Documentation
¶
Overview ¶
Package cursor provides a pure Go parser and decoder for Windows static (.cur) and animated (.ani) cursor files, extracting animation frames, per-frame durations, and pixel-precise cursor hotspots.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnsupportedFormat indicates the input data is neither a valid .cur nor .ani file. ErrUnsupportedFormat = errors.New("unsupported cursor format: only .cur and .ani files are supported") // ErrTruncatedData indicates the input stream terminated prematurely. ErrTruncatedData = errors.New("truncated cursor data") // ErrInvalidHeader indicates malformed header metadata. ErrInvalidHeader = errors.New("invalid cursor header") // ErrNoFrames indicates the cursor file contains no decodable image frames. ErrNoFrames = errors.New("cursor file contains no frames") // ErrFrameLimitExceeded indicates an animation exceeded the maximum allowed frames. ErrFrameLimitExceeded = errors.New("animation frame limit exceeded") )
Functions ¶
Types ¶
type Cursor ¶
type Cursor struct {
// Frames contains each decoded image frame (NRGBA or RGBA).
Frames []image.Image
// Delays contains the display duration for each frame.
Delays []time.Duration
// DelayMs contains the display duration in integer milliseconds for each frame.
DelayMs []int
// HotspotX is the raw pixel X coordinate of the cursor active point.
HotspotX int
// HotspotY is the raw pixel Y coordinate of the cursor active point.
HotspotY int
// Width is the nominal width of the cursor in pixels.
Width int
// Height is the nominal height of the cursor in pixels.
Height int
// Animated reports whether this cursor contains multiple animation frames (.ani).
Animated bool
}
Cursor represents a decoded Windows static or animated cursor.
func DecodeBytes ¶
DecodeBytes parses cursor data from a byte slice and returns the decoded Cursor.
func (*Cursor) HotspotFraction ¶
HotspotFraction converts the raw pixel hotspot into normalized [0.0, 1.0] fractions relative to a given crop rectangle. If crop dimensions are not positive, fractions are computed relative to the cursor nominal source dimensions. Normalized fractions survive scaling and resizing operations.
Click to show internal directories.
Click to hide internal directories.