Results 1 to 40 of 44

Thread: [RESOLVED] picturebox upsidedown-gradient

Threaded View

  1. #15
    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.

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