Esempio n. 1
0
func (ts *TextSymbolizer) Draw(gc draw2d.GraphicContext, shape geom.Shape) {
	if !ts.Applies(shape) {
		return
	}
	if name := shape.Attribute(ts.s.Attr); name != "" {
		gc.SetFontSize(ts.s.Size)
		l, t, r, b := gc.GetStringBounds(name)
		bb := shape.Bbox()
		dx := math.Abs(bb[2] - bb[0])
		dy := math.Abs(bb[3] - bb[1])
		ox, oy := dx/2, dy/2

		x, y := ts.r.matrix.TransformPoint(bb[0]+ox, bb[1]-oy)
		gc.SetFillColor(ts.s.Fill)
		gc.FillStringAt(name, x-(r-l)/2, y-(t-b)/2)
	}
}