February 9th, 2010

Silverlight Brush Effect – Paint Splatter

All Silverlight Examples, Silverlight 3 tutorials, Silverlight C# Tutorials, Silverlight Effects, by Gavin Wignall.

Using the Line element and some Random math I have created a paint splatter brush effect. Use the color palette at the top of the example to change color and then draw using the mouse.

To create this effect, I plot lines one after the other using the Line element. Starting from the mouse co-ordinates and then using Random math to plot each further point. The length and size of each splatter is also set each time using Random math.

To create a line using the Line component:

To create a new line we perform the following

Create a new Line and call it Line1…

Line Line1 = new Line();

Set the start co-ordinates of the line…

Line1.X1 = 0;

Line1.Y1 = 0;

Set the end co-ordinates of the line…

Line1.X2 = 10;

Line1.Y2 = 10;

Add the line to the page…


You can see another post I made on building a Paint Application here.

To get a Random number we use the following code in C#:

First define the variable…

private Random NextDouble = new Random();

Then each time you want a new Random number perform the following…


This value will be of a double figure between 0 and 1. To get a specific range of random numbers we need to multiply this value.

To get a Random number between 0 and 100…

NextDouble.NextDouble() * 100;

To get a Random number between 50 and 100…

(NextDouble.NextDouble() * 50) + 50;

Grab the Source

As always, you can grab the source files to this post here.

Back Top

Responses to “Silverlight Brush Effect – Paint Splatter”

  1. Spitzen Gutscheinaktionen Gutschein nur hier! Schnell kommen und sparen!

  1. No trackbacks yet.

Leave a Reply

Back Top