Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Gradient Brush

Gradient Brush

Scheduled Pinned Locked Moved Visual Basic
graphicshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tyrone_whitey
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • T Tyrone_whitey

      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

      C Offline
      C Offline
      Chatura Dilan
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • C Chatura Dilan

        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

        T Offline
        T Offline
        Tyrone_whitey
        wrote on last edited by
        #3

        What does CSng mean and what does it do? Ty

        C 1 Reply Last reply
        0
        • T Tyrone_whitey

          What does CSng mean and what does it do? Ty

          C Offline
          C Offline
          Chatura Dilan
          wrote on last edited by
          #4

          converts to single data type chatura

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups