BitMap

package
v0.0.0-...-7325ca5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 23 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 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() [1]gdclass.Image

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 [1]gdclass.Image)

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) 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) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

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