2
0

BitMap.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="BitMap" inherits="Resource" version="4.0">
  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="create">
  13. <return type="void" />
  14. <argument index="0" name="size" type="Vector2" />
  15. <description>
  16. Creates a bitmap with the specified size, filled with [code]false[/code].
  17. </description>
  18. </method>
  19. <method name="create_from_image_alpha">
  20. <return type="void" />
  21. <argument index="0" name="image" type="Image" />
  22. <argument index="1" name="threshold" type="float" default="0.1" />
  23. <description>
  24. 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.
  25. </description>
  26. </method>
  27. <method name="get_bit" qualifiers="const">
  28. <return type="bool" />
  29. <argument index="0" name="position" type="Vector2" />
  30. <description>
  31. Returns bitmap's value at the specified position.
  32. </description>
  33. </method>
  34. <method name="get_size" qualifiers="const">
  35. <return type="Vector2" />
  36. <description>
  37. Returns bitmap's dimensions.
  38. </description>
  39. </method>
  40. <method name="get_true_bit_count" qualifiers="const">
  41. <return type="int" />
  42. <description>
  43. Returns the amount of bitmap elements that are set to [code]true[/code].
  44. </description>
  45. </method>
  46. <method name="grow_mask">
  47. <return type="void" />
  48. <argument index="0" name="pixels" type="int" />
  49. <argument index="1" name="rect" type="Rect2" />
  50. <description>
  51. 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].
  52. </description>
  53. </method>
  54. <method name="opaque_to_polygons" qualifiers="const">
  55. <return type="Array" />
  56. <argument index="0" name="rect" type="Rect2" />
  57. <argument index="1" name="epsilon" type="float" default="2.0" />
  58. <description>
  59. 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.
  60. To get polygons covering the whole bitmap, pass:
  61. [codeblock]
  62. Rect2(Vector2(), get_size())
  63. [/codeblock]
  64. [code]epsilon[/code] is passed to RDP to control how accurately the polygons cover the bitmap: a lower [code]epsilon[/code] corresponds to more points in the polygons.
  65. </description>
  66. </method>
  67. <method name="set_bit">
  68. <return type="void" />
  69. <argument index="0" name="position" type="Vector2" />
  70. <argument index="1" name="bit" type="bool" />
  71. <description>
  72. Sets the bitmap's element at the specified position, to the specified value.
  73. </description>
  74. </method>
  75. <method name="set_bit_rect">
  76. <return type="void" />
  77. <argument index="0" name="rect" type="Rect2" />
  78. <argument index="1" name="bit" type="bool" />
  79. <description>
  80. Sets a rectangular portion of the bitmap to the specified value.
  81. </description>
  82. </method>
  83. </methods>
  84. </class>