nigiri

package module
v0.0.0-...-548dba9 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

README

nigiri

wrapping around ebiten engine (github.com/hajimehoshi/ebiten)

in pre-alpha state

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsJS = false

Functions

func AddAfterLoopSub

func AddAfterLoopSub(sub afterLooper) error

func DelAfterLoopSub

func DelAfterLoopSub(sub afterLooper) error

func DrawRect

func DrawRect(img *ebiten.Image, rect Rect, clr color.Color)

func GetFace

func GetFace(name string, size float64) (font.Face, error)

func GetTempImage

func GetTempImage(w, h int) *ebiten.Image

func PutPoolTex

func PutPoolTex(tex Tex)

func PutTempImage

func PutTempImage(tex *ebiten.Image)

func ResetFaceCache

func ResetFaceCache()

func Run

func Run(mainLoop func(win *ebiten.Image, dt float64) error, width, height int, scale float64, title string) error

func ScreenSize

func ScreenSize() (w, h int)

func SetFaceLoader

func SetFaceLoader(loader FaceLoaderF)

func SetShrink

func SetShrink(shrinkPeriod, shrinkReserve, shrinkLimit int)

func SetTexLoader

func SetTexLoader(f TexLoaderF)

func TexCacheReset

func TexCacheReset()

func TransformUpVector

func TransformUpVector(t VTransformer) vec2.V2

func TransformVector

func TransformVector(t VTransformer, v vec2.V2) vec2.V2

Apply t to both ends of vector (0,0)-(v) and takes delta t(v)-t(0,0)

func UID

func UID() uint64

func Vertex

func Vertex(v2 vec2.V2) ebiten.Vertex

func VertexColor

func VertexColor(v2 vec2.V2, clr color.Color) ebiten.Vertex

Types

type Align

type Align byte
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type Camera

type Camera struct {
	// contains filtered or unexported fields
}

func NewCamera

func NewCamera() *Camera

func (*Camera) Angle

func (c *Camera) Angle() float64

func (*Camera) Apply

func (c *Camera) Apply(x, y float64) (float64, float64)

func (*Camera) ApplyPoint

func (c *Camera) ApplyPoint(v vec2.V2) vec2.V2

func (*Camera) Center

func (c *Camera) Center() vec2.V2

func (*Camera) ClipRect

func (c *Camera) ClipRect() image.Rectangle

func (*Camera) ClippedRect

func (c *Camera) ClippedRect(rect Rect) bool

return true if we can skip drawing this rect, false if we should draw false negative is ok as we draw some off-screen, false positives are not accepted

func (*Camera) Local

func (c *Camera) Local() RTransformer

func (*Camera) Mark

func (c *Camera) Mark() RTransformer

func (*Camera) MulScale

func (c *Camera) MulScale(scaleK float64)

func (*Camera) NoRot

func (c *Camera) NoRot() RTransformer

func (*Camera) NoScale

func (c *Camera) NoScale() RTransformer

func (*Camera) Phys

func (c *Camera) Phys() RTransformer

func (*Camera) Pos

func (c *Camera) Pos() vec2.V2

func (*Camera) Rotate

func (c *Camera) Rotate(ang float64)

func (*Camera) Scale

func (c *Camera) Scale() float64

func (*Camera) SetAng

func (c *Camera) SetAng(v float64)

func (*Camera) SetCenter

func (c *Camera) SetCenter(v vec2.V2)

func (*Camera) SetClipRect

func (c *Camera) SetClipRect(rect image.Rectangle)

func (*Camera) SetPos

func (c *Camera) SetPos(v vec2.V2)

func (*Camera) SetScale

func (c *Camera) SetScale(v float64)

func (*Camera) Translate

func (c *Camera) Translate(delta vec2.V2)

func (*Camera) UnApply

func (c *Camera) UnApply(x, y float64) (float64, float64)

func (*Camera) UnApplyPoint

func (c *Camera) UnApplyPoint(v vec2.V2) vec2.V2

type Clipper

type Clipper interface {
	ClipRect() image.Rectangle
}

type DrawOptions

type DrawOptions struct {
	Layer Layer
	// contains filtered or unexported fields
}

func NewDrawOptions

func NewDrawOptions(layer Layer) DrawOptions

func (DrawOptions) ColorAlpha

func (do DrawOptions) ColorAlpha() (color.Color, float64)

func (DrawOptions) CompositeMode

func (do DrawOptions) CompositeMode() ebiten.CompositeMode

func (*DrawOptions) SetAlpha

func (do *DrawOptions) SetAlpha(alpha float64)

func (*DrawOptions) SetColor

func (do *DrawOptions) SetColor(color color.Color)

func (*DrawOptions) SetCompositeMode

func (do *DrawOptions) SetCompositeMode(mode ebiten.CompositeMode)

type DrawRequester

type DrawRequester interface {
	DrawReqs(Q *Queue)
}

type Drawer

type Drawer struct {
	Src           TexSrcer
	Transform     RTransformer
	Clipper       Clipper
	ChangeableTex bool

	DrawOptions
	// contains filtered or unexported fields
}

func NewDrawer

func NewDrawer(src TexSrcer, layer Layer, transform ...RTransformer) *Drawer

func (*Drawer) DrawReqs

func (id *Drawer) DrawReqs(Q *Queue)

func (*Drawer) GetRect

func (id *Drawer) GetRect() Rect

func (*Drawer) SetSmooth

func (id *Drawer) SetSmooth(smooth bool)

type FaceLoaderF

type FaceLoaderF func(name string, size float64) (font.Face, error)

func FileFaceLoader

func FileFaceLoader(pathStr string) FaceLoaderF

type FrameTexSrc

type FrameTexSrc struct {
	// contains filtered or unexported fields
}

func NewFrameTexSrc

func NewFrameTexSrc(tex Tex, sizeX, sizeY, count int, updF FrameUpdF) (*FrameTexSrc, error)

func (*FrameTexSrc) Count

func (f *FrameTexSrc) Count() int

func (*FrameTexSrc) FrameN

func (f *FrameTexSrc) FrameN() int

func (*FrameTexSrc) GetSrcImage

func (f *FrameTexSrc) GetSrcImage() *ebiten.Image

func (*FrameTexSrc) GetSrcRectUID

func (f *FrameTexSrc) GetSrcRectUID() (srcRect *image.Rectangle, uid uint64)

func (*FrameTexSrc) SetFrameN

func (f *FrameTexSrc) SetFrameN(n int)

func (*FrameTexSrc) Update

func (f *FrameTexSrc) Update(dt float64)

type FrameUpdF

type FrameUpdF func(src *FrameTexSrc, dt float64)

func AnimateFrameCycle

func AnimateFrameCycle(fps float64) FrameUpdF

func AnimateFrameOnce

func AnimateFrameOnce(fps float64) FrameUpdF

type Layer

type Layer float32

type Line

type Line struct {
	CamTransform RTransformer
	DrawOptions

	From  vec2.V2
	To    vec2.V2
	Width float64
}

todo: change to triangles

func NewLine

func NewLine(camTransform RTransformer, layer Layer) Line

func NewLineExt

func NewLineExt(camTransform RTransformer, opts DrawOptions, from, to vec2.V2, width float64) Line

func (Line) DrawReqs

func (l Line) DrawReqs(Q *Queue)

type MouseRect

type MouseRect struct {
	MouseActive bool
	CatchRect   image.Rectangle
	// contains filtered or unexported fields
}

func NewClickRect

func NewClickRect(selfF OnMouserF) MouseRect

func (*MouseRect) AddChild

func (c *MouseRect) AddChild(child OnMouser)

func (*MouseRect) DeleteChild

func (c *MouseRect) DeleteChild(child OnMouser)

func (MouseRect) OnMouse

func (c MouseRect) OnMouse(x, y int) bool

type OnMouser

type OnMouser interface {
	OnMouse(x, y int) bool
}

type OnMouserF

type OnMouserF func(x, y int) bool

func (OnMouserF) OnMouse

func (f OnMouserF) OnMouse(x, y int) bool

type Polyline

type Polyline struct {
	CamTransform RTransformer
	DrawOptions

	Points []vec2.V2
	Closed bool
	Width  float64
	Color  color.Color
}

func NewPolyline

func NewPolyline(camTransform RTransformer, layer Layer) Polyline

func NewPolylineExt

func NewPolylineExt(camTransform RTransformer, opts DrawOptions, points []vec2.V2,
	width float64, color color.Color) Polyline

func (Polyline) DrawReqs

func (l Polyline) DrawReqs(Q *Queue)

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Add

func (Q *Queue) Add(d DrawRequester)

for use from outside package

func (*Queue) Clear

func (Q *Queue) Clear()

func (*Queue) Len

func (Q *Queue) Len() int

func (*Queue) Run

func (Q *Queue) Run(dest *ebiten.Image)

type RTransformer

type RTransformer interface {
	TransformRect(rect Rect) Rect
}

type Rect

type Rect struct {
	//position of pivot point in world coordinates
	Position vec2.V2

	//size of rect, negative numbers are okay as that is a flipped axis
	Width  float64
	Height float64
	//Rotation of rect in Degrees, counter clockwise
	Angle float64
	// contains filtered or unexported fields
}
var ZR Rect

func NewRect

func NewRect(w, h float64, pivotRel vec2.V2) Rect

func (Rect) AbsToRel

func (r Rect) AbsToRel(absPoint vec2.V2) (relPoint vec2.V2, ok bool)

func (Rect) ClipRect

func (r Rect) ClipRect() Rect

func (Rect) Corners

func (r Rect) Corners() (res [4]vec2.V2)

func (Rect) Empty

func (r Rect) Empty() bool

func (Rect) OuterImageRect

func (r Rect) OuterImageRect() (res image.Rectangle)

func (Rect) RelToAbs

func (r Rect) RelToAbs(relPoint vec2.V2) (absPoint vec2.V2)

func (Rect) TransformRect

func (r Rect) TransformRect(rect Rect) Rect

type RectDrawer

type RectDrawer struct {
	Rect
	*TriDrawer
	// contains filtered or unexported fields
}

func NewRectDrawer

func NewRectDrawer(r Rect, layer Layer, cam RTransformer) RectDrawer

func (RectDrawer) GetVerticesIndices

func (rd RectDrawer) GetVerticesIndices() (v []ebiten.Vertex, i []uint16)

type Scaler

type Scaler struct {
	UseFixed       bool
	FitProportion  bool
	ScaleFactor    vec2.V2
	FixedW, FixedH float64
}

func NewFitScaler

func NewFitScaler(w, h float64) Scaler

func NewFixedScaler

func NewFixedScaler(w, h float64) Scaler

func NewScaler

func NewScaler(scale float64) Scaler

func (Scaler) TransformRect

func (s Scaler) TransformRect(rect Rect) Rect

type Sector

type Sector struct {
	SectorParams
	*TriDrawer
	// contains filtered or unexported fields
}

func NewSector

func NewSector(p SectorParams, layer Layer, vTransformer VTransformer) *Sector

func (*Sector) GetVerticesIndices

func (s *Sector) GetVerticesIndices() (v []ebiten.Vertex, i []uint16)

type SectorParams

type SectorParams struct {
	Center   vec2.V2
	Radius   float64
	StartAng float64
	EndAng   float64
}

func (SectorParams) New

func (p SectorParams) New(layer Layer, camera *Camera) *Sector

type Sprite

type Sprite struct {
	*SpriteTrans
	*Drawer
	// contains filtered or unexported fields
}

func NewSprite

func NewSprite(src TexSrcer, layer Layer, transforms ...RTransformer) *Sprite

func (*Sprite) GetSrcColor

func (s *Sprite) GetSrcColor(x, y int) (clr color.Color, ok bool)

func (*Sprite) GetSrcPoint

func (s *Sprite) GetSrcPoint(x, y int) (p image.Point, ok bool)

func (*Sprite) GetSrcPointColor

func (s *Sprite) GetSrcPointColor(x, y int) (pt image.Point, clr color.Color, ok bool)

func (Sprite) Update

func (s Sprite) Update(dt float64)

type SpriteTrans

type SpriteTrans struct {
	Position vec2.V2
	Pivot    vec2.V2
	Angle    float64
	Scaler
}

func (SpriteTrans) TransformRect

func (s SpriteTrans) TransformRect(rect Rect) Rect

type Tex

type Tex struct {
	// contains filtered or unexported fields
}

func CircleTex

func CircleTex() Tex

func GetPoolTex

func GetPoolTex(w, h int) Tex

func GetTex

func GetTex(name string) (tex Tex, err error)

func NewCircleTex

func NewCircleTex(radius int) Tex

func NewTex

func NewTex(img *ebiten.Image) Tex

func (Tex) GetSrcImage

func (t Tex) GetSrcImage() *ebiten.Image

func (Tex) GetSrcRectUID

func (t Tex) GetSrcRectUID() (srcRect *image.Rectangle, uid uint64)

func (Tex) Size

func (t Tex) Size() (x, y int)

type TexCache

type TexCache struct {
	// contains filtered or unexported fields
}

func NewTexCache

func NewTexCache(loader TexLoaderF) *TexCache

func (*TexCache) GetTex

func (tc *TexCache) GetTex(name string) (tex Tex, err error)

func (*TexCache) Reset

func (tc *TexCache) Reset()

func (*TexCache) SetTexLoader

func (tc *TexCache) SetTexLoader(f TexLoaderF)

type TexLoaderF

type TexLoaderF func(name string) (*ebiten.Image, error)

func FileTexLoader

func FileTexLoader(pathStr string) TexLoaderF

type TexSrcer

type TexSrcer interface {
	GetSrcRectUID() (srcRect *image.Rectangle, uid uint64)
	GetSrcImage() *ebiten.Image
}

type TextDrawer

type TextDrawer struct {
	Face     font.Face
	Text     string
	Layer    Layer
	Position vec2.V2
	Color    color.Color
}

func NewTextDrawer

func NewTextDrawer(face font.Face, layer Layer) *TextDrawer

func (*TextDrawer) DrawReqs

func (td *TextDrawer) DrawReqs(Q *Queue)

type TextSprite

type TextSprite struct {
	*TextSrc
	*SpriteTrans
	*Drawer
}

func NewTextSprite

func NewTextSprite(interlineK float64, permanentTex bool, layer Layer, transforms ...RTransformer) *TextSprite

type TextSrc

type TextSrc struct {

	//default values for new strings, already exist do not change
	DefFace  font.Face
	DefColor color.Color
	DefAlign Align

	InterLineK float64
	// contains filtered or unexported fields
}

func NewTextSrc

func NewTextSrc(InterLineK float64, permanentTex bool) *TextSrc

func NewTextSrcExt

func NewTextSrcExt(InterLineK float64, permanentTex bool, face font.Face, align Align, clr color.Color) *TextSrc

func (*TextSrc) AddText

func (ts *TextSrc) AddText(text string)

func (*TextSrc) AddTextExt

func (ts *TextSrc) AddTextExt(text string, face font.Face, align Align, clr color.Color)

func (*TextSrc) GetSrcImage

func (ts *TextSrc) GetSrcImage() *ebiten.Image

func (*TextSrc) GetSrcRectUID

func (ts *TextSrc) GetSrcRectUID() (srcRect *image.Rectangle, uid uint64)

func (*TextSrc) Reset

func (ts *TextSrc) Reset()

func (*TextSrc) SetText

func (ts *TextSrc) SetText(text string)

func (*TextSrc) SetTextExt

func (ts *TextSrc) SetTextExt(text string, face font.Face, align Align, clr color.Color)

type TransformerF

type TransformerF func(in Rect) (out Rect, clip image.Rectangle)

func (TransformerF) ClipRect

func (f TransformerF) ClipRect() image.Rectangle

func (TransformerF) TransformRect

func (f TransformerF) TransformRect(rect Rect) Rect

type Transforms

type Transforms []RTransformer

func (Transforms) TransformRect

func (t Transforms) TransformRect(rect Rect) Rect

type TriDrawer

type TriDrawer struct {
	Src           TriSrcer
	Cam           VTransformer
	Clipper       Clipper
	ChangeableSrc bool

	DrawOptions
	// contains filtered or unexported fields
}

func NewTriDrawer

func NewTriDrawer(src TriSrcer, layer Layer, cam VTransformer) *TriDrawer

func (*TriDrawer) DrawReqs

func (s *TriDrawer) DrawReqs(Q *Queue)

type TriSrcer

type TriSrcer interface {
	GetVerticesIndices() ([]ebiten.Vertex, []uint16)
}

type Updater

type Updater interface {
	Update(dt float64)
}

type VTransformer

type VTransformer interface {
	ApplyPoint(vec2.V2) vec2.V2
}

Jump to

Keyboard shortcuts

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