|
-
Aug 19th, 2021, 11:08 AM
#1
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.
-
Aug 20th, 2021, 03:43 AM
#2
Addicted Member
Re: [RESOLVED] picturebox upsidedown-gradient
 Originally Posted by Schmidt
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|