MCPcopy
hub / github.com/fogleman/primitive / Rasterize

Method Rasterize

primitive/ellipse.go:154–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152}
153
154func (c *RotatedEllipse) Rasterize() []Scanline {
155 var path raster.Path
156 const n = 16
157 for i := 0; i < n; i++ {
158 p1 := float64(i+0) / n
159 p2 := float64(i+1) / n
160 a1 := p1 * 2 * math.Pi
161 a2 := p2 * 2 * math.Pi
162 x0 := c.Rx * math.Cos(a1)
163 y0 := c.Ry * math.Sin(a1)
164 x1 := c.Rx * math.Cos(a1+(a2-a1)/2)
165 y1 := c.Ry * math.Sin(a1+(a2-a1)/2)
166 x2 := c.Rx * math.Cos(a2)
167 y2 := c.Ry * math.Sin(a2)
168 cx := 2*x1 - x0/2 - x2/2
169 cy := 2*y1 - y0/2 - y2/2
170 x0, y0 = rotate(x0, y0, radians(c.Angle))
171 cx, cy = rotate(cx, cy, radians(c.Angle))
172 x2, y2 = rotate(x2, y2, radians(c.Angle))
173 if i == 0 {
174 path.Start(fixp(x0+c.X, y0+c.Y))
175 }
176 path.Add2(fixp(cx+c.X, cy+c.Y), fixp(x2+c.X, y2+c.Y))
177 }
178 return fillPath(c.Worker, path)
179}

Callers

nothing calls this directly

Calls 4

rotateFunction · 0.85
radiansFunction · 0.85
fixpFunction · 0.85
fillPathFunction · 0.85

Tested by

no test coverage detected