Results 1 to 40 of 44

Thread: [RESOLVED] picturebox upsidedown-gradient

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: [RESOLVED] picturebox upsidedown-gradient

    FWIW, here's Code which renders a "seamless RainBow-Pattern" with the help of the VB6-CairoWrapper (available on vbRichClient.com):

    Code:
    Option Explicit
    
    Private Sub Form_Resize()
      RenderToFormOrPicBox Me, Array(vbRed, vbYellow, vbGreen, vbCyan, vbBlue, vbMagenta, vbRed)
    End Sub
    
    Private Sub RenderToFormOrPicBox(Canvas, ColorStops)
      Canvas.ScaleMode = vbPixels
      
      Dim CC As cCairoContext, Pat As cCairoPattern, i As Long
      Set CC = Cairo.CreateSurface(Canvas.ScaleWidth, Canvas.ScaleHeight).CreateContext
      
      Set Pat = Cairo.CreateLinearPattern(0, 0, CC.Surface.Width, 0) 
      For i = 0 To UBound(ColorStops) 'add the Color-Stops for this gradient-pattern
          Pat.AddColorStop i / UBound(ColorStops), ColorStops(i)
      Next
      CC.Paint 1, Pat 'now render the gradient-pattern via the CairoContext
      
      Set Canvas.Picture = CC.Surface.Picture
    End Sub
    HTH

    Olaf
    Last edited by Schmidt; Aug 19th, 2021 at 02:02 PM.

  2. #2
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    238

    Re: [RESOLVED] picturebox upsidedown-gradient

    Quote Originally Posted by Schmidt View Post
    FWIW, here's Code which renders a "seamless RainBow-Pattern" with the help of the VB6-CairoWrapper (available on vbRichClient.com):

    Code:
    Option Explicit
    
    Private Sub Form_Resize()
      RenderToFormOrPicBox Me, Array(vbRed, vbYellow, vbGreen, vbCyan, vbBlue, vbMagenta, vbRed)
    End Sub
    
    Private Sub RenderToFormOrPicBox(Canvas, ColorStops)
      Canvas.ScaleMode = vbPixels
      
      Dim CC As cCairoContext, Pat As cCairoPattern, i As Long
      Set CC = Cairo.CreateSurface(Canvas.ScaleWidth, Canvas.ScaleHeight).CreateContext
      
      Set Pat = Cairo.CreateLinearPattern(0, 0, CC.Surface.Width, 0) 
      For i = 0 To UBound(ColorStops) 'add the Color-Stops for this gradient-pattern
          Pat.AddColorStop i / UBound(ColorStops), ColorStops(i)
      Next
      CC.Paint 1, Pat 'now render the gradient-pattern via the CairoContext
      
      Set Canvas.Picture = CC.Surface.Picture
    End Sub
    HTH

    Olaf
    Professional and sophisticated indeed. Great! I know about this superb work (RichClient) of yours since many years but somehow not able to get the opportunity to utilize your grand work in my programs. Many others must be using it and getting benefited of course. Thanks a TON for the same.

    Kind Regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width