With the advantage of rendering speed, Flash and Silverlight can provide a richer experience in drawing and image filtering. Moreover, by using the Timer Event, real time replay of drawing bring us into another generation of art.
Recently, I got quite many application requests. I think a implementation list will be made to give you a better idea what will happen in the next few days.
Comparison
Flash implementation: 1 hour 10 minutes
Silverlight implementation: 1 hour 30 minutes
What’s the difference?
- Line Drawing: moveTo, LineTo [AS3] vs System.Windows.Shapes.Line [C#]
Source codes
Simple Drawing [Flash 9, AS3] (16.2 KiB, 1,510 hits)
Simple Drawing [Silverlight 2, C#] (48.8 KiB, 1,885 hits)
Flash
Silverlight
Line: moveTo, LineTo [AS3] vs System.Windows.Shapes.Line [C#]
I think drawing in AS3 is pretty straight forward and easy. It’s because all of the drawing libraries can be found inside the graphics object.
// AS3 // draw a square var shape:Shape = new Shape(); shape.graphics.lineStyle(LINE_WIDTH, 0x000000); shape.graphics.moveTo(0, 0); shape.graphics.lineTo(0, 100); // you can change the lineStyle anytime shape.graphics.lineStyle(LINE_WIDTH, 0x000000); shape.graphics.lineTo(100, 100); shape.graphics.lineTo(100, 0); shape.graphics.lineTo(0, 0); addChild(shape);
How about in C#? Silverlight has a wide range of line drawing libraries. Though it’s powerful, but I really find it hard to learn. By a series of trial and error, I have come up a solution to draw a square using code. I think much more time is needed to explore the whole mystery of the Line Class.
Other than that, Silverlight has a readily available control (InkPresenter) for drawing lines. However, if you really want to produce the “ink” effect similar to the above sample, you may only do it by yourself.
// C# // draw a square PolyLineSegment polyLineSegment = new PolyLineSegment(); polyLineSegment.Points.Add(new Point(0, 100)); polyLineSegment.Points.Add(new Point(100, 100)); polyLineSegment.Points.Add(new Point(100, 0)); polyLineSegment.Points.Add(new Point(0, 0)); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = new Point(0, 0); pathFigure.Segments.Add(polyLineSegment); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(pathFigure); Path path = new Path(); path.Stroke = new SolidColorBrush(Colors.Black); path.StrokeThickness = 10; path.Data = pathGeometry; // add to the stage LayoutRoot.Children.Add(path);

September 9th, 2008 at 8:37 am
Hello,
This is an interesting comparison of the two platforms. However Silverlight (and WPF) really shines in markup. You can recreate the path geometry with this simple line of markup
You might have to change the layout for this because I wrote it for WPF. But it’s not far off from what you’d write for Silverlight. I think you’re hiding a major convenience that silverlight provides by not including the markup components of the platform.
September 9th, 2008 at 8:40 am
Hmm…looks like your engine ate my markup
September 9th, 2008 at 1:29 pm
HI Brown, I agree that Silverlight has a huge advantange in using the mark up as well. Actually, I want to demonstrate how things are done (in code) in both of the technology.
Anyway, I also think that it’s also important to show the best side of them, I will review this problem. Thanks for you suggestion.
September 9th, 2008 at 3:07 pm
[...] Flash vs Silverlight- Simple Drawing [...]
September 9th, 2008 at 11:33 pm
Size-wise Flash is still better but the language behind Silverlight is more robust. Using this post as a gauge of which was better I would say Flash since the Silverlight demo wouldn’t start for me, it simply added a black dot on the far right when I clicked.
September 10th, 2008 at 4:19 am
The flash api is more NORMAL, if you’ve ever used any drawing api.
Whhile SL’s api is wierd, I’ll take it because C# is ohhhh so sweet, and we’re able to reuse code on both the server and client.
September 10th, 2008 at 10:27 am
excellent, I like it, though the “ink” seems not so “inky” with my mouse :)
September 10th, 2008 at 3:11 pm
Flash version works on Linux, Silverlight version doesn’t.
Flash wins!
September 18th, 2008 at 4:44 am
I like Silverlight… the only thing is having to download, run, install silverlight if it’s not already on the client machine and then having to restart the browser. That’s the only thing I wish could be fixed to make it over the top over Flash
October 21st, 2008 at 6:40 pm
Thank you for valuable information.
May 17th, 2009 at 11:22 pm
How can I speed up the replay function? Thanks!
I’ve got a few more question, can I chat directly to you? in yahoo? ID: shellingford_inlove
June 9th, 2009 at 5:17 pm
Silverlight now works with Linux, Moonlight for SL 2.0 is in Alpha Release, works for me on Ubuntu.
August 15th, 2009 at 3:32 pm
[...] Flash vs Silverlight: Simple Drawing [...]
October 18th, 2009 at 2:30 am
i aggree that sl have a great convenience on its markup syntax, but most of the times, we have to do that in code to get dynamic effect, and markup don’t help us at all.
the drawing api of silverlight is so ugly
February 6th, 2010 at 1:16 am
You could use Rectangle in SilverLight instead of manually drawing it with lines.