Skip to content

Instantly share code, notes, and snippets.

@tariq1890
Created August 27, 2017 01:14
Show Gist options
  • Select an option

  • Save tariq1890/baf0f0a754ad7de611d91b937ae6d28a to your computer and use it in GitHub Desktop.

Select an option

Save tariq1890/baf0f0a754ad7de611d91b937ae6d28a to your computer and use it in GitHub Desktop.

Revisions

  1. tariq1890 created this gist Aug 27, 2017.
    35 changes: 35 additions & 0 deletions lgrad.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    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()
    }