Documentation ¶
Index ¶
- Constants
- Variables
- func AbsInt(v int) int
- func AbsInt32(v int32) int32
- func ImageToRGBA(input image.Image) *image.RGBA
- func IterEllipse(A, B Point) chan Point
- func IterLine(p1 Point, p2 Point) chan Point
- func IterRect(p1, p2 Point) chan Point
- func MidpointEllipse(center, radius Point) chan Point
- func OpenImage(filename string) (image.Image, error)
- func ParseResolution(resi string) (int, int, error)
- func TrimBox(src, dst *Rect, p Point, S Rect, thickness int)
- type Color
- func (c Color) Add(r, g, b, a int) Color
- func (c Color) AddColor(other Color) Color
- func (c Color) Darken(v int) Color
- func (c Color) IsZero() bool
- func (c Color) Lighten(v int) Color
- func (c Color) MarshalJSON() ([]byte, error)
- func (c Color) SetAlpha(v uint8) Color
- func (c Color) String() string
- func (c Color) ToColor() color.RGBA
- func (c Color) ToHex() string
- func (c Color) ToRGBA() color.RGBA
- func (c Color) Transparent() bool
- func (c Color) Transparentize(v int) Color
- func (c *Color) UnmarshalJSON(b []byte) error
- type Engine
- type Point
- func (p *Point) Add(other Point)
- func (p *Point) Compare(other Point) Point
- func (p Point) Inside(r Rect) bool
- func (p Point) IsZero() bool
- func (p *Point) MarshalText() ([]byte, error)
- func (p Point) String() string
- func (p *Point) Subtract(other Point)
- func (p *Point) UnmarshalText(b []byte) error
- type Rect
- type Text
- type Texturer
Constants ¶
const Version = "0.1.0"
Version number of the render library.
Variables ¶
var ( Invisible = Color{} White = RGBA(255, 255, 255, 255) Grey = RGBA(153, 153, 153, 255) DarkGrey = RGBA(64, 64, 64, 255) Black = RGBA(0, 0, 0, 255) SkyBlue = RGBA(0, 153, 255, 255) Blue = RGBA(0, 0, 255, 255) DarkBlue = RGBA(0, 0, 153, 255) Red = RGBA(255, 0, 0, 255) DarkRed = RGBA(153, 0, 0, 255) Green = RGBA(0, 255, 0, 255) DarkGreen = RGBA(0, 153, 0, 255) Cyan = RGBA(0, 255, 255, 255) DarkCyan = RGBA(0, 153, 153, 255) Yellow = RGBA(255, 255, 0, 255) Orange = RGBA(255, 153, 0, 255) DarkYellow = RGBA(153, 153, 0, 255) Magenta = RGBA(255, 0, 255, 255) Purple = RGBA(153, 0, 153, 255) Pink = RGBA(255, 153, 255, 255) )
Common color names.
Functions ¶
func ImageToRGBA ¶
ImageToRGBA converts a Go image.Image into an image.RGBA.
func IterEllipse ¶
IterEllipse iterates an Ellipse using two Points as the top-left and bottom-right corners of a rectangle that encompasses the ellipse.
func IterLine ¶
IterLine is a generator that returns the X,Y coordinates to draw a line. https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm)
func IterRect ¶
IterRect loops through all the points forming a rectangle between the top-left point and the bottom-right point.
func MidpointEllipse ¶
MidpointEllipse implements an ellipse plotting algorithm.
func OpenImage ¶
OpenImage opens an image file from disk.
Supported file types are: jpeg, gif, png, bmp.
func ParseResolution ¶
ParseResolution turns a resolution string like "1024x768" and returns the width and height values.
Types ¶
type Color ¶
Color holds an RGBA color value.
func MustHexColor ¶
MustHexColor parses a color from hex code or panics.
func (Color) MarshalJSON ¶
MarshalJSON serializes the Color for JSON.
func (Color) Transparent ¶
Transparent returns whether the alpha channel is zeroed out and the pixel won't appear as anything when rendered.
func (Color) Transparentize ¶
Transparentize adjusts the alpha value.
func (*Color) UnmarshalJSON ¶
UnmarshalJSON reloads the Color from JSON.
type Engine ¶
type Engine interface { Setup() error // Poll for events like keypresses and mouse clicks. Poll() (*event.State, error) GetTicks() uint32 WindowSize() (w, h int) // Present presents the current state to the screen. Present() error // Clear the full canvas and set this color. Clear(Color) SetTitle(string) DrawPoint(Color, Point) DrawLine(Color, Point, Point) DrawRect(Color, Rect) DrawBox(Color, Rect) DrawText(Text, Point) error ComputeTextRect(Text) (Rect, error) // Texture caching. StoreTexture(name string, img image.Image) (Texturer, error) LoadTexture(name string) (Texturer, error) Copy(t Texturer, src, dst Rect) // Teardown and free memory for all textures, returning the number // of textures that were freed. FreeTextures() int // Delay for a moment using the render engine's delay method, // implemented by sdl.Delay(uint32) Delay(uint32) // Tasks that the Setup function should defer until tear-down. Teardown() Loop() error // maybe? }
Engine is the interface for the rendering engine, keeping SDL-specific stuff far away from the core of Doodle.
type Point ¶
Point holds an X,Y coordinate value.
var (
Origin Point
)
Common points.
func ParsePoint ¶
ParsePoint to parse a point from its string representation.
func (*Point) Compare ¶
Compare the point to another, returning a delta coordinate.
If the two points are equal the result has X=0 Y=0. Otherwise the X and Y return values will be positive or negative numbers of how you could modify the current Point to be equal to the other.
func (Point) Inside ¶
Inside returns whether the Point falls inside the rect.
NOTICE: the W and H are zero-relative, so a 100x100 box at coordinate X,Y would still have W,H of 100.
func (*Point) MarshalText ¶
MarshalText to convert the point into text so that a render.Point may be used as a map key and serialized to JSON.
func (*Point) UnmarshalText ¶
UnmarshalText to restore it from text.
type Rect ¶
Rect has a coordinate and a width and height.
func NewRect ¶
NewRect creates a rectangle of size `width` and `height`. The X,Y values are initialized to zero.
func (Rect) Intersects ¶
Intersects with the other rectangle in any way.
func (Rect) SubtractPoint ¶
SubtractPoint is the inverse of AddPoint. Use this only if you need to invert the Point being added.
This does r.X - other.X, r.Y - other.Y and keeps the width/height the same.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package sdl provides an SDL2 renderer for Doodle.
|
Package sdl provides an SDL2 renderer for Doodle. |