Beispiel #1
0
// usage creates any necessary tags for actually using the service in the SVG.
func (s *service) usage(canvas *svg.SVG, iconIds map[string]string) {
	canvas.Use(
		s.point.X,
		s.point.Y,
		"#serviceBlock",
		fmt.Sprintf(`id=%q`, s.name))
	if len(s.iconSrc) > 0 {
		canvas.Use(
			s.point.X+serviceBlockSize/2-iconSize/2,
			s.point.Y+serviceBlockSize/2-iconSize/2,
			"#"+iconIds[s.charmPath],
			fmt.Sprintf(`width="%d" height="%d"`, iconSize, iconSize),
		)
	} else {
		canvas.Image(
			s.point.X+serviceBlockSize/2-iconSize/2,
			s.point.Y+serviceBlockSize/2-iconSize/2,
			iconSize,
			iconSize,
			s.iconUrl,
		)
	}
	canvas.Textlines(
		s.point.X+serviceBlockSize/2,
		s.point.Y+serviceBlockSize/6,
		[]string{s.name},
		serviceBlockSize/10,
		0,
		"#505050",
		"middle")
}
Beispiel #2
0
// usage creates any necessary tags for actually using the relation in the SVG.
func (r *serviceRelation) usage(canvas *svg.SVG) {
	l := r.shortestRelation()
	canvas.Line(
		l.p0.X,
		l.p0.Y,
		l.p1.X,
		l.p1.Y,
		fmt.Sprintf(`stroke=%q`, relationColor),
		fmt.Sprintf(`stroke-width="%dpx"`, relationLineWidth),
		fmt.Sprintf(`stroke-dasharray=%q`, strokeDashArray(l)),
	)
	mid := l.p0.Add(l.p1).Div(2).Sub(point(healthCircleRadius, healthCircleRadius))
	canvas.Use(mid.X, mid.Y, "#healthCircle")
}