Gradients for soft brush

daspope

New member
Joined
Aug 2, 2004
Messages
4
hello all, I am trying to create a radial gradiant ellipse to create a soft brush for a simple paint app im making. ive searched the crap out of gradients for VB.NET and all i can come up with is stuff for buttons and form backgrounds etc.

i currently draw my round (ellipse) brushes with the following:

Code:
PictureBox1.CreateGraphics.FillEllipse(New SolidBrush(Color.FromArgb(VScrollBar1.Value, VScrollBar2.Value, VScrollBar3.Value)), e.X, e.Y, HScrollBar1.Value, HScrollBar1.Value)

in the mousedown and mousemove events

in the mouse up it sets my canpaint variable to false and saves picturebox1 to a bitmap object type so that i do not lose the drawing when the app is minimized etc.

its pretty late so this might now make sense, but im looking for a way i can plug in a new boolean var i.e. isGradient and if its true draw a radial gradient ellipse instead of the solid.

also while im here instead of creating a new thread later... ive been trying to think of a logical way to create solid lines when the mouse is moved fast... currently if the user moves the mouse too fast they get seperated dots and not a solid path. i was thinking of logging all of the mouse x,y coords to an array while the mouse is moving and then on mouse up calling a function that takes these coords and compares them one element at a time and if theres a gap of more than 2 to fill it in, but i dont think this would be the easiest/smartest/best way to go about that.

thanks in advance for any info/suggestions.
 
nevermind, i got it worked out... i was lacking sleep last night and not thinking clearly, i just need to apply gradiants to the shape similar to how i applied my hatch texture

Code:
If brush = 1 Then
Dim g As Graphics = PictureBox1.CreateGraphics
        Dim TexBrush As New _
        System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D. _
        HatchStyle.SolidDiamond, Color.Red, Color.Blue)
            g.FillEllipse(TexBrush, x, y, HScrollBar1.Value, HScrollBar1.Value)
End If
 
Back
Top