gogol

package module
v0.0.0-...-c134eb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2012 License: MIT Imports: 3 Imported by: 0

README


  GOGOL


    a bitmap drawing & animation library for Go.


. synopsis

    gogol's purpose is to provide a simple interface
    for drawing bitmap graphics on the screen, as well
    as handling mouse & keyboard events.

    gogol is especially well suited for building 2D
    games.

. installation

    go get github.com/cloudhead/gogol

. documentation

    go doc gogol

. examples

    see /examples folder

. license

    see LICENSE

. copyright

    Alexis Sellier <alexis@cloudhead.io>

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

View Source
const (
	MouseL Mouse = 0
	MouseM       = 1
	MouseR       = 2
)
View Source
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 FullScreen

func FullScreen()

FullScreen enables full-screen mode.

func HideCursor

func HideCursor()

HideCursor hides the mouse cursor.

func Init

func Init(h Handler)

Init initializes the engine and creates a window with the specified title.

func NewClip

func NewClip(img *image.Image, x, y, w, h int) *image.Clip

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.

func NewImage

func NewImage(path string) *image.Image

NewImage creates a *image.Image from the specified path.

func NewSprite

func NewSprite(img *image.Image, w, h int) *image.Sprite

NewSprite creates a *image.Sprite from the given *image.Image. w and h specify the width and height of the clips.

func Scale

func Scale(x, y float32)

Scale scales the view by x and y.

func ShowCursor

func ShowCursor()

ShowCursor shows the mouse cursor.

func Translate

func Translate(x, y float32)

Translate moves the drawing position to the specified coordinates. Subsequent drawing operations will be relative to these coordinates.

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) Mouse

func (d *DefaultHandler) Mouse(b Mouse, isDown bool, 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
}

type Key

type Key uint

type Mouse

type Mouse int

Mouse can be either MouseL, MouseR or MouseR.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL