newsvg 511 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. if test $# -lt 1
  3. then
  4. echo "specify a file"
  5. exit 2
  6. fi
  7. if test ! -f $1
  8. then
  9. cat <<! > $1
  10. package main
  11. import (
  12. "github.com/ajstarks/svgo"
  13. "os"
  14. )
  15. var (
  16. width = 500
  17. height = 500
  18. canvas = svg.New(os.Stdout)
  19. )
  20. func background(v int) { canvas.Rect(0, 0, width, height, canvas.RGB(v, v, v)) }
  21. func main() {
  22. canvas.Start(width, height)
  23. background(255)
  24. // your code here
  25. canvas.Grid(0, 0, width, height, 10, "stroke:black;opacity:0.1")
  26. canvas.End()
  27. }
  28. !
  29. fi
  30. $EDITOR $1