Esempio n. 1
0
// addOffsetPosition add text-dx/dy offsets
// set POSITION so that the offsets are from the outer bounds of the
// label. e.g. dx=10 moves the left bound of the label 10 pixels to the right
func addOffsetPosition(style *Block, properties *mss.Properties) {
	dx, _ := properties.GetFloat("text-dx")
	dy, _ := properties.GetFloat("text-dy")

	dy = -dy

	var position string
	if dy < 0 {
		dy = -dy
		position += "l"
	} else if dy > 0 {
		position += "u"
	} else {
		position += "c"
	}
	if dx < 0 {
		dx = -dx
		position += "l"
	} else if dx > 0 {
		position += "r"
	} else {
		position += "c"
	}

	if dx != 0 || dy != 0 {
		style.Add("OFFSET", fmt.Sprintf("%.0f %.0f", dx, dy))
	}
	style.Add("Position", position)
}
Esempio n. 2
0
func fmtFloatProp(p *mss.Properties, name string, scale float64) *string {
	v, ok := p.GetFloat(name)
	if !ok {
		return nil
	}
	r := strconv.FormatFloat(v*scale, 'f', -1, 64)
	return &r
}