image

package
v0.0.0-...-c744f44 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ErrCoordOutOfRange log.ConstErr = "coordinates out of range"

ErrCoordOutOfRange indicates that given coordinates are out of range

View Source
const ErrInvalidFormat log.ConstErr = "invalid project file (not .tabula)"
View Source
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.

func (EmptyTool) OnMotion

func (t EmptyTool) OnMotion(evt *sdl.MouseMotionEvent, iv *View)

OnMotion does nothing.

func (EmptyTool) String

func (t EmptyTool) String() string

type Layer

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

func NewLayer

func NewLayer(offset sdl.Point, texture gfx.Texture) *Layer

func (Layer) Destroy

func (l Layer) Destroy()

Destroy destroys OpenGL assets associated with the Layer

func (Layer) MarshalBinary

func (l Layer) MarshalBinary() ([]byte, error)

MarshalBinary fulfills a requirement for gob to encode Layer

func (Layer) Render

func (l Layer) Render(view sdl.FRect)

Render draws the ui.Component

func (*Layer) UnmarshalBinary

func (l *Layer) UnmarshalBinary(data []byte) error

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 Project

type Project struct {
	ProjName string
	Mult     int32
	Canvas   sdl.Rect
	View     sdl.FRect
	Layers   []*Layer
}

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) AddLayer

func (iv *View) AddLayer(tex gfx.Texture)

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

func (iv *View) InBoundary(pt sdl.Point) bool

InBoundary returns whether a point is in this ui.Component's bounds

func (*View) LoadProject

func (iv *View) LoadProject(fileName string) error

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) OnResize

func (iv *View) OnResize(x, y int32)

OnResize is called when the user resizes the window

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) Render

func (iv *View) Render()

Render draws the ui.Component

func (*View) RenderCanvas

func (iv *View) RenderCanvas()

RenderCanvas draws what is on the canvas or area, whichever is larger

func (*View) SaveProject

func (iv *View) SaveProject(fileName string) error

SaveProject saves the relevant project data at the specified file location in a compressed format. The fileName must end with '.tabula'

func (*View) SelectPixel

func (iv *View) SelectPixel(p sdl.Point) error

SelectPixel adds the given x, y pixel to the

func (*View) String

func (iv *View) String() string

String returns the name of the component type

func (*View) WriteToFile

func (iv *View) WriteToFile(fileName string) error

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

Jump to

Keyboard shortcuts

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