Skip to content

Instantly share code, notes, and snippets.

@tariq1890
Created August 27, 2017 01:14
Show Gist options
  • Save tariq1890/baf0f0a754ad7de611d91b937ae6d28a to your computer and use it in GitHub Desktop.
Save tariq1890/baf0f0a754ad7de611d91b937ae6d28a to your computer and use it in GitHub Desktop.
Create a Linear Gradient with SVGO
package main
import (
"bufio"
"github.com/ajstarks/svgo"
"os"
)
func main() {
width := 1920
height := 1080
lg := []svg.Offcolor{
{0, "rgb(0,0,0)", 200},
{1, "rgb(0,0,0)", 128},
}
_ = []svg.Offcolor{
{10, "#00cc00", 1},
{30, "#006600", 1},
{70, "#cc0000", 1},
{90, "#000099", 1}}
f, _ := os.Create("lgrad.svg")
w := bufio.NewWriter(f)
g := svg.New(w)
g.Start(width, height)
g.Rect(0, 0, width, height, "fill:white")
g.Title("Gradients")
g.Def()
g.LinearGradient("h", 0, 100, 0, 0, lg)
g.DefEnd()
g.End()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment