apptype

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package apptype defines the core types and interfaces for the Pel pixel art editor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrushType

type BrushType int

BrushType represents the type of brush tool being used

const (
	BrushTypePencil BrushType = iota
	BrushTypeEraser
	BrushTypeFill
	BrushTypeLine
	BrushTypeRectangle
	BrushTypeCircle
)

Brush type constants

func (BrushType) IsValid

func (bt BrushType) IsValid() bool

IsValid checks if the brush type is valid

func (BrushType) String

func (bt BrushType) String() string

String returns a human-readable name for the brush type

type Brushable

type Brushable interface {
	// SetColor sets the color at the specified canvas coordinates
	// Returns an error if the operation fails
	SetColor(c color.Color, x, y int) error

	// MouseToCanvasXY converts mouse event coordinates to canvas coordinates
	// Returns nil pointers if the coordinates are outside the canvas
	MouseToCanvasXY(ev *desktop.MouseEvent) (*int, *int)
}

Brushable defines the interface for objects that can be painted on

type PelCanvasConfig

type PelCanvasConfig struct {
	DrawingArea  fyne.Size     // Size of the drawing area in pixels
	CanvasOffset fyne.Position // Offset of the canvas from the window origin
	PxRows       int           // Number of pixel rows in the grid
	PxCols       int           // Number of pixel columns in the grid
	PxSize       int           // Size of each pixel in screen pixels
}

PelCanvasConfig holds the configuration for the pixel canvas

func (PelCanvasConfig) TotalPixels

func (c PelCanvasConfig) TotalPixels() int

TotalPixels returns the total number of pixels in the canvas

func (PelCanvasConfig) Validate

func (c PelCanvasConfig) Validate() error

Validate checks if the canvas configuration is valid

type State

type State struct {
	BrushColor     color.Color // Current brush color
	BrushType      BrushType   // Current brush tool type
	SwatchSelected int         // Index of the currently selected color swatch
	FilePath       string      // Path to the currently open file (empty if new/unsaved)
}

State represents the current state of the application

func (*State) HasFilePath

func (s *State) HasFilePath() bool

HasUnsavedChanges returns true if there's a file path (indicating the project has been saved)

func (*State) SetBrushColor

func (s *State) SetBrushColor(c color.Color)

SetBrushColor updates the current brush color

func (*State) SetBrushType

func (s *State) SetBrushType(bt BrushType)

SetBrushType updates the current brush type

func (*State) SetFilePath

func (s *State) SetFilePath(path string)

SetFilePath updates the file path for the current project

func (*State) SetSwatchSelected

func (s *State) SetSwatchSelected(index int)

SetSwatchSelected updates the selected swatch index

func (*State) Validate

func (s *State) Validate() error

Validate checks if the state is valid

Jump to

Keyboard shortcuts

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