Documentation
¶
Overview ¶
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.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AsBitMap() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) ConvertToImage() Image.Instance
- func (self Instance) Create(size Vector2i.XY)
- func (self Instance) CreateFromImageAlpha(image Image.Instance)
- func (self Instance) GetBit(x int, y int) bool
- func (self Instance) GetBitv(position Vector2i.XY) bool
- func (self Instance) GetSize() Vector2i.XY
- func (self Instance) GetTrueBitCount() int
- func (self Instance) GrowMask(pixels int, rect Rect2i.PositionSize)
- func (self Instance) ID() ID
- func (self Instance) OpaqueToPolygons(rect Rect2i.PositionSize) [][]Vector2.XY
- func (self Instance) Resize(new_size Vector2i.XY)
- func (self Instance) SetBit(x int, y int, bit bool)
- func (self Instance) SetBitRect(rect Rect2i.PositionSize, bit bool)
- func (self Instance) SetBitv(position Vector2i.XY, bit bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Virtual(name string) reflect.Value
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 Expanded ¶
func (Expanded) CreateFromImageAlpha ¶
Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to false if the alpha value of the image at that position is equal to 'threshold' or less, and true in other case.
func (Expanded) OpaqueToPolygons ¶
Creates an slice 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 [][Vector2.XY] of its vertices.
To get polygons covering the whole bitmap, pass:
var size = Rect2.PositionSize{Vector2.Zero, Vector2.From(bitmap.GetSize())}
'epsilon' is passed to RDP to control how accurately the polygons cover the bitmap: a lower 'epsilon' corresponds to more points in the polygons.
type Extension ¶
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]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type 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.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) ConvertToImage ¶
Returns an image of the same size as the bitmap and with an [Image.Format] of type [Image.FormatL8]. true bits of the bitmap are being converted into white pixels, and false bits into black.
func (Instance) CreateFromImageAlpha ¶
Creates a bitmap that matches the given image dimensions, every element of the bitmap is set to false if the alpha value of the image at that position is equal to 'threshold' or less, and true in other case.
func (Instance) GetTrueBitCount ¶
Returns the number of bitmap elements that are set to true.
func (Instance) GrowMask ¶
func (self Instance) GrowMask(pixels int, rect Rect2i.PositionSize)
Applies morphological dilation or erosion to the bitmap. If 'pixels' is positive, dilation is applied to the bitmap. If 'pixels' is negative, erosion is applied to the bitmap. 'rect' defines the area where the morphological operation is applied. Pixels located outside the 'rect' are unaffected by Instance.GrowMask.
func (Instance) OpaqueToPolygons ¶
func (self Instance) OpaqueToPolygons(rect Rect2i.PositionSize) [][]Vector2.XY
Creates an slice 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 [][Vector2.XY] of its vertices.
To get polygons covering the whole bitmap, pass:
var size = Rect2.PositionSize{Vector2.Zero, Vector2.From(bitmap.GetSize())}
'epsilon' is passed to RDP to control how accurately the polygons cover the bitmap: a lower 'epsilon' corresponds to more points in the polygons.
func (Instance) SetBit ¶
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.