path_style.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2017 The oksvg Authors. All rights reserved.
  2. // created: 2/12/2017 by S.R.Wiley
  3. //
  4. // utils.go implements translation of an SVG2.0 path into a rasterx Path.
  5. package oksvg
  6. import (
  7. "image/color"
  8. "github.com/srwiley/rasterx"
  9. )
  10. // PathStyle holds the state of the SVG style.
  11. type PathStyle struct {
  12. FillOpacity, LineOpacity float64
  13. LineWidth, DashOffset, MiterLimit float64
  14. Dash []float64
  15. UseNonZeroWinding bool
  16. fillerColor, linerColor interface{} // either color.Color or rasterx.Gradient
  17. LineGap rasterx.GapFunc
  18. LeadLineCap rasterx.CapFunc // This is used if different than LineCap
  19. LineCap rasterx.CapFunc
  20. LineJoin rasterx.JoinMode
  21. mAdder rasterx.MatrixAdder // current transform
  22. }
  23. // styleAttribute describes draw options, such as {"fill":"black"; "stroke":"white"}.
  24. type styleAttribute = map[string]string
  25. // DefaultStyle sets the default PathStyle to fill black, winding rule,
  26. // full opacity, no stroke, ButtCap line end and Bevel line connect.
  27. var DefaultStyle = PathStyle{1.0, 1.0, 2.0, 0.0, 4.0, nil, true,
  28. color.NRGBA{0x00, 0x00, 0x00, 0xff}, nil,
  29. nil, nil, rasterx.ButtCap, rasterx.Bevel, rasterx.MatrixAdder{M: rasterx.Identity}}