Documentation
¶
Overview ¶
Package markup is the screenshot markup editor: annotations drawn over a captured image (crop, arrow, rectangle, ellipse, freehand, text, highlighter, numbered markers and pixelation) with undo and redo, painted live on screen and flattened into the pixels that are saved.
Index ¶
- Variables
- func Flatten(d *Doc, font render.Font) *image.RGBA
- func MarkerPx(size int) int
- func Paint(cv *render.Canvas, marks []Mark, v View, font render.Font)
- func PaintMark(cv *render.Canvas, m Mark, v View, font render.Font)
- func TextPx(size int) float64
- type Deps
- type Doc
- type Editor
- type Mark
- type Tool
- type View
Constants ¶
This section is empty.
Variables ¶
var Tools = []Tool{ToolCrop, ToolArrow, ToolRect, ToolEllipse, ToolFreehand, ToolText, ToolHighlight, ToolMarker, ToolPixelate}
Tools lists every tool in toolbar order.
Functions ¶
func Flatten ¶
Flatten renders the document as it is saved: the marks burned into a copy of the captured pixels, cropped. Pixelated cells replace the pixels under them, so nothing of the original survives there.
Types ¶
type Deps ¶
type Deps struct {
App *app.Application
// Font draws the toolbar, text marks and marker numbers; Px is the
// toolbar's size.
Font render.Font
Px float64
// Palette is the colors the toolbar offers, the first one picked.
Palette []render.Color
// Save writes the flattened image over path, atomically, and copies it.
Save func(img *image.RGBA, path string) error
// SaveAs writes the flattened image to a path the user picked.
SaveAs func(img *image.RGBA, path string) error
// Closed runs once the window is gone, whatever closed it.
Closed func()
}
Deps are what the editor needs from the shell.
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc is an image under edit: the captured pixels, never changed, and the marks over them with an undo cursor.
func NewDoc ¶
func NewDoc(base render.StillImage) *Doc
NewDoc starts editing base, which it never writes.
func (*Doc) Push ¶
Push applies m on top, discarding what undo had taken back. A pixelation samples its cells now, a marker takes the next number, and a mark with nothing to show is dropped; it reports whether m was applied.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is one open markup window. Its methods run on the loop goroutine.
func Open ¶
Open shows the editor over base, the captured image saved at path. It draws base as it is in memory: the file is never read.
func (*Editor) Save ¶
Save flattens the marks into the image, writes it over the capture and closes the editor; a failed write keeps it open and is returned.
type Mark ¶
type Mark struct {
Tool Tool
Points []image.Point
Color render.Color
Size int
Text string
Number int
// contains filtered or unexported fields
}
Mark is one annotation in image pixels. Points holds the drag's endpoints (every sampled point for freehand); Size is the stroke width; Text is a text mark's string; Number is a marker's ordinal.