|
-
Aug 21st, 2021, 03:15 AM
#27
Re: [RESOLVED] picturebox upsidedown-gradient
For completeness, to allow an influencing of the Angle of the Gradient-Vector -
the routine I've posted in #18, would need to be changed to:
Code:
Private Sub RenderToFormOrPicBox(Canvas, AngDeg0to90, 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, Cos(AngDeg0to90 / 180 * Cairo.PI) * CC.Surface.Width, _
Sin(AngDeg0to90 / 180 * Cairo.PI) * CC.Surface.Height)
For i = 0 To UBound(ColorStops) 'now 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
I've colored the changes in Blue.
Usage then:
RenderToFormOrPicBox Me, 0, Array(vbCyan, vbBlue) 'horizontal
RenderToFormOrPicBox Me, 90, Array(vbCyan, vbBlue) 'vertical
RenderToFormOrPicBox Me, 45, Array(vbCyan, vbBlue) 'angled
HTH
Olaf
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
|