Skip to content
0.2.0-dev Download ZIP
114 lines ·4.7 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="BitMap" inherits="Resource" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Boolean matrix.
5 </brief_description>
6 <description>
7 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.
8 </description>
9 <tutorials>
10 </tutorials>
11 <methods>
12 <method name="convert_to_image" qualifiers="const">
13 <return type="Image" />
14 <description>
15 Returns an image of the same size as the bitmap and with an [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.
16 </description>
17 </method>
18 <method name="create">
19 <return type="void" />
20 <param index="0" name="size" type="Vector2i" />
21 <description>
22 Creates a bitmap with the specified size, filled with [code]false[/code].
23 </description>
24 </method>
25 <method name="create_from_image_alpha">
26 <return type="void" />
27 <param index="0" name="image" type="Image" />
28 <param index="1" name="threshold" type="float" default="0.1" />
29 <description>
30 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.
31 </description>
32 </method>
33 <method name="get_bit" qualifiers="const">
34 <return type="bool" />
35 <param index="0" name="x" type="int" />
36 <param index="1" name="y" type="int" />
37 <description>
38 Returns bitmap's value at the specified position.
39 </description>
40 </method>
41 <method name="get_bitv" qualifiers="const">
42 <return type="bool" />
43 <param index="0" name="position" type="Vector2i" />
44 <description>
45 Returns bitmap's value at the specified position.
46 </description>
47 </method>
48 <method name="get_size" qualifiers="const">
49 <return type="Vector2i" />
50 <description>
51 Returns bitmap's dimensions.
52 </description>
53 </method>
54 <method name="get_true_bit_count" qualifiers="const">
55 <return type="int" />
56 <description>
57 Returns the number of bitmap elements that are set to [code]true[/code].
58 </description>
59 </method>
60 <method name="grow_mask">
61 <return type="void" />
62 <param index="0" name="pixels" type="int" />
63 <param index="1" name="rect" type="Rect2i" />
64 <description>
65 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].
66 </description>
67 </method>
68 <method name="opaque_to_polygons" qualifiers="const">
69 <return type="PackedVector2Array[]" />
70 <param index="0" name="rect" type="Rect2i" />
71 <param index="1" name="epsilon" type="float" default="2.0" />
72 <description>
73 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.
74 To get polygons covering the whole bitmap, pass:
75 [codeblock]
76 Rect2(Vector2(), get_size())
77 [/codeblock]
78 [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.
79 </description>
80 </method>
81 <method name="resize">
82 <return type="void" />
83 <param index="0" name="new_size" type="Vector2i" />
84 <description>
85 Resizes the image to [param new_size].
86 </description>
87 </method>
88 <method name="set_bit">
89 <return type="void" />
90 <param index="0" name="x" type="int" />
91 <param index="1" name="y" type="int" />
92 <param index="2" name="bit" type="bool" />
93 <description>
94 Sets the bitmap's element at the specified position, to the specified value.
95 </description>
96 </method>
97 <method name="set_bit_rect">
98 <return type="void" />
99 <param index="0" name="rect" type="Rect2i" />
100 <param index="1" name="bit" type="bool" />
101 <description>
102 Sets a rectangular portion of the bitmap to the specified value.
103 </description>
104 </method>
105 <method name="set_bitv">
106 <return type="void" />
107 <param index="0" name="position" type="Vector2i" />
108 <param index="1" name="bit" type="bool" />
109 <description>
110 Sets the bitmap's element at the specified position, to the specified value.
111 </description>
112 </method>
113 </methods>
114</class>