Gradient Brush
-
Okay this looks nasty. Real Nasty. So here's the code. Its supposed to be three parallel color polygons but, it doesn't look like that. This is the first time i'm using the gradient brush so, if any of the experienced Vb programmers could help me make it look neater than what it is, that would be appreciated. Private Sub frmSplash_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'Declares procedure level varaibles. Dim brGradient As System.Drawing.Drawing2D.LinearGradientBrush Dim points() As PointF 'Defines the rectangle. Dim clientRectangle As New System.Drawing.Rectangle(0, 0, _ Me.Width, Me.Height) 'Sets the Gradient Brush color for the red polygon. brGradient = New System.Drawing.Drawing2D.LinearGradientBrush(clientRectangle, _ Color.Black, Color.Red, _ System.Drawing.Drawing2D.LinearGradientMode.Horizontal) 'Draws the points for the red polygon. points = New PointF() {New PointF(0, 0), _ New PointF(0, 30), _ New PointF(ToSingle(Me.Width / 2.3), 320), _ New PointF(ToSingle(Me.Width / 2), 320), _ New PointF(ToSingle(Me.Width / 2), 295), _ New PointF(35, 0), _ New PointF(0, 0)} 'Fills the red polygon using the points and gradient brush. e.Graphics.FillPolygon(brGradient, points) 'Closes the Gradient brush. brGradient.Dispose() 'Sets the Gradient Brush color for the green polygon. brGradient = New System.Drawing.Drawing2D.LinearGradientBrush(clientRectangle, _ Color.Black, Color.Green, _ System.Drawing.Drawing2D.LinearGradientMode.Horizontal) 'Draws the points for the green polygon. points = New PointF() {New PointF(125, 0), _ New PointF(125, 30), _ New PointF(400, 320), _ New PointF(435, 320), _ New PointF(435, 295), _ New PointF(160, 0), _ New PointF(125, 0)} 'Fills the green polygon using the points and gradient b
-
Okay this looks nasty. Real Nasty. So here's the code. Its supposed to be three parallel color polygons but, it doesn't look like that. This is the first time i'm using the gradient brush so, if any of the experienced Vb programmers could help me make it look neater than what it is, that would be appreciated. Private Sub frmSplash_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'Declares procedure level varaibles. Dim brGradient As System.Drawing.Drawing2D.LinearGradientBrush Dim points() As PointF 'Defines the rectangle. Dim clientRectangle As New System.Drawing.Rectangle(0, 0, _ Me.Width, Me.Height) 'Sets the Gradient Brush color for the red polygon. brGradient = New System.Drawing.Drawing2D.LinearGradientBrush(clientRectangle, _ Color.Black, Color.Red, _ System.Drawing.Drawing2D.LinearGradientMode.Horizontal) 'Draws the points for the red polygon. points = New PointF() {New PointF(0, 0), _ New PointF(0, 30), _ New PointF(ToSingle(Me.Width / 2.3), 320), _ New PointF(ToSingle(Me.Width / 2), 320), _ New PointF(ToSingle(Me.Width / 2), 295), _ New PointF(35, 0), _ New PointF(0, 0)} 'Fills the red polygon using the points and gradient brush. e.Graphics.FillPolygon(brGradient, points) 'Closes the Gradient brush. brGradient.Dispose() 'Sets the Gradient Brush color for the green polygon. brGradient = New System.Drawing.Drawing2D.LinearGradientBrush(clientRectangle, _ Color.Black, Color.Green, _ System.Drawing.Drawing2D.LinearGradientMode.Horizontal) 'Draws the points for the green polygon. points = New PointF() {New PointF(125, 0), _ New PointF(125, 30), _ New PointF(400, 320), _ New PointF(435, 320), _ New PointF(435, 295), _ New PointF(160, 0), _ New PointF(125, 0)} 'Fills the green polygon using the points and gradient b
Replace ToSingle with CSng. You have created polygons. But those polygons don’t look like what you have expected. Try to change x- and y-coordinates of PointFs according to you preference. chatura
-
Replace ToSingle with CSng. You have created polygons. But those polygons don’t look like what you have expected. Try to change x- and y-coordinates of PointFs according to you preference. chatura
What does CSng mean and what does it do? Ty
-
What does CSng mean and what does it do? Ty
converts to single data type chatura