Documentation ¶
Overview ¶
Package gogol provides an abstract interface over bitmap graphic rendering and animation.
Create an empty event handler and initialize gogol with it:
handler := gogol.DefaultHandler{} gogol.Init(handler)
Create an animation from a sprite, and draw the current frame:
sprite := gogol.NewImage("goblin.bmp").Sprite(16, 16) animation := sprite.Sequence(0, -1) ... animation.DrawFrameAt(0, 0)
Index ¶
- Constants
- func AdjustExp(exp, max float32)
- func AdjustHSL(h, s, l float32)
- func FullScreen()
- func HideCursor()
- func Init(h Handler)
- func NewClip(img *image.Image, x, y, w, h int) *image.Clip
- func NewImage(path string) *image.Image
- func NewSprite(img *image.Image, w, h int) *image.Sprite
- func Scale(x, y float32)
- func ShowCursor()
- func Translate(x, y float32)
- type DefaultHandler
- func (d *DefaultHandler) Display(delta time.Duration)
- func (d *DefaultHandler) DisplayPost()
- func (d *DefaultHandler) Entry(e bool)
- func (d *DefaultHandler) Keyboard(key Key, isDown bool)
- func (d *DefaultHandler) Motion(x, y int)
- func (d *DefaultHandler) Mouse(b Mouse, isDown bool, x, y int)
- func (d *DefaultHandler) Ready()
- func (d *DefaultHandler) Reshape(w, h int)
- func (d *DefaultHandler) Title() string
- type Handler
- type Key
- type Mouse
Constants ¶
const ( MouseL Mouse = 0 MouseM = 1 MouseR = 2 )
const ( KeyBackspace Key = keyChar | 8 KeyTab = keyChar | 9 KeyReturn = keyChar | 13 KeyEsc = keyChar | 27 KeySpace = keyChar | 32 KeyLeft = keySpecial | C.GLUT_KEY_LEFT KeyUp = keySpecial | C.GLUT_KEY_UP KeyRight = keySpecial | C.GLUT_KEY_RIGHT KeyDown = keySpecial | C.GLUT_KEY_DOWN KeyShiftL = keySpecial | 112 KeyShiftR = keySpecial | 113 KeyCtrlL = keySpecial | 114 KeyCtrlR = keySpecial | 115 KeyAltL = keySpecial | 116 KeyAltR = keySpecial | 117 KeyF1 = keySpecial | C.GLUT_KEY_F1 KeyF2 = keySpecial | C.GLUT_KEY_F2 KeyF3 = keySpecial | C.GLUT_KEY_F3 KeyF4 = keySpecial | C.GLUT_KEY_F4 KeyF5 = keySpecial | C.GLUT_KEY_F5 KeyF6 = keySpecial | C.GLUT_KEY_F6 KeyF7 = keySpecial | C.GLUT_KEY_F7 KeyF8 = keySpecial | C.GLUT_KEY_F8 KeyF9 = keySpecial | C.GLUT_KEY_F9 KeyF10 = keySpecial | C.GLUT_KEY_F10 KeyF11 = keySpecial | C.GLUT_KEY_F11 KeyF12 = keySpecial | C.GLUT_KEY_F12 )
Variables ¶
This section is empty.
Functions ¶
func AdjustExp ¶
func AdjustExp(exp, max float32)
AdjustExp adjusts the scene's exposure. The first parameter specifies the exposure (default is 1.0), the second specifies the maximum brightness.
func AdjustHSL ¶
func AdjustHSL(h, s, l float32)
AdjustHSL adjusts the scene's hue, saturation & lightness. Values can range between 0 and 1.
func Init ¶
func Init(h Handler)
Init initializes the engine and creates a window with the specified title.
func NewClip ¶
NewClip creates a *image.Clip from the given *image.Image. x and y specify the top-left corner on the image, w and h specify the width and height.
Types ¶
type DefaultHandler ¶
type DefaultHandler struct {
WindowTitle string
}
DefaultHandler implements Handler
func (*DefaultHandler) Display ¶
func (d *DefaultHandler) Display(delta time.Duration)
func (*DefaultHandler) DisplayPost ¶
func (d *DefaultHandler) DisplayPost()
func (*DefaultHandler) Entry ¶
func (d *DefaultHandler) Entry(e bool)
func (*DefaultHandler) Keyboard ¶
func (d *DefaultHandler) Keyboard(key Key, isDown bool)
func (*DefaultHandler) Motion ¶
func (d *DefaultHandler) Motion(x, y int)
func (*DefaultHandler) Ready ¶
func (d *DefaultHandler) Ready()
func (*DefaultHandler) Reshape ¶
func (d *DefaultHandler) Reshape(w, h int)
func (*DefaultHandler) Title ¶
func (d *DefaultHandler) Title() string
type Handler ¶
type Handler interface { // Ready is called once, after the window is created, // but before anything is drawn to the screen. Ready() // Reshape is called every time the window is resized. // The new width and height are passed as arguments. Reshape(w, h int) // Display is called on every frame, right before the // view is re-drawn. The time delta since the last frame // is passed as an argument. // // This is the recommend place to perform all drawing // operations. Display(delta time.Duration) // DisplayPost is called on every frame, after Display, // and after any post-processing effects have been applied. // This function is useful for drawing UI elements which // shouldn't be affected by image filters. DisplayPost() // Keyboard is called whenever a key is pressed or released. // The key is passed as an argument, as well as the state // of t Keyboard(k Key, isDown bool) // Mouse is called whenever the mouse is clicked. Mouse(button Mouse, isDown bool, x, y int) // Motion is called whenever the mouse is moved, with the x // and y position of the cursor. Motion(x, y int) // Entry is called when the mouse enters or exits the window. // true is passed if the mouse is entering, false is passed // if it is exiting. Entry(isEnter bool) // Title is called to set the title of the window. Title() string }