Documentation ¶
Index ¶
- Constants
- type EmptyTool
- type Layer
- type PixelColorTool
- type PixelSelectionTool
- type Project
- type Tool
- type View
- func (iv *View) AddLayer(tex gfx.Texture)
- func (iv *View) CenterCanvas()
- func (iv *View) Destroy()
- func (iv *View) InBoundary(pt sdl.Point) bool
- func (iv *View) LoadProject(fileName string) error
- func (iv *View) OnClick(evt *sdl.MouseButtonEvent) bool
- func (iv *View) OnEnter()
- func (iv *View) OnLeave()
- func (iv *View) OnMotion(evt *sdl.MouseMotionEvent) bool
- func (iv *View) OnResize(x, y int32)
- func (iv *View) OnScroll(evt *sdl.MouseWheelEvent) bool
- func (iv *View) Render()
- func (iv *View) RenderCanvas()
- func (iv *View) SaveProject(fileName string) error
- func (iv *View) SelectPixel(p sdl.Point) error
- func (iv *View) String() string
- func (iv *View) WriteToFile(fileName string) error
Constants ¶
const ErrCoordOutOfRange log.ConstErr = "coordinates out of range"
ErrCoordOutOfRange indicates that given coordinates are out of range
const ErrInvalidFormat log.ConstErr = "invalid project file (not .tabula)"
const ErrWriteFormat log.ConstErr = "unsupported image format"
ErrWriteFormat indicates that an unsupported image format was trying to be written to
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmptyTool ¶
type EmptyTool struct { }
EmptyTool does nothing.
func (EmptyTool) OnClick ¶
func (t EmptyTool) OnClick(evt *sdl.MouseButtonEvent, iv *View)
OnClick does nothing.
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
func (Layer) Destroy ¶
func (l Layer) Destroy()
Destroy destroys OpenGL assets associated with the Layer
func (Layer) MarshalBinary ¶
MarshalBinary fulfills a requirement for gob to encode Layer
func (*Layer) UnmarshalBinary ¶
UnmarshalBinary fulfills a requirement for gob to decode Layer
type PixelColorTool ¶
type PixelColorTool struct {
// contains filtered or unexported fields
}
PixelColorTool colors any clicked pixels purple
func (*PixelColorTool) OnClick ¶
func (t *PixelColorTool) OnClick(evt *sdl.MouseButtonEvent, iv *View)
OnClick is called when the user clicks within the Image View's region and the tool is currently active for the image view.
func (*PixelColorTool) OnMotion ¶
func (t *PixelColorTool) OnMotion(evt *sdl.MouseMotionEvent, iv *View)
OnMotion is called when the user clicks within the Image View's region and the tool is currently active for the image view.
func (*PixelColorTool) String ¶
func (t *PixelColorTool) String() string
type PixelSelectionTool ¶
type PixelSelectionTool struct {
// contains filtered or unexported fields
}
PixelSelectionTool selects any clicked pixels
func (*PixelSelectionTool) OnClick ¶
func (t *PixelSelectionTool) OnClick(evt *sdl.MouseButtonEvent, iv *View)
OnClick is called when the user clicks within the Image View's region and the tool is currently active for the image view.
func (*PixelSelectionTool) OnMotion ¶
func (t *PixelSelectionTool) OnMotion(evt *sdl.MouseMotionEvent, iv *View)
OnMotion is called when the user clicks within the Image View's region and the tool is currently active for the image view.
func (*PixelSelectionTool) String ¶
func (t *PixelSelectionTool) String() string
type Tool ¶
type Tool interface { OnClick(evt *sdl.MouseButtonEvent, iv *View) OnMotion(evt *sdl.MouseMotionEvent, iv *View) fmt.Stringer }
Tool defines the behavior of tools used for the image view.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View defines an interactable image viewing pane
func NewView ¶
func NewView(area sdl.Rect, bbComms chan<- comms.Image, toolComms <-chan Tool, cfg *config.Config) (*View, error)
NewView returns a pointer to a new View struct that implements ui.Component
func (*View) CenterCanvas ¶
func (iv *View) CenterCanvas()
CenterCanvas updates the view so the canvas is in the center of the window
func (*View) Destroy ¶
func (iv *View) Destroy()
Destroy frees all assets acquired by the ui.Component
func (*View) InBoundary ¶
InBoundary returns whether a point is in this ui.Component's bounds
func (*View) LoadProject ¶
LoadProject loads the project data at the specified file location, decompresses and decodes the data and populates the relevant fields in the image view. The fileName must end with '.tabula'
func (*View) OnClick ¶
func (iv *View) OnClick(evt *sdl.MouseButtonEvent) bool
OnClick is called when the user clicks within the ui.Component's region
func (*View) OnEnter ¶
func (iv *View) OnEnter()
OnEnter is called when the cursor enters the ui.Component's region
func (*View) OnLeave ¶
func (iv *View) OnLeave()
OnLeave is called when the cursor leaves the ui.Component's region
func (*View) OnMotion ¶
func (iv *View) OnMotion(evt *sdl.MouseMotionEvent) bool
OnMotion is called when the cursor moves within the ui.Component's region
func (*View) OnScroll ¶
func (iv *View) OnScroll(evt *sdl.MouseWheelEvent) bool
OnScroll is called when the user scrolls within the ui.Component's region
func (*View) RenderCanvas ¶
func (iv *View) RenderCanvas()
RenderCanvas draws what is on the canvas or area, whichever is larger
func (*View) SaveProject ¶
SaveProject saves the relevant project data at the specified file location in a compressed format. The fileName must end with '.tabula'
func (*View) SelectPixel ¶
SelectPixel adds the given x, y pixel to the
func (*View) WriteToFile ¶
WriteToFile uses an OpenGL Frame Buffer Object to render the data in the canvas to a texture, and then write the data in that texture to the specified file