ungerik / go-cairo

Go binding for the cairo graphics library
Other
142 stars 32 forks source link

Add support for linear and radial gradients #19

Closed bit101 closed 6 years ago

bit101 commented 6 years ago

Sample Code:

surface := cairo.NewSurface(cairo.FORMAT_ARGB32, 400, 200)
pattern := cairo.CreateLinearGradient(0, 0, 200, 200)
pattern.AddColorStopRGB(0, 1, 1, 1)
pattern.AddColorStopRGB(1, 0, 0, 0)
surface.SetSource(pattern)
surface.Rectangle(0, 0, 200, 200)
surface.Fill()

pattern = cairo.CreateRadialGradient(300, 100, 0, 300, 100, 100)
pattern.AddColorStopRGB(0, 1, 0, 0)
pattern.AddColorStopRGB(1, 0, 0, 1)
surface.SetSource(pattern)
surface.Rectangle(200, 0, 200, 200)
surface.Fill()
bit101 commented 6 years ago

There are plenty of other useful methods there I'll probably work on later, but this at least lets you create these gradients and render them.

bit101 commented 6 years ago

This project is great, but has not seen much work in the last couple of years. I'm doing a lot of clean up and additions to it in my own fork. I will work off and develop that at github.com/bit101/go-cairo. If you ever want to pull my changes in, just let me know. Thanks for the work you did on this so far!

ungerik commented 6 years ago

Cool. Yeah, didn't use the package myself for some time now.

bit101 commented 6 years ago

Understood. It happens. I'm really appreciating the work you did on it.