Tuesday, April 1, 2008

Motion Blur in Silverlight 2

Gilbok Lee posted an example of motion blur in Silverlight 2 on the Silverlight Forum (http://silverlight.net/forums/t/13167.aspx) which turned out to be an April Fools joke.

Very funny ;)... But thanks to one of the flash developers I work with (thanks Martijn Croezen) I was able to create a motion blur effect.
You can use the sliders for adjusting the amount of blur and the opacity.

Click here for the demo

Click here for the source

4 comments:

  1. "April fools, we actually made it work for real!" :)

    Who needs bitmapfilters :)

    oh wait. WE do!

    ReplyDelete
  2. ...sure we all do! Armed with BitmapFilters, Silverlight - IMHO - is already comparable to Flash (or even better).

    ReplyDelete
  3. no longer works in the new silverlight

    ReplyDelete
  4. I hope fixed the exeptions. The biggest problem was to change the pathmarkupsyntax into seperate segments in C#. Then come further exception that you cannot cast from int to double but you have simply to put a point and zero (e.g. 0 -> 0.0). Then the project works fine. Just replace the following code with following.

    Code:
    PathGeometry pathGeo = new PathGeometry();
    PathFigure pathFigure = new PathFigure();
    pathFigure.StartPoint = new Point(0.5, 0.5);
    LineSegment lg1 = new LineSegment();
    lg1.Point = new Point(this.Width, 0.5);

    LineSegment lg2 = new LineSegment();
    lg2.Point = new Point(this.Width, this.Height);

    LineSegment lg3 = new LineSegment();
    lg3.Point = new Point(0.5, this.Height);
    PathSegmentCollection psc = new PathSegmentCollection();

    psc.Add(lg1);
    psc.Add(lg2);
    psc.Add(lg3);

    pathFigure.Segments = psc;
    PathFigureCollection pfc = new PathFigureCollection();
    pfc.Add(pathFigure);
    pathGeo.Figures = pfc;
    OverallPlaceholder.SetValue(Canvas.ClipProperty, pathGeo);

    ReplyDelete