BitMap

package
v0.0.0-...-568b220 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package BitMap provides methods for working with BitMap object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsBitMap() Instance
}

type Expanded

type Expanded [1]gdclass.BitMap

func (Expanded) CreateFromImageAlpha

func (self Expanded) CreateFromImageAlpha(image Image.Instance, threshold Float.X)

Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to [code]false[/code] if the alpha value of the image at that position is equal to [param threshold] or less, and [code]true[/code] in other case.

func (Expanded) OpaqueToPolygons

func (self Expanded) OpaqueToPolygons(rect Rect2i.PositionSize, epsilon Float.X) [][]Vector2.XY

Creates an [Array] of polygons covering a rectangular portion of the bitmap. It uses a marching squares algorithm, followed by Ramer-Douglas-Peucker (RDP) reduction of the number of vertices. Each polygon is described as a [PackedVector2Array] of its vertices. To get polygons covering the whole bitmap, pass: [codeblock] Rect2(Vector2(), get_size()) [/codeblock] [param epsilon] is passed to RDP to control how accurately the polygons cover the bitmap: a lower [param epsilon] corresponds to more points in the polygons.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsBitMap

func (self *Extension[T]) AsBitMap() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.BitMap

A two-dimensional array of boolean values, can be used to efficiently store a binary matrix (every matrix element takes only one bit) and query the values using natural cartesian coordinates.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsBitMap

func (self Instance) AsBitMap() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) ConvertToImage

func (self Instance) ConvertToImage() Image.Instance

Returns an image of the same size as the bitmap and with a [enum Image.Format] of type [constant Image.FORMAT_L8]. [code]true[/code] bits of the bitmap are being converted into white pixels, and [code]false[/code] bits into black.

func (Instance) Create

func (self Instance) Create(size Vector2i.XY)

Creates a bitmap with the specified size, filled with [code]false[/code].

func (Instance) CreateFromImageAlpha

func (self Instance) CreateFromImageAlpha(image Image.Instance)

Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to [code]false[/code] if the alpha value of the image at that position is equal to [param threshold] or less, and [code]true[/code] in other case.

func (Instance) GetBit

func (self Instance) GetBit(x int, y int) bool

Returns bitmap's value at the specified position.

func (Instance) GetBitv

func (self Instance) GetBitv(position Vector2i.XY) bool

Returns bitmap's value at the specified position.

func (Instance) GetSize

func (self Instance) GetSize() Vector2i.XY

Returns bitmap's dimensions.

func (Instance) GetTrueBitCount

func (self Instance) GetTrueBitCount() int

Returns the number of bitmap elements that are set to [code]true[/code].

func (Instance) GrowMask

func (self Instance) GrowMask(pixels int, rect Rect2i.PositionSize)

Applies morphological dilation or erosion to the bitmap. If [param pixels] is positive, dilation is applied to the bitmap. If [param pixels] is negative, erosion is applied to the bitmap. [param rect] defines the area where the morphological operation is applied. Pixels located outside the [param rect] are unaffected by [method grow_mask].

func (Instance) ID

func (self Instance) ID() ID

func (Instance) OpaqueToPolygons

func (self Instance) OpaqueToPolygons(rect Rect2i.PositionSize) [][]Vector2.XY

Creates an [Array] of polygons covering a rectangular portion of the bitmap. It uses a marching squares algorithm, followed by Ramer-Douglas-Peucker (RDP) reduction of the number of vertices. Each polygon is described as a [PackedVector2Array] of its vertices. To get polygons covering the whole bitmap, pass: [codeblock] Rect2(Vector2(), get_size()) [/codeblock] [param epsilon] is passed to RDP to control how accurately the polygons cover the bitmap: a lower [param epsilon] corresponds to more points in the polygons.

func (Instance) Resize

func (self Instance) Resize(new_size Vector2i.XY)

Resizes the image to [param new_size].

func (Instance) SetBit

func (self Instance) SetBit(x int, y int, bit bool)

Sets the bitmap's element at the specified position, to the specified value.

func (Instance) SetBitRect

func (self Instance) SetBitRect(rect Rect2i.PositionSize, bit bool)

Sets a rectangular portion of the bitmap to the specified value.

func (Instance) SetBitv

func (self Instance) SetBitv(position Vector2i.XY, bit bool)

Sets the bitmap's element at the specified position, to the specified value.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

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