add Deleter and DrawDeleter interfaces

This commit is contained in:
faiface 2016-12-03 16:33:56 +01:00
parent d16037c983
commit 42d573372e
1 changed files with 19 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import (
// Drawer is anything that can be drawn. It's by no means a drawer inside your table.
//
// Drawer consists of a single method: Draw. Draw methods takes any number of Transform arguments. It applies these
// Drawer consists of a single methods: Draw. Draw methods takes any number of Transform arguments. It applies these
// transforms in the reverse order and finally draws something transformed by these transforms.
//
// Example:
@ -23,6 +23,19 @@ type Drawer interface {
Draw(t ...Transform)
}
// Deleter is anything that can be deleted. All graphics objects that have some associated video memory
// are deleters. It is necessary to call Delete when you're done with an object, otherwise you're going
// to have video memory leaks.
type Deleter interface {
Delete()
}
// DrawDeleter combines Drawer and Deleter interfaces.
type DrawDeleter interface {
Drawer
Deleter
}
// PolygonColor is a polygon shape filled with a single color.
type PolygonColor struct {
parent pixelgl.Doer
@ -108,3 +121,8 @@ func (pc *PolygonColor) Draw(t ...Transform) {
pc.va.Draw()
}
// Delete destroys a polygon shape and releases it's video memory. Do not use this shape after calling Delete.
func (pc *PolygonColor) Delete() {
pc.va.Delete()
}