Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type History ¶
type History struct {
// contains filtered or unexported fields
}
History manages a history of Strokes added to a drawing.
func (*History) AddStroke ¶
AddStroke adds a stroke to the history, becoming the new tail at the end of the history data.
func (*History) Latest ¶
Latest returns the tail of the history (the most recent stroke). If you had recently called Undo, the latest stroke may still have a 'next' stroke. Returns nil if there was no stroke in history.
func (*History) Oldest ¶
Oldest returns the head of the history (the earliest stroke added). If the history size limit had been reached, the oldest stroke will creep along forward and not necessarily be the FIRST EVER stroke added.
func (*History) Redo ¶
Redo advances forwards after a recent Undo. Note that if you added new strokes after an Undo, the new tail has no next node to move to and Redo returns false.
func (*History) Undo ¶
Undo steps back a step in the history. This sets the current tail to point to the "tail - 1" element, but doesn't change the link of that element to its future value yet; so that you can Redo it. But if you add a new stroke from this state, it will overwrite the tail.next and invalidate the old history that came after, starting a new branch of history from that point on.
Returns false if the undo failed (no earlier node to move to).
type HistoryElement ¶
type HistoryElement struct {
// contains filtered or unexported fields
}
HistoryElement is a doubly linked list of stroke history.
type Stroke ¶
type Stroke struct { ID int // Unique ID per each stroke Shape Shape Color render.Color Pattern string Thickness int // 0 = 1px; thickness creates a box N pixels away from each point ExtraData interface{} // arbitrary storage for extra data to attach // Start and end points for Lines, Rectangles, etc. PointA render.Point PointB render.Point // Array of points for Freehand shapes. Points []render.Point // Storage space to recall the previous values of points that were replaced, // especially for the Undo/Redo History tool. When the uix.Canvas commits a // Stroke to the level data, any pixel that has replaced an existing color // will cache its color here, so we can easily page forwards and backwards // in history and not lose data. // // The data is implementation defined and controlled by the caller. This // package does not modify OriginalPoints or do anything with it. OriginalPoints map[render.Point]interface{} // contains filtered or unexported fields }
Stroke holds temporary pixel data with a shape and color.
It is used for myriad purposes:
- As a staging area for drawing new pixels to the drawing without committing them until completed.
- As a unit of work for the Undo/Redo History when editing a drawing.
- As imaginary visual lines superimposed on top of a drawing, for example to visualize the link between two doodads or to draw collision hitboxes and other debug lines to the drawing.
func (*Stroke) IterPoints ¶
IterPoints returns an iterator of points represented by the stroke.
For a Line, returns all of the points between PointA and PointB. For freehand, returns every point added to the stroke.
func (*Stroke) IterThickPoints ¶
IterThickPoints iterates over the points and yield Rects of each one.
type TextSettings ¶
type TextSettings struct { Font string // like 'DejaVuSans.ttf' Size int Message string Label *ui.Label // cached label texture }
TextSettings holds currently selected Text Tool settings.
var TT TextSettings
Currently active settings (global variable)
func (TextSettings) IsZero ¶
func (tt TextSettings) IsZero() bool
IsZero checks if the TextSettings are populated.