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/
  1. package
  2. {
  3. import flash.display.*;
  4. import flash.events.*;
  5. import flash.filters.*;
  6. import flash.net.*;
  7.  
  8.  
  9.  
  10. public class Halftone extends Sprite
  11. {
  12.  
  13. private var image:Class;
  14.  
  15. private var loader:URLLoader;
  16. private var shader:Shader;
  17. private var filter:ShaderFilter;
  18. private var im:Bitmap;
  19.  
  20. public function Halftone():void
  21. {
  22. var myImage = new MyImage(500,333);
  23. im = new Bitmap(myImage);
  24. addChild(im);
  25. loader = new URLLoader();
  26. loader.dataFormat = URLLoaderDataFormat.BINARY;
  27. loader.addEventListener(Event.COMPLETE, onComplete);
  28. loader.load(new URLRequest("Halftone.pbj")); //Download: http://www.adamcoulombe.info/lab/as3/halftone/Halftone.pbj
  29. }
  30.  
  31. private function onComplete(e:Event):void
  32. {
  33. stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved)
  34.  
  35. }
  36. private function mouseMoved(e):void
  37. {
  38. shader = new Shader(loader.data);
  39. //shader.data.contrast.value = [ 1 ] ;
  40. shader.data.brightness.value = [ stage.mouseX /stage.stageWidth + 1 ];
  41. //shader.data.amount.value = [100];
  42. filter = new ShaderFilter(shader);
  43. im.filters = [filter];
  44. }
  45. }
  46. }

以上是关于actionscript3/Flash中的半色调效果的主要内容,如果未能解决你的问题,请参考以下文章

在我的导航栏 iOS 7 中设置色调/半透明级别的问题

JavaScript/HTML/CSS 半色调线条效果

Adobe Flash动作脚本3

半透明边框与background-clip

如何使用 argparse 模块?

Android中的半透明状态栏