Flash vs Silverlight Gallery Flash vs Silverlight: Flip Rotator
Sep 15

Kaleidoscope is an attractive toy for me when I was young. You can use any image you like and it will produce many amazing effects via mirror reflection.

You won’t be able to figure out the original image if you don’t download the source now~

Comparison

Flash implementation: 40 minutes  
Silverlight implementation: 1 hour 30 minutes (Implemented First)
What’s the difference?

  • Triangle Mask: mask [AS3] vs PathGeometry [C#]

Source codes

Flash

Silverlight

Triangle Mask: mask [AS3] vs PathGeometry [C#]

The Kaleidoscope is created by masking an image with a triangle and duplicating the masked images.

// AS3
// Create a triangle mask
var mask : Shape = new Shape();
mask.graphics.beginFill(0x000000);
mask.graphics.moveTo(0, 0);

// add the triangle points
mask.graphics.lineTo(100, 100);
mask.graphics.lineTo(0, 100);
mask.graphics.lineTo(0, 0);
mask.graphics.endFill();

// mask the current object
this.mask = mask;

// remember to add the mask to the stage
addChild(mask);

In my previous article Water Effect, we have discussed how to clip the object easily using Ellipse or Rectangle. However, if you want to clip the object using irregular shape, some more work has to be done. Below is a demonstration.

// C#
// Create a path geometry
PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.IsClosed = true;
pathFigure.StartPoint = new Point(0, 0);

// add the triangle points
PolyLineSegment polyLineSegment = new PolyLineSegment();
polyLineSegment.Points.Add(new Point(100, 100));
polyLineSegment.Points.Add(new Point(0, 100));
polyLineSegment.Points.Add(new Point(0, 0));

pathFigure.Segments.Add(polyLineSegment);
pathGeometry.Figures.Add(pathFigure);

// clip the current object
this.Clip = pathGeometry;

Shares and Enjoy~

Did you like this post?

Subscribe here:  

9 Responses to “Silverlight vs Flash: Kaleidoscope”

  1. cigraphics Says:

    SilverLight is a memory hog :|. It looks that it moves in slow motion but flash works fine

  2. unruledboy Says:

    found http://www.mashooo.com/ a few months ago, with over 50 silverlight games, thought you might want to have look at the “draw” effects:)

  3. admin Says:

    Thanks unruledboy, the games are nice, especially the line runner.

  4. Silverlight Cream for September 15, 2008 -- #368 Says:

    [...] Comparisons. Mike Snow gives us a big caution and example of floating point comparison issues. Silverlight vs Flash: Kaleidoscope Terence Tsang tackled the Kaleidoscope this time out … runs very smoothly to my eyes… Throwing [...]

  5. Jeryyms Says:

    Nice site you have

  6. hombre desnudos foto Says:

    Ringraziamenti molto! Lo avete aiutato molto!

  7. Tim Says:

    if you use process explorer the silver light uses less cpu than flash

  8. Luke Says:

    NOTE: Visitors should make sure that they refresh the page before each test as the second test loses some cycles to the still running first test. Both stutter to get going, which is interesting.

  9. Luke Says:

    Flash consumes about 20% more CPU time which is good and bad. Good in that it gets what it wants to enhance the experience and bad for other apps.

    Its difficult to argue that SL looks half the speed in the side-by-side but we know from the FPS stress test that SL seems to be much faster with small loads but drops off quicker the more that’s added to the screen.

Leave a Reply