Version: v0.0.0-...-b5aa40e Latest Latest

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

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 27 Imported by: 0




View Source
const (
	ROTATE mouseMode = iota

control mode constant

View Source
const (

Point Location Mode Const


This section is empty.


func AddCommands

func AddCommands()

AddCommands opens up some command line functions to the application.

func InitScene

func InitScene(prevScene string, data interface{})

InitScene is called whenever the scene 'demo' starts. it creates the objects in our application.

func LoopScene

func LoopScene() bool

LoopScene is a basic scene-loop function, returning the value of some boolean defined in this oak project package. When loopDemo is false, the scene will stop (and then immediately reset, as it is defined to be followed by itself).

func PolygonFromFace

func PolygonFromFace(f *dcel.Face) *render.Polygon

PolygonFromFace converts a dcelFace into a polygon to be rendered


type Button

type Button struct {
	Text       *render.Text
	TxtX, TxtY float64
	Font       *render.Font
	Layer      int

A Button is a UI element that has transient background, overlayed text, collision space, and binds to mouse events.

func NewButton

func NewButton(bndb event.Bindable, f *render.Font) *Button

NewButton returns a new button rendering with a given font, bound to a given bindable function on being clicked.

func (*Button) SetPos

func (b *Button) SetPos(x float64, y float64)

SetPos acts as SetSpace does, overwriting entities.Solid.

func (*Button) SetSpace

func (b *Button) SetSpace(sp *collision.Space)

SetSpace overwrites entities.Solid, pointing this button to use the mouse collision Rtree instead of the entity collision space.

func (*Button) SetString

func (b *Button) SetString(txt string)

SetString converts input strings into stringers.

func (*Button) SetText

func (b *Button) SetText(txt fmt.Stringer)

SetText changes the text on this button to be the input txt.

type DynamicTicker

type DynamicTicker struct {
	// contains filtered or unexported fields

A DynamicTicker is a ticker which can be sent signals in the form of durations to change how often it ticks.

func NewDynamicTicker

func NewDynamicTicker() *DynamicTicker

NewDynamicTicker returns a null-initialized dynamic ticker

func (*DynamicTicker) SetTick

func (dt *DynamicTicker) SetTick(d time.Duration)

SetTick changes the rate at which a dynamic ticker ticks

func (*DynamicTicker) Step

func (dt *DynamicTicker) Step()

Step will force the dynamic ticker to tick, once. If the forced tick is not received, multiple calls to step will do nothing.

type InteractivePoint

type InteractivePoint struct {
	// contains filtered or unexported fields

InteractivePoint is a struct to wrap around dcel points and extend them to be bindable and have collision space.

func NewInteractivePoint

func NewInteractivePoint(v *dcel.Vertex, i int) *InteractivePoint

NewInteractivePoint creates a new ip given a dcel point to base it off of.

func (*InteractivePoint) Init

func (ip *InteractivePoint) Init() event.CID

Init allows ip to satisfy the event.Entity interface, so it may be stored with other entities in a global list managed by oak.

type InteractivePolyhedron

type InteractivePolyhedron struct {
	// contains filtered or unexported fields

An InteractivePolyhedron is a wrapper around an oak polyhedron which defines mouse collision areas to interact with parts of the underlying DCEL structure.

func (*InteractivePolyhedron) Init

func (ip *InteractivePolyhedron) Init() event.CID

Init establishes ip's non-polyhedron variables.

func (*InteractivePolyhedron) UpdateSpaces

func (ip *InteractivePolyhedron) UpdateSpaces()

UpdateSpaces is a helper function to polyhedron's Update which similarly resets parts of the ip as it is moved through space. In this case the large job here is making sure all of the vertex collision areas stay in the right spots.

type Polyhedron

type Polyhedron struct {
	FaceColors []color.Color
	EdgeColors []color.Color
	Center     physics.Vector

Polyhedron is a type which extends render.Renderable, allowing it to be drawn to screen through oak's drawing functionality. Polyhedron specifically draws a DCEL, given some defined colors for the DCEL's faces and Edges. Vertices are given a generic color because they are barely visibile anyway with our drawing scheme. Polyhedrons are not drawn in a very sophisticated manner.

func NewPolyhedronFromDCEL

func NewPolyhedronFromDCEL(dc *dcel.DCEL, x, y float64) *Polyhedron

NewPolyhedronFromDCEL creates a polyhedron from a dcel and an initial screen position

func (*Polyhedron) RotX

func (p *Polyhedron) RotX(theta float64)

RotX rotates the polyhedron around the X axis

func (*Polyhedron) RotY

func (p *Polyhedron) RotY(theta float64)

RotY rotates the polyhedron around the Y axis

func (*Polyhedron) RotZ

func (p *Polyhedron) RotZ(theta float64)

RotZ rotates the polyhedron around the Z axis

func (*Polyhedron) Scale

func (p *Polyhedron) Scale(factor float64)

Scale scales up or down the given polyhedron

func (*Polyhedron) ShiftX

func (p *Polyhedron) ShiftX(x float64)

ShiftX moves a polyhedron and its center along the x axis

func (*Polyhedron) ShiftY

func (p *Polyhedron) ShiftY(y float64)

ShiftY moves a polyhedron and its center along the y axis

func (*Polyhedron) String

func (p *Polyhedron) String() string


func (*Polyhedron) Update

func (p *Polyhedron) Update()

Update keeps a polyhedron's drawn elements consistent with changes in the underlying DCEL.

type Slider

type Slider struct {
	// contains filtered or unexported fields

Slider is a little UI element with a movable slider representing a range. It has a specific purpose of setting visualization delay, but eventually it might be expanded to a more generalized structure.

func NewSlider

func NewSlider(layer int, f *render.Font) *Slider

NewSlider returns a slider with initialized values using the given font to render its text.

func (*Slider) Init

func (sl *Slider) Init() event.CID

Init returns a CID for the Slider.

Note on engine internals: All entities as defined by the engine need to have this function defined on them. this is because an entity is only a meaningful concept in terms of the engine for an entity's ability to have events bound to it and triggered on it, which this CID (caller ID) represents.

Its literal meaning is, in our event bus, the value passed into NextID (which is the only way to get a legitimate CID), is stored at the array index of the returned CID.

func (*Slider) SetPos

func (sl *Slider) SetPos(x float64, y float64)

SetPos is an overwrite of a lower-tiered function which sets this slider's position and the position of it's attached entities

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL