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. Help me How Exacrly i can use the pathGradiant brush

Help me How Exacrly i can use the pathGradiant brush

Scheduled Pinned Locked Moved Visual Basic
comhelp
4 Posts 3 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.
  • E Offline
    E Offline
    EmanAli
    wrote on last edited by
    #1

    Hi please Tell me the code about how exactly i used the pathgradiant brush to draw a sphere Thanks. Eman Ali Moughal Senior Software Engineer Soon Soft (pvt) Ltd www.soonsoft.com

    C 1 Reply Last reply
    0
    • E EmanAli

      Hi please Tell me the code about how exactly i used the pathgradiant brush to draw a sphere Thanks. Eman Ali Moughal Senior Software Engineer Soon Soft (pvt) Ltd www.soonsoft.com

      C Offline
      C Offline
      cnurse
      wrote on last edited by
      #2

      Eman, I just hacked this code out of my own C# project, hoping thatit will be of use to you. It may help clarify a few quirky things about PathGradientBrush. I think, by altering the focus parameter of SetTriangle... or SetSigma... in the code below, that you may be able to present a highlite at a position in a circle which approximates the look of a sphere. I honestly dont think you will get anything high quality though without breaking the sphere into triangles and shading each one appropriately, and that's way beyond me. Another kludge you might use is to take a bitmap of a sphere, drawn in a 3D package or using Photopaint etc., and scaling it. Well, for what its worth, here is my code, you will have to hack out my variables and try follow what's going on quite closely. This method returns a brush that you can use on Graphics.FillPath. prPath is a GraphicsPath prFlip just flips a start and end color around prBrushType is my enumeration which controls whether blends or triangle or bell type fills public PathGradientBrush CreatePathBrush(GraphicsPath prPath) { Color lStart, lEnd; // Start and end color PathGradientBrush lBrush; // Brush to assign to lStart = Your Start Color; lEnd = Your End Color; // Create the linear brush lBrush = new PathGradientBrush(prPath); lBrush.CenterColor = lEnd; // Create an array of colors which are the end color at each point Color []lColors = new Color[prPath.PointCount]; for(int lCount = 0 ; lCount < prPath.PointCount ; lCount ++) { lColors[lCount] = lStart; } lBrush.SurroundColors = lColors; // Experiment with the 0.5F figure, it should change the highlight on the shape you fill // Of course you will want to fill a circle or ellipse would be better still. lBrush.SetSigmaBellShape(0.5F); return lBrush; } --------------- Hope this makes some kind of sense to you. Nursey

      A 1 Reply Last reply
      0
      • C cnurse

        Eman, I just hacked this code out of my own C# project, hoping thatit will be of use to you. It may help clarify a few quirky things about PathGradientBrush. I think, by altering the focus parameter of SetTriangle... or SetSigma... in the code below, that you may be able to present a highlite at a position in a circle which approximates the look of a sphere. I honestly dont think you will get anything high quality though without breaking the sphere into triangles and shading each one appropriately, and that's way beyond me. Another kludge you might use is to take a bitmap of a sphere, drawn in a 3D package or using Photopaint etc., and scaling it. Well, for what its worth, here is my code, you will have to hack out my variables and try follow what's going on quite closely. This method returns a brush that you can use on Graphics.FillPath. prPath is a GraphicsPath prFlip just flips a start and end color around prBrushType is my enumeration which controls whether blends or triangle or bell type fills public PathGradientBrush CreatePathBrush(GraphicsPath prPath) { Color lStart, lEnd; // Start and end color PathGradientBrush lBrush; // Brush to assign to lStart = Your Start Color; lEnd = Your End Color; // Create the linear brush lBrush = new PathGradientBrush(prPath); lBrush.CenterColor = lEnd; // Create an array of colors which are the end color at each point Color []lColors = new Color[prPath.PointCount]; for(int lCount = 0 ; lCount < prPath.PointCount ; lCount ++) { lColors[lCount] = lStart; } lBrush.SurroundColors = lColors; // Experiment with the 0.5F figure, it should change the highlight on the shape you fill // Of course you will want to fill a circle or ellipse would be better still. lBrush.SetSigmaBellShape(0.5F); return lBrush; } --------------- Hope this makes some kind of sense to you. Nursey

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Hi cnurse thanks for the help buddy. i have now my concept bcome bit improve about the path gradiant brush. Thanks for your help.

        C 1 Reply Last reply
        0
        • A Anonymous

          Hi cnurse thanks for the help buddy. i have now my concept bcome bit improve about the path gradiant brush. Thanks for your help.

          C Offline
          C Offline
          cnurse
          wrote on last edited by
          #4

          You're very welcome. I'm glad I can offer back to a system I have gained so much from. By the way. Watch out for my Theme system which will be released in the next few weeks. It lets you edit and manage gradients and will show you lots of ways to use them. Regards, Nursey

          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