uff, Cedric, i got opposite results

blurFilter=shaky and unstable
convultionFilter=svery smooth

can anybody tell me why?



On 1/31/06, Cédric Muller <[EMAIL PROTECTED]> wrote:
> ???????
> blurFilter=very smooth
> convultionFilter=shaky and unstable
>
>
>
> > much better with Convolution filter :)
> >
> > On 1/31/06, Mike Mountain <[EMAIL PROTECTED]> wrote:
> >> OK you'll need a movie 768x768 - copy this code on to frame 1 etc.
> >>
> >> with blur filter:
> >>
> >> [/as]
> >> import flash.filters.*;
> >> import flash.geom.*;
> >> import flash.display.*;
> >> //
> >> //import flash.display.Bitmap;
> >> var width:Number = 768;
> >> var height:Number = 768;
> >> var offScreen1:BitmapData = new BitmapData(width, height, false, 0);
> >> var onScreen:BitmapData = new BitmapData(width, height, false, 0);
> >> var zeroPoint:Point = new Point(0, 0);
> >> var clip:MovieClip = createEmptyMovieClip("clip", 1);
> >> clip._x = 0;
> >> clip._y = 0;
> >> clip.attachBitmap(onScreen, 1);
> >> // wire the bitmap to the screen
> >> function RGBtoHEX(r, g, b) {
> >>         return (r << 16 | g << 8 | b);
> >> }
> >> function spectre(angle) {
> >>         r = (180-angle)/180*Math.PI;
> >>         var c_r = Math.sin(r++)*127+128 << 16;
> >>         var c_g = Math.sin(r)*127+128 << 8;
> >>         var c_b = Math.cos(r--)*127+128;
> >>         return (c_r | c_g | c_b);
> >> }
> >> var filterArray = new Array();
> >> //var filter:GlowFilter = new GlowFilter(color, alpha, blurX,
> >> blurY, strength, quality, inner, knockout);
> >> //filterArray.push(filter);
> >> var blurX = 20;
> >> var blurY = 20;
> >> var quality = 2;
> >> var filter = new BlurFilter(blurX, blurY, quality);
> >> filterArray.push(filter);
> >> //
> >> var plug = _root.createEmptyMovieClip('plug', 10);
> >> plug._y = 200;
> >> plug._x = 200;
> >> createEmptyMovieClip('canvas', 200);
> >> t = 0;
> >> numsegs = 15;
> >> segmentLength = 6;
> >> drawCord = function () {
> >>         t += 2;
> >>         lw = Math.sin(t)*100;
> >>         //trace(lw);
> >>         a = 100;
> >>         //trace(a)
> >>         canvas.clear();
> >>         var col = spectre(t);
> >>         canvas.lineStyle(1, col, a);
> >>         canvas.moveTo(plug._x, plug._y);
> >>         points[0] = new Object();
> >>         points[0].x = plug._x;
> >>         points[0].y = plug._y;
> >>         var v1 = 1;
> >>         while (v1<points.length-1) {
> >>                 v4 = Math.atan2(points[v1].y-points[v1-1].y, points
> >> [v1].x-points[v1-1].x);
> >>                 v3 = points[v1-1].x+(segmentLength)*Math.cos(v4)*2;
> >>                 v2 = points[v1-1].y+(segmentLength)*Math.sin(v4)*2;
> >>                 points[v1].x = v3;
> >>                 points[v1].y = v2;
> >>                 canvas.lineStyle((points.length-v1)/2, col);
> >>                 canvas.lineTo(v3, v2);
> >>                 ++v1;
> >>         }
> >>         //(points.length-v1)/2
> >> };
> >> var points = new Array();
> >> var i = 0;
> >> while (i<numsegs) {
> >>         points[i] = new Object();
> >>         points[i].x=5*i, points[i].y=Math.sin(i/20);
> >>         ++i;
> >> }
> >> //drawCord();
> >> plug.xVel = 10+Math.random()*10;
> >> plug.yVel = 10+Math.random()*10;
> >> plug.xmax = Stage.width;
> >> plug.xmin = 0;
> >> plug.ymax = Stage.height;
> >> plug.ymin = 0;
> >> /*
> >> var matrixX:Number = 3;
> >> var matrixY:Number = 3;
> >> var matrix:Array = [1, 1, 1, 0, 0, 0, 0, 1, 0];
> >> var divisor:Number = 4;
> >> */
> >> //var sfilter:ConvolutionFilter = new ConvolutionFilter(matrixX,
> >> matrixY, matrix, divisor);
> >> var blurX = 10;
> >> var blurY = 10;
> >> var quality = 2;
> >> var sfilter = new BlurFilter(blurX, blurY, quality);
> >>
> >> //
> >> myMatrix = new Matrix();
> >> translateMatrix = new Matrix();
> >> degrees = 180;
> >> radians = (degrees/180)*Math.PI;
> >> myMatrix.rotate(radians);
> >> translateMatrix.translate(768, 768);
> >> myMatrix.concat(translateMatrix);
> >> myColorTransform = new ColorTransform();
> >> blendMode = "normal";
> >> myRectangle = new Rectangle(0, 0, 768, 768);
> >> smooth = true;
> >> // sfilter = new BlurFilter(5, 5, 1);
> >> plug.onEnterFrame = function() {
> >>         rolldie = Math.random()*100;
> >>         if (rolldie>97) {
> >>                 this.xVel = -10+Math.random()*20;
> >>                 this.yVel = -10+Math.random()*20;
> >>         }
> >>         canvas.filters = filterArray;
> >>         drawCord();
> >>         copyStage();
> >>         var nextX = this.xVel+this._x;
> >>         var nextY = this.yVel+this._y;
> >>         if (nextX>this.xmax) {
> >>                 this.xVel = (this.xVel+Math.random()*10)*-1;
> >>                 nextX = this.xmax-(nextX-this.xmax);
> >>         } else if (nextX<this.xmin) {
> >>                 this.xVel = (this.xVel+Math.random()*10)*-1;
> >>                 nextX = this.xmin+(this.xmin-nextX);
> >>         }
> >>         if (nextY>this.ymax) {
> >>                 this.yVel = (this.yVel+Math.random()*10)*-1;
> >>                 nextY = this.ymax-(nextY-this.ymax);
> >>         } else if (nextY<this.ymin) {
> >>                 this.yVel = (this.yVel+Math.random()*10)*-1;
> >>                 nextY = this.ymin+(this.ymin-nextY);
> >>         }
> >>         this._x = nextX;
> >>         this._y = nextY;
> >>         onScreen.copyPixels(offScreen1, offScreen1.rectangle,
> >> zeroPoint);
> >>         onScreen.applyFilter(offScreen1, offScreen1.rectangle, new
> >> Point(0, 0), sfilter);
> >>         offScreen1.draw(_root, myMatrix, myColorTransform,
> >> blendMode, myRectangle, smooth);
> >> };
> >> [/as]
> >>
> >>
> >> With convolution filter:
> >>
> >> [as]
> >> import flash.filters.*;
> >> import flash.geom.*;
> >> import flash.display.*;
> >> //
> >> //import flash.display.Bitmap;
> >> var width:Number = 768;
> >> var height:Number = 768;
> >> var offScreen1:BitmapData = new BitmapData(width, height, false, 0);
> >> var onScreen:BitmapData = new BitmapData(width, height, false, 0);
> >> var zeroPoint:Point = new Point(0, 0);
> >> var clip:MovieClip = createEmptyMovieClip("clip", 1);
> >> clip._x = 0;
> >> clip._y = 0;
> >> clip.attachBitmap(onScreen, 1);
> >> // wire the bitmap to the screen
> >> function RGBtoHEX(r, g, b) {
> >>         return (r << 16 | g << 8 | b);
> >> }
> >> function spectre(angle) {
> >>         r = (180-angle)/180*Math.PI;
> >>         var c_r = Math.sin(r++)*127+128 << 16;
> >>         var c_g = Math.sin(r)*127+128 << 8;
> >>         var c_b = Math.cos(r--)*127+128;
> >>         return (c_r | c_g | c_b);
> >> }
> >> var filterArray = new Array();
> >> //var filter:GlowFilter = new GlowFilter(color, alpha, blurX,
> >> blurY, strength, quality, inner, knockout);
> >> //filterArray.push(filter);
> >> var blurX = 20;
> >> var blurY = 20;
> >> var quality = 2;
> >> var filter = new BlurFilter(blurX, blurY, quality);
> >> filterArray.push(filter);
> >> //
> >> var plug = _root.createEmptyMovieClip('plug', 10);
> >> plug._y = 200;
> >> plug._x = 200;
> >> createEmptyMovieClip('canvas', 200);
> >> t = 0;
> >> numsegs = 15;
> >> segmentLength = 6;
> >> drawCord = function () {
> >>         t += 2;
> >>         lw = Math.sin(t)*100;
> >>         //trace(lw);
> >>         a = 100;
> >>         //trace(a)
> >>         canvas.clear();
> >>         var col = spectre(t);
> >>         canvas.lineStyle(1, col, a);
> >>         canvas.moveTo(plug._x, plug._y);
> >>         points[0] = new Object();
> >>         points[0].x = plug._x;
> >>         points[0].y = plug._y;
> >>         var v1 = 1;
> >>         while (v1<points.length-1) {
> >>                 v4 = Math.atan2(points[v1].y-points[v1-1].y, points
> >> [v1].x-points[v1-1].x);
> >>                 v3 = points[v1-1].x+(segmentLength)*Math.cos(v4)*2;
> >>                 v2 = points[v1-1].y+(segmentLength)*Math.sin(v4)*2;
> >>                 points[v1].x = v3;
> >>                 points[v1].y = v2;
> >>                 canvas.lineStyle((points.length-v1)/2, col);
> >>                 canvas.lineTo(v3, v2);
> >>                 ++v1;
> >>         }
> >>         //(points.length-v1)/2
> >> };
> >> var points = new Array();
> >> var i = 0;
> >> while (i<numsegs) {
> >>         points[i] = new Object();
> >>         points[i].x=5*i, points[i].y=Math.sin(i/20);
> >>         ++i;
> >> }
> >> //drawCord();
> >> plug.xVel = 10+Math.random()*10;
> >> plug.yVel = 10+Math.random()*10;
> >> plug.xmax = Stage.width;
> >> plug.xmin = 0;
> >> plug.ymax = Stage.height;
> >> plug.ymin = 0;
> >>
> >> var matrixX:Number = 3;
> >> var matrixY:Number = 3;
> >> var matrix:Array = [1, 1, 1, 0, 0, 0, 0, 1, 0];
> >> var divisor:Number = 4;
> >> var sfilter:ConvolutionFilter = new ConvolutionFilter(matrixX,
> >> matrixY, matrix, divisor);
> >> /*
> >> var blurX = 10;
> >> var blurY = 10;
> >> var quality = 2;
> >> var sfilter = new BlurFilter(blurX, blurY, quality);
> >> */
> >> //
> >> myMatrix = new Matrix();
> >> translateMatrix = new Matrix();
> >> degrees = 180;
> >> radians = (degrees/180)*Math.PI;
> >> myMatrix.rotate(radians);
> >> translateMatrix.translate(768, 768);
> >> myMatrix.concat(translateMatrix);
> >> myColorTransform = new ColorTransform();
> >> blendMode = "normal";
> >> myRectangle = new Rectangle(0, 0, 768, 768);
> >> smooth = true;
> >> // sfilter = new BlurFilter(5, 5, 1);
> >> plug.onEnterFrame = function() {
> >>         rolldie = Math.random()*100;
> >>         if (rolldie>97) {
> >>                 this.xVel = -10+Math.random()*20;
> >>                 this.yVel = -10+Math.random()*20;
> >>         }
> >>         canvas.filters = filterArray;
> >>         drawCord();
> >>         copyStage();
> >>         var nextX = this.xVel+this._x;
> >>         var nextY = this.yVel+this._y;
> >>         if (nextX>this.xmax) {
> >>                 this.xVel = (this.xVel+Math.random()*10)*-1;
> >>                 nextX = this.xmax-(nextX-this.xmax);
> >>         } else if (nextX<this.xmin) {
> >>                 this.xVel = (this.xVel+Math.random()*10)*-1;
> >>                 nextX = this.xmin+(this.xmin-nextX);
> >>         }
> >>         if (nextY>this.ymax) {
> >>                 this.yVel = (this.yVel+Math.random()*10)*-1;
> >>                 nextY = this.ymax-(nextY-this.ymax);
> >>         } else if (nextY<this.ymin) {
> >>                 this.yVel = (this.yVel+Math.random()*10)*-1;
> >>                 nextY = this.ymin+(this.ymin-nextY);
> >>         }
> >>         this._x = nextX;
> >>         this._y = nextY;
> >>         onScreen.copyPixels(offScreen1, offScreen1.rectangle,
> >> zeroPoint);
> >>         onScreen.applyFilter(offScreen1, offScreen1.rectangle, new
> >> Point(0, 0), sfilter);
> >>         offScreen1.draw(_root, myMatrix, myColorTransform,
> >> blendMode, myRectangle, smooth);
> >> };
> >> [/as]
> >>
> >> Although it may be something to do with the application of the
> >> filter....
> >>
> >> Scuse the dodgy code - WIP.
> >>
> >> M
> >>
> >>
> >>> -----Original Message-----
> >>> From: [EMAIL PROTECTED]
> >>> [mailto:[EMAIL PROTECTED] On Behalf
> >>> Of Mike Duguid
> >>> Sent: 30 January 2006 22:44
> >>> To: Flashcoders mailing list
> >>> Subject: Re: [Flashcoders] ConvolutionFilter performance
> >>>
> >>> Mike, do you have an example of this? My current test shows
> >>> the opposite - that convolution is proving more cpu intensive
> >>> than blurfilter?
> >>>
> >>>
> >>>> Mike Mountain  <[EMAIL PROTECTED]> wrote:
> >>>> In my tests convolution filter was much faster than a blurfilter.
> >>>> But it's an easy one to swap oout and test for yourself...
> >>>
> >>>
> >>>> Andreas R�nning <[EMAIL PROTECTED]> wrote:
> >>>> Does anyone know which is faster; a blurring one-pass convolution
> >>>> filter or a blurfilter? Or are they just 2 sides to the
> >>> same story? I
> >>>> need a high performance blur operation for depth of field..
> >>>>
> >>>> Cheers,
> >>>>
> >>>> - Andreas
> >>> _______________________________________________
> >>> Flashcoders mailing list
> >>> Flashcoders@chattyfig.figleaf.com
> >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>>
> >> _______________________________________________
> >> Flashcoders mailing list
> >> Flashcoders@chattyfig.figleaf.com
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >
> >
> > --
> > ----------------------------------------------------------------------
> > ----------------------------------------------------------------------
> > ---------------------
> > Franto
> >
> > http://blog.franto.com
> > http://www.flashcoders.sk
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>


--
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Franto

http://blog.franto.com
http://www.flashcoders.sk
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to