Beispiel #1
0
// Update updates the string drawn by this drawable.
func (t *Text) Update(val string) {
	if t.value == val {
		return
	}
	t.value = val
	t.Width = render.SizeOfString(val)
	t.dirty = true
}
Beispiel #2
0
// NewText creates a new Text drawable.
func NewText(val string, x, y float64, r, g, b int) *Text {
	return &Text{
		value: val,
		Width: render.SizeOfString(val),
		r:     r, g: g, b: b, a: 255,
		x: x, y: y,
		scaleX: 1, scaleY: 1,
		baseElement: baseElement{
			visible: true,
			isNew:   true,
		},
	}
}
Beispiel #3
0
func createNameTag(name string) (verts []*render.StaticVertex) {
	width := render.SizeOfString(name) + 4
	offset := -(width/2)*0.01 + (2 * 0.01)
	for _, r := range name {
		tex := render.CharacterTexture(r)
		if tex == nil {
			continue
		}
		s := render.SizeOfCharacter(r)
		for _, v := range faceVertices[direction.North].verts {
			vert := &render.StaticVertex{
				X:        float32(v.X)*float32(s*0.01) - float32(offset+s*0.01) - 0.01,
				Y:        float32(v.Y)*0.16 - 0.08 - 0.01,
				Z:        0.05,
				Texture:  tex,
				TextureX: float64(v.TOffsetX),
				TextureY: float64(v.TOffsetY),
				R:        64,
				G:        64,
				B:        64,
				A:        255,
			}
			verts = append(verts, vert)
		}
		for _, v := range faceVertices[direction.North].verts {
			vert := &render.StaticVertex{
				X:        float32(v.X)*float32(s*0.01) - float32(offset+s*0.01),
				Y:        float32(v.Y)*0.16 - 0.08,
				Z:        0,
				Texture:  tex,
				TextureX: float64(v.TOffsetX),
				TextureY: float64(v.TOffsetY),
				R:        255,
				G:        255,
				B:        255,
				A:        255,
			}
			verts = append(verts, vert)
		}
		offset += (s + 2) * 0.01
	}
	return verts
}