Type CursorImage

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

CursorImage is a pointer the application paints itself, as a picture the system draws as its own pointer: it follows the mouse with no lag, shows over the window's title bar and edges the way any pointer does, and is dropped by the system when the mouse leaves. A remote desktop client uses it for the pointer the remote machine names.

A CursorImage never changes after NewCursorImage, so one value is one pointer and platforms make their native cursor for it once. Make a new value when the picture changes.

Constructors

NewCursorImage#

func NewCursorImage(width, height, hotX, hotY int, scale float32, bgra []byte) (*CursorImage, error)

NewCursorImage is a pointer picture width by height image pixels, with its hotspot at hotX, hotY from the top left: the pixel that is the mouse's position. bgra holds the rows top down, four bytes a pixel in blue, green, red, alpha order, with the color not multiplied by alpha. The image keeps bgra, so it must not be changed afterwards.

scale is how many image pixels one logical pixel of the window covers, 1 when zero: a picture made for the screen's own pixels passes the window's pixel scale, and one drawn at 1x passes 1.

Methods

Hotspot#

func (image *CursorImage) Hotspot() (x, y int)

Hotspot is the pixel of the image that is the mouse's position.

Pixels#

func (image *CursorImage) Pixels() []byte

Pixels is the image's rows, top down, in blue, green, red, alpha bytes with the color not multiplied by alpha. Callers must not change it.

Scale#

func (image *CursorImage) Scale() float32

Scale is how many image pixels cover one logical pixel.

Size#

func (image *CursorImage) Size() (width, height int)

Size is the image's width and height in image pixels.