Something like Nerhol http://nerhol.com/ Saqoosha forked:4 favorite:19 lines:76 license : MIT License modified : 2012-03-30 13:32:56 package { import com.adobe.images.PNGEncoder; import com.bit101.components.HBox; import com.bit101.components.PushButton; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.BitmapDataChannel; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.TimerEvent; import flash.filters.BevelFilter; import flash.filters.BitmapFilterQuality; import flash.geom.Matrix; import flash.geom.Point; import flash.geom.Rectangle; import flash.media.Camera; import flash.media.Video; import flash.net.FileReference; import flash.utils.Timer; /** * Webcam required. * @author Saqoosha * @see http://nerhol.com/ */ [SWF(backgroundColor="#FFFFFF", frameRate="30", width="465", height="465")] public class SomethingLikeNerhol extends Sprite { private static const PT:Point = new Point(); private static const RECT:Rectangle = new Rectangle(0, 0, 465, 465); private var _noise:BitmapData = new BitmapData(465, 465, false, 0x0); private var _final:BitmapData = new BitmapData(465, 465, false, 0x0); private var _video:Video = new Video(640, 480); private var _tmp:BitmapData = new BitmapData(465, 465, true, 0x0); private var _color:BitmapData = new BitmapData(465, 465, true, 0x0); private var _mtx:Matrix = new Matrix(-1, 0, 0, 1, 552.5, 0); private var _bevel:BevelFilter = new BevelFilter(1, 45, 0xffffff, 0.2, 0x0, 0.2, 1, 1, 1, BitmapFilterQuality.LOW); private var _min:int = 0; private var _max:int = 0; private var _current:int = 1; private var _timer:Timer = new Timer(50); public function SomethingLikeNerhol() { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; var cam:Camera = Camera.getCamera(); if (!cam) return; cam.setMode(640, 480, 30); _video.attachCamera(cam); _video.smoothing = true; addChild(new Bitmap(_final)); var hbox:HBox = new HBox(this, 5, 5); new PushButton(hbox, 0, 0, 'GENERATE', _generate).width = 80; new PushButton(hbox, 0, 0, 'SAVE', _save).width = 50; _timer.addEventListener(TimerEvent.TIMER, _update); } private function _generate(e:* = null):void { var o:Number = Math.random() * 300 + 200; _noise.perlinNoise(o, o, 2, new Date().getTime(), false, true, 7, true); var hist:Vector.<Number> = _noise.histogram()[0]; for (_min = 0; _min < 256; _min++) { if (hist[_min]) break; } for (_max = 255; _max >= 0; _max--) { if (hist[_max]) break; } _current = _min; _timer.start(); } private function _update(e:* = null):void { _tmp.fillRect(RECT, 0x0); _tmp.threshold(_noise, RECT, PT, '>=', _current, 0xffffffff, 0xff); _color.draw(_video, _mtx, null, null, null, true); _color.copyChannel(_tmp, RECT, PT, BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA); _color.applyFilter(_color, RECT, PT, _bevel); _final.copyPixels(_color, RECT, PT); if (++_current > _max) _timer.stop(); } private function _save(e:* = null):void { new FileReference().save(PNGEncoder.encode(_final), 'something-like-nerhol.png'); } } } Code Fullscreen Preview Fullscreen alexnotkin OKASUKE zob PESakaTFM linktale savage69kr BeloitAve Alchemist bradsedito umhr tjoen nki2 iamroox : BitmapData camera Effect Motion particles ushanos : cameraTransforms beryu : camera hidrodixtion.. : awesome effect generator webcam alumican_net.. : ネルホル bkzen : 画像変形 smart_ant : 画像変形 BitmapData Motion awesome camera effect generator particles webcam 画像変形 Video smoothing BitmapFilterQuality.LOW save addEventListener getTime width attachCamera FileReference stop Rectangle StageScaleMode.NO_SCALE Timer Date start TimerEvent.TIMER Vector Math.random Number int sort new page view favorite forked pv 0 forked from: Something like Ne.. leenan5210 forked:0 favorite:0 lines:76 ( diff:1 ) pv 0 forked from: Something like Ne.. Trevor.Fulton forked:0 favorite:0 lines:76 ( diff:1 ) pv 517 forked from: Something like Ne.. hacker_zxh9vkwz forked:1 favorite:0 lines:76 ( diff:1 ) pv 305 forked from: Something like Ne.. 4dmaker forked:0 favorite:0 lines:76 ( diff:1 )