MCPcopy
hub / github.com/tdewolff/canvas / init

Method init

svg.go:102–115  ·  view source on GitHub ↗
(width, height float64, viewbox [4]float64)

Source from the content-addressed store, hash-verified

100}
101
102func (svg *svgParser) init(width, height float64, viewbox [4]float64) {
103 svg.width, svg.height = width*96.0/25.4, height*96.0/25.4
104 svg.diagonal = math.Sqrt((svg.width*svg.width + svg.height*svg.height) / 2.0)
105
106 svg.c = New(width, height)
107 svg.ctx = NewContext(svg.c)
108 svg.ctx.SetCoordSystem(CartesianIV)
109 if 0.0 < viewbox[2] && 0.0 < viewbox[3] {
110 m := Identity.Scale(width/viewbox[2], height/viewbox[3]).Translate(-viewbox[0], -viewbox[1])
111 svg.ctx.SetView(m)
112 }
113 svg.ctx.SetStrokeJoiner(MiterJoiner{BevelJoin, svgDefaultState.strokeMiterLimit})
114 svg.state = svgDefaultState
115}
116
117func (svg *svgParser) push(tag string, attrs map[string]string) {
118 svg.ctx.Push()

Callers 2

parseDefsMethod · 0.95
ParseSVGFunction · 0.95

Calls 7

NewContextFunction · 0.85
SetCoordSystemMethod · 0.80
SetViewMethod · 0.80
SetStrokeJoinerMethod · 0.80
NewFunction · 0.70
TranslateMethod · 0.45
ScaleMethod · 0.45

Tested by

no test coverage detected