actionscript3/Flash中的半色调效果
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了actionscript3/Flash中的半色调效果相关的知识,希望对你有一定的参考价值。
This is a demo of a halftone effect for AS3. It requires a halftone filter file. You can download all the files required for this at http://www.adamcoulombe.info/lab/as3/halftone/
package { import flash.display.*; import flash.events.*; import flash.filters.*; import flash.net.*; public class Halftone extends Sprite { private var image:Class; private var loader:URLLoader; private var shader:Shader; private var filter:ShaderFilter; private var im:Bitmap; public function Halftone():void { var myImage = new MyImage(500,333); im = new Bitmap(myImage); addChild(im); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.BINARY; loader.addEventListener(Event.COMPLETE, onComplete); loader.load(new URLRequest("Halftone.pbj")); //Download: http://www.adamcoulombe.info/lab/as3/halftone/Halftone.pbj } private function onComplete(e:Event):void { stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved) } private function mouseMoved(e):void { shader = new Shader(loader.data); //shader.data.contrast.value = [ 1 ] ; shader.data.brightness.value = [ stage.mouseX /stage.stageWidth + 1 ]; //shader.data.amount.value = [100]; filter = new ShaderFilter(shader); im.filters = [filter]; } } }
以上是关于actionscript3/Flash中的半色调效果的主要内容,如果未能解决你的问题,请参考以下文章