HighTechTalks DotNet Forums  

PathGradient code almost works

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss PathGradient code almost works in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
active
 
Posts: n/a

Default PathGradient code almost works - 05-07-2007 , 10:01 AM






Just playing to become familiar with the PathGradient, I wrote this to
display two squares. The first one displays but not the second one.

I made some guesses about reusing the Path, and the Point and Colors
arrays - probable not all correct.

Thanks



Private Sub FillGradientRectangles()

Dim gr As Graphics = Panel1.CreateGraphics

Dim path As New GraphicsPath()

Dim points As Point() = { _

New Point(0, 0), _

New Point(0, 150), _

New Point(150, 150), _

New Point(150, 0)}

path.AddLines(points)

Dim pthGrBrush As New PathGradientBrush(path)

pthGrBrush.CenterColor = Color.FromArgb(255, 0, 127, 127)

Dim colors As Color() = { _

Color.FromArgb(255, 0, 0, 0), _

Color.FromArgb(255, 0, 255, 0), _

Color.FromArgb(255, 0, 255, 255), _

Color.FromArgb(255, 0, 0, 255)}

pthGrBrush.SurroundColors = colors

gr.FillPath(pthGrBrush, path)

'DRAW SECOND SQUARE

path.Reset()

points(0) = New Point(300, 0)

points(1) = New Point(300, 150)

points(2) = New Point(150, 150)

points(3) = New Point(150, 0)

path.AddLines(points)

pthGrBrush.CenterColor = Color.FromArgb(255, 127, 127, 127)

colors(0) = Color.FromArgb(255, 255, 0, 0)

colors(1) = Color.FromArgb(255, 255, 255, 0)

colors(2) = Color.FromArgb(255, 0, 255, 255)

colors(3) = Color.FromArgb(255, 0, 0, 255)

pthGrBrush.SurroundColors = colors

gr.FillPath(pthGrBrush, path)

gr.Dispose()






End Sub



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.