BitMap.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="BitMap" inherits="Resource" version="3.6" 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 a [enum Image.Format] of type [code]FORMAT_L8[/code]. [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. <argument index="0" name="size" type="Vector2" />
  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. <argument index="0" name="image" type="Image" />
  28. <argument 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 [code]threshold[/code] 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. <argument index="0" name="position" type="Vector2" />
  36. <description>
  37. Returns bitmap's value at the specified position.
  38. </description>
  39. </method>
  40. <method name="get_size" qualifiers="const">
  41. <return type="Vector2" />
  42. <description>
  43. Returns bitmap's dimensions.
  44. </description>
  45. </method>
  46. <method name="get_true_bit_count" qualifiers="const">
  47. <return type="int" />
  48. <description>
  49. Returns the amount of bitmap elements that are set to [code]true[/code].
  50. </description>
  51. </method>
  52. <method name="grow_mask">
  53. <return type="void" />
  54. <argument index="0" name="pixels" type="int" />
  55. <argument index="1" name="rect" type="Rect2" />
  56. <description>
  57. Applies morphological dilation or erosion to the bitmap. If [code]pixels[/code] is positive, dilation is applied to the bitmap. If [code]pixels[/code] is negative, erosion is applied to the bitmap. [code]rect[/code] defines the area where the morphological operation is applied. Pixels located outside the [code]rect[/code] are unaffected by [method grow_mask].
  58. </description>
  59. </method>
  60. <method name="opaque_to_polygons" qualifiers="const">
  61. <return type="Array" />
  62. <argument index="0" name="rect" type="Rect2" />
  63. <argument index="1" name="epsilon" type="float" default="2.0" />
  64. <description>
  65. Generates polygon outlines from the opaque (non-transparent) areas of the [BitMap] using a Marching Squares algorithm.
  66. Returns an [Array] of [PoolVector2Array], where each [PoolVector2Array] represents a polygon outline. These outlines can be directly assigned to the [code]polygon[/code] property of nodes like [CollisionPolygon2D] or [OccluderPolygon2D].
  67. The [code]epsilon[/code] parameter controls polygon simplification. A lower value produces more accurate polygons, but at the cost of increased polygon size and potential performance impact. A higher value simplifies the polygons, reducing their size and improving performance, but with less accuracy.
  68. </description>
  69. </method>
  70. <method name="resize">
  71. <return type="void" />
  72. <argument index="0" name="new_size" type="Vector2" />
  73. <description>
  74. Resizes the image to [code]new_size[/code].
  75. </description>
  76. </method>
  77. <method name="set_bit">
  78. <return type="void" />
  79. <argument index="0" name="position" type="Vector2" />
  80. <argument index="1" name="bit" type="bool" />
  81. <description>
  82. Sets the bitmap's element at the specified position, to the specified value.
  83. </description>
  84. </method>
  85. <method name="set_bit_rect">
  86. <return type="void" />
  87. <argument index="0" name="rect" type="Rect2" />
  88. <argument index="1" name="bit" type="bool" />
  89. <description>
  90. Sets a rectangular portion of the bitmap to the specified value.
  91. </description>
  92. </method>
  93. </methods>
  94. <constants>
  95. </constants>
  96. </class>