Feast your eyes...
(usual drill, setup a form with a button and paste this code in)
VB Code:
imports system.drawing.drawing2d '........ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim g As Graphics = Me.CreateGraphics 'shape of the pen stroke Dim curve() As Point = New Point(6) _ { _ New Point(10, 10), _ New Point(20, 60), _ New Point(90, 240), _ New Point(280, 210), _ New Point(60, 60), _ New Point(30, 180), _ New Point(300, 300) _ } 'define a fancy color gradient Dim ink As PathGradientBrush = New PathGradientBrush(curve) '########### 'temporary object for setting up the color gradient Dim blender As ColorBlend = New ColorBlend(curve.Length) blender.Colors = New Color(6) {Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, Color.Violet} blender.Positions = New Single(6) {} For i As Integer = 0 To 6 blender.Positions(i) = i * (1.0F / 6.0F) 'equally space each colour along the path outline Next i ink.InterpolationColors = blender '########### Dim CoolPen As Pen = New Pen(ink, 20) 'create a customisable pen object CoolPen.CompoundArray() = New Single() {0, 0.2, 0.4, 0.5, 0.75, 1} 'the 3 striped pen instead of a single "nib" g.DrawBeziers(CoolPen, curve) 'go! End Sub




Reply With Quote