![]() Well, I'm here - so just ask questions about the cairo-code-snippets I'm posting, when you "got lost" on a certain line of cairo-drawing-code.Do you love to create colorful artwork but find it difficult to decide which colors to use? Well, with the help of the Color Wheel Spinner, you can easily pick any color from the rainbow! Just spin the wheel and select which color you want to use. Though I'm absolutely convinced, that - if the community would invest only "half the amount of time" into "learning the cairo-lib" (instead of investing that time into GDI/GDIPlus), a whole lot of "graphics-threads" in this forum would be much shorter. Without (at least a rough) understanding what a Cairo-Pattern is (and does) - and without understanding how the so called "transforms" work (all those "translates, scales, rotates" which can be applied to "coordsys-matrices" on a cairo-surface-context, but also within a used cairo-patterns independently of the context this pattern is used on), one cannot write really efficient "cairo-code" for the more challenging scenarios. On - as well as on other cairo-related websites - you'll find a lot of tutorials and "best-practice"-hints, how to achieve certain effects with that library. Set Pat.Matrix = (1, 0) 'shift the CoordSys in the Linear-PatternObj one step to the rightĮnd FunctionHere's hope, that the extensive comments help understanding this stuff a bit more. RotateDrawingsDeg 360 / Steps 'increase the rotation-angle on the Context-CoordSys for our next line-drawing Stroke 0, Pat ' <- Stroke the line with the current Gradient-Pattern-Color (at the current Pattern-Coord-Pos) 'this prepares the two Coord-Systems for the next round of our loop. TranslateDrawings Size / 2, Size / 2 'shift the Contexts Coord-Sys into the center of the Srfįor i = 1 To Steps 'now we "walk the outer ring" (rotating a little bit after each step) SetLineWidth 1.8 'oversize the drawn lines for a little bit of overlap (0.9px to the left and right) SetLineCap CAIRO_LINE_CAP_ROUND 'for softer "overlapped-blending" at the line-"corner"-endpoints With CreateRingSrf.CreateContext 'now we can enter drawing-mode on the Srf-Context Set CreateRingSrf = Cairo.CreateSurface(Size, Size) 'create the return-value of this function Pat.AddColorStop i / UBound(ColorStops), ColorStops(i) Set Pat = Cairo.CreateLinearPattern(0, 0, Steps, 0)įor i = 0 To UBound(ColorStops) 'now add the Color-Stops for this gradient-pattern (to interpolate between) ![]() Steps = 2 * Cairo.PI * RadiusOuter 'calculate the amount of pixel-steps on the outer radius (2*PI*r) 'create a linear (horizontal) gradient-pattern that matches the amount of "unrolled outer-ring-pixel-steps" Set Picture = CreateRingSrf(200, 50, 100, ColorStops).Pictureįunction CreateRingSrf(Size, RadiusInner, RadiusOuter, ColorStops) As cCairoSurfaceĭim Steps As Long, Pat As cCairoPattern, i As Long I've already studied the code of you, Olaf and ColinE66, but I still can't draw a smooth Color Wheel with Cairo, which makes me very depressed.ĭrawing algorithms always make me a headache.ĭim ColorStops 'define the Colors the "Conical-Gradient will span and interpolate-between"ĬolorStops = Array(vbRed, vbYellow, vbGreen, vbCyan, vbBlue, vbMagenta, vbRed) But I don't know why, I can't understand Cairo. Cairo can always achieve very cool effects. RotateDrawingsDeg 0.25 'rotate by one quarter of a degree (360 / (1440 steps in the LUT))Įnd FunctionHi reexre, thank you for your reply. With CreateRingSpectrumSurface.CreateContext ![]() Set CreateRingSpectrumSurface = Cairo.CreateSurface(Size, Size) Set Lst = New_c.ArrayList(vbLong, vbRed, vbYellow, vbGreen, vbCyan, vbBlue, vbMagenta, vbRed) ![]() With Cairo.CreateLinearPattern(0, 0, LUTSrf.Width - 1, 0) Private Sub W_Paint(CC As cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)ĭrawBorderAndBackGround CC, dx_Aligned, dy_AlignedĬC.Arc xCenter, 圜enter, 0.4 * RingRadius 'the centered Circle-Fill with the current colorĬC.ColorSplit ColorLut(CurRingIdx), RR, GG, BB Code: Option Explicit 'a circular ColorChooser (implemented as an RC5 cwWidget-Class)Ĭonst RingSurfaceSize& = 384, RingWidth& = 42 ' 1 Then Exit SubĬurRingIdx = (Cairo.CalcArc(圜enter - Y, xCenter - X) * 720 / Cairo.PI + 1080) Mod 1440ĬurLUM = Sqr((xCenter - X) * (xCenter - X) + (圜enter - Y) * (圜enter - Y))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |