Ejemplo n.º 1
0
func (ig *ImageGraphics) setStyle(style chart.Style) {
	ig.gc.SetStrokeColor(chart.Color2RGBA(style.LineColor, 0xff))
	ig.gc.SetLineWidth(float64(style.LineWidth))
	orig := dashPattern[style.LineStyle]
	pattern := make([]float64, len(orig))
	copy(pattern, orig)
	for i := range pattern {
		pattern[i] *= math.Sqrt(float64(style.LineWidth))
	}
	ig.gc.SetLineDash(pattern, 0)
}
Ejemplo n.º 2
0
func (ig *ImageGraphics) Rect(x, y, w, h int, style chart.Style) {
	ig.setStyle(style)
	stroke := func() { ig.gc.Stroke() }
	if style.FillColor != "" {
		ig.gc.SetFillColor(chart.Color2RGBA(style.FillColor, 0x0ff /*uint8(style.Alpha*255)*/))
		stroke = func() { ig.gc.FillStroke() }
	}
	ig.gc.MoveTo(float64(x), float64(y))
	ig.gc.LineTo(float64(x+w), float64(y))
	ig.gc.LineTo(float64(x+w), float64(y+h))
	ig.gc.LineTo(float64(x), float64(y+h))
	ig.gc.LineTo(float64(x), float64(y))
	stroke()
}
Ejemplo n.º 3
0
func (ig *ImageGraphics) Wedge(ix, iy, iro, iri int, phi, psi float64, style chart.Style) {
	ig.setStyle(style)
	stroke := func() { ig.gc.Stroke() }
	if style.FillColor != "" {
		ig.gc.SetFillColor(chart.Color2RGBA(style.FillColor, 0x0ff /*uint8(style.Alpha*255)*/))
		stroke = func() { ig.gc.FillStroke() }
	}

	iri = 0
	ecc := 1.0                           // eccentricity
	x, y := float64(ix), float64(iy)     // center as float
	ro, ri := float64(iro), float64(iri) // radius outer and inner as float
	roe, rie := ro*ecc, ri*ecc           // inner and outer radius corrected by ecc

	xao, yao := math.Cos(phi)*roe+x, y+math.Sin(phi)*ro
	// xco, yco := math.Cos(psi)*roe+x, y-math.Sin(psi)*ro
	xai, yai := math.Cos(phi)*rie+x, y+math.Sin(phi)*ri
	xci, yci := math.Cos(psi)*rie+x, y+math.Sin(psi)*ri

	// outbound straight line
	if ri > 0 {
		ig.gc.MoveTo(xai, yai)
	} else {
		ig.gc.MoveTo(x, y)
	}
	ig.gc.LineTo(xao, yao)

	// outer arc
	ig.gc.ArcTo(x, y, ro, roe, phi, psi-phi)

	// inbound straight line
	if ri > 0 {
		ig.gc.LineTo(xci, yci)
		ig.gc.ArcTo(x, y, ri, rie, psi, phi-psi)
	} else {
		ig.gc.LineTo(x, y)
	}
	stroke()
}
Ejemplo n.º 4
0
func (ig *ImageGraphics) setStyle(style chart.Style) {
	ig.gc.SetStrokeColor(chart.Color2RGBA(style.LineColor, 0xff))
	ig.gc.SetLineWidth(float64(style.LineWidth))
	ig.gc.SetLineDash(dashPattern[style.LineStyle], 0)
}