1 /** 2 Base class of anything 2D. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.canvasitem; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.node; 23 import godot.texture; 24 import godot.stylebox; 25 import godot.font; 26 import godot.mesh; 27 import godot.world2d; 28 import godot.material; 29 import godot.inputevent; 30 /** 31 Base class of anything 2D. 32 33 Canvas items are laid out in a tree and children inherit and extend the transform of their parent. CanvasItem is extended by $(D Control), for anything GUI related, and by $(D Node2D) for anything 2D engine related. 34 Any CanvasItem can draw. For this, the "update" function must be called, then NOTIFICATION_DRAW will be received on idle time to request redraw. Because of this, canvas items don't need to be redraw on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). They can only be used inside the notification, signal or _draw() overrides function, though. 35 Canvas items are draw in tree order. By default, children are on top of their parents so a root CanvasItem will be drawn behind everything (this can be changed per item though). 36 Canvas items can also be hidden (hiding also their subtree). They provide many means for changing standard parameters such as opacity (for it and the subtree) and self opacity, blend mode. 37 Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed. 38 */ 39 @GodotBaseClass struct CanvasItem 40 { 41 enum string _GODOT_internal_name = "CanvasItem"; 42 public: 43 @nogc nothrow: 44 union { godot_object _godot_object; Node _GODOT_base; } 45 alias _GODOT_base this; 46 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 47 package(godot) __gshared bool _classBindingInitialized = false; 48 package(godot) static struct _classBinding 49 { 50 __gshared: 51 @GodotName("_draw") GodotMethod!(void) _draw; 52 @GodotName("_toplevel_raise_self") GodotMethod!(void) _toplevelRaiseSelf; 53 @GodotName("_update_callback") GodotMethod!(void) _updateCallback; 54 @GodotName("_edit_set_state") GodotMethod!(void, Dictionary) _editSetState; 55 @GodotName("_edit_get_state") GodotMethod!(Dictionary) _editGetState; 56 @GodotName("_edit_set_position") GodotMethod!(void, Vector2) _editSetPosition; 57 @GodotName("_edit_get_position") GodotMethod!(Vector2) _editGetPosition; 58 @GodotName("_edit_set_scale") GodotMethod!(void, Vector2) _editSetScale; 59 @GodotName("_edit_get_scale") GodotMethod!(Vector2) _editGetScale; 60 @GodotName("_edit_set_rect") GodotMethod!(void, Rect2) _editSetRect; 61 @GodotName("_edit_get_rect") GodotMethod!(Rect2) _editGetRect; 62 @GodotName("_edit_use_rect") GodotMethod!(bool) _editUseRect; 63 @GodotName("_edit_set_rotation") GodotMethod!(void, double) _editSetRotation; 64 @GodotName("_edit_get_rotation") GodotMethod!(double) _editGetRotation; 65 @GodotName("_edit_use_rotation") GodotMethod!(bool) _editUseRotation; 66 @GodotName("_edit_set_pivot") GodotMethod!(void, Vector2) _editSetPivot; 67 @GodotName("_edit_get_pivot") GodotMethod!(Vector2) _editGetPivot; 68 @GodotName("_edit_use_pivot") GodotMethod!(bool) _editUsePivot; 69 @GodotName("get_canvas_item") GodotMethod!(RID) getCanvasItem; 70 @GodotName("set_visible") GodotMethod!(void, bool) setVisible; 71 @GodotName("is_visible") GodotMethod!(bool) isVisible; 72 @GodotName("is_visible_in_tree") GodotMethod!(bool) isVisibleInTree; 73 @GodotName("show") GodotMethod!(void) show; 74 @GodotName("hide") GodotMethod!(void) hide; 75 @GodotName("update") GodotMethod!(void) update; 76 @GodotName("set_as_toplevel") GodotMethod!(void, bool) setAsToplevel; 77 @GodotName("is_set_as_toplevel") GodotMethod!(bool) isSetAsToplevel; 78 @GodotName("set_light_mask") GodotMethod!(void, long) setLightMask; 79 @GodotName("get_light_mask") GodotMethod!(long) getLightMask; 80 @GodotName("set_modulate") GodotMethod!(void, Color) setModulate; 81 @GodotName("get_modulate") GodotMethod!(Color) getModulate; 82 @GodotName("set_self_modulate") GodotMethod!(void, Color) setSelfModulate; 83 @GodotName("get_self_modulate") GodotMethod!(Color) getSelfModulate; 84 @GodotName("set_draw_behind_parent") GodotMethod!(void, bool) setDrawBehindParent; 85 @GodotName("is_draw_behind_parent_enabled") GodotMethod!(bool) isDrawBehindParentEnabled; 86 @GodotName("_set_on_top") GodotMethod!(void, bool) _setOnTop; 87 @GodotName("_is_on_top") GodotMethod!(bool) _isOnTop; 88 @GodotName("draw_line") GodotMethod!(void, Vector2, Vector2, Color, double, bool) drawLine; 89 @GodotName("draw_polyline") GodotMethod!(void, PoolVector2Array, Color, double, bool) drawPolyline; 90 @GodotName("draw_polyline_colors") GodotMethod!(void, PoolVector2Array, PoolColorArray, double, bool) drawPolylineColors; 91 @GodotName("draw_multiline") GodotMethod!(void, PoolVector2Array, Color, double, bool) drawMultiline; 92 @GodotName("draw_multiline_colors") GodotMethod!(void, PoolVector2Array, PoolColorArray, double, bool) drawMultilineColors; 93 @GodotName("draw_rect") GodotMethod!(void, Rect2, Color, bool) drawRect; 94 @GodotName("draw_circle") GodotMethod!(void, Vector2, double, Color) drawCircle; 95 @GodotName("draw_texture") GodotMethod!(void, Texture, Vector2, Color, Texture) drawTexture; 96 @GodotName("draw_texture_rect") GodotMethod!(void, Texture, Rect2, bool, Color, bool, Texture) drawTextureRect; 97 @GodotName("draw_texture_rect_region") GodotMethod!(void, Texture, Rect2, Rect2, Color, bool, Texture, bool) drawTextureRectRegion; 98 @GodotName("draw_style_box") GodotMethod!(void, StyleBox, Rect2) drawStyleBox; 99 @GodotName("draw_primitive") GodotMethod!(void, PoolVector2Array, PoolColorArray, PoolVector2Array, Texture, double, Texture) drawPrimitive; 100 @GodotName("draw_polygon") GodotMethod!(void, PoolVector2Array, PoolColorArray, PoolVector2Array, Texture, Texture, bool) drawPolygon; 101 @GodotName("draw_colored_polygon") GodotMethod!(void, PoolVector2Array, Color, PoolVector2Array, Texture, Texture, bool) drawColoredPolygon; 102 @GodotName("draw_string") GodotMethod!(void, Font, Vector2, String, Color, long) drawString; 103 @GodotName("draw_char") GodotMethod!(double, Font, Vector2, String, String, Color) drawChar; 104 @GodotName("draw_mesh") GodotMethod!(void, Mesh, Texture, Texture) drawMesh; 105 @GodotName("draw_multimesh") GodotMethod!(void, Mesh, Texture, Texture) drawMultimesh; 106 @GodotName("draw_set_transform") GodotMethod!(void, Vector2, double, Vector2) drawSetTransform; 107 @GodotName("draw_set_transform_matrix") GodotMethod!(void, Transform2D) drawSetTransformMatrix; 108 @GodotName("get_transform") GodotMethod!(Transform2D) getTransform; 109 @GodotName("get_global_transform") GodotMethod!(Transform2D) getGlobalTransform; 110 @GodotName("get_global_transform_with_canvas") GodotMethod!(Transform2D) getGlobalTransformWithCanvas; 111 @GodotName("get_viewport_transform") GodotMethod!(Transform2D) getViewportTransform; 112 @GodotName("get_viewport_rect") GodotMethod!(Rect2) getViewportRect; 113 @GodotName("get_canvas_transform") GodotMethod!(Transform2D) getCanvasTransform; 114 @GodotName("get_local_mouse_position") GodotMethod!(Vector2) getLocalMousePosition; 115 @GodotName("get_global_mouse_position") GodotMethod!(Vector2) getGlobalMousePosition; 116 @GodotName("get_canvas") GodotMethod!(RID) getCanvas; 117 @GodotName("get_world_2d") GodotMethod!(World2D) getWorld2d; 118 @GodotName("set_material") GodotMethod!(void, Material) setMaterial; 119 @GodotName("get_material") GodotMethod!(Material) getMaterial; 120 @GodotName("set_use_parent_material") GodotMethod!(void, bool) setUseParentMaterial; 121 @GodotName("get_use_parent_material") GodotMethod!(bool) getUseParentMaterial; 122 @GodotName("set_notify_local_transform") GodotMethod!(void, bool) setNotifyLocalTransform; 123 @GodotName("is_local_transform_notification_enabled") GodotMethod!(bool) isLocalTransformNotificationEnabled; 124 @GodotName("set_notify_transform") GodotMethod!(void, bool) setNotifyTransform; 125 @GodotName("is_transform_notification_enabled") GodotMethod!(bool) isTransformNotificationEnabled; 126 @GodotName("force_update_transform") GodotMethod!(void) forceUpdateTransform; 127 @GodotName("make_canvas_position_local") GodotMethod!(Vector2, Vector2) makeCanvasPositionLocal; 128 @GodotName("make_input_local") GodotMethod!(InputEvent, InputEvent) makeInputLocal; 129 } 130 bool opEquals(in CanvasItem other) const { return _godot_object.ptr is other._godot_object.ptr; } 131 CanvasItem opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 132 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 133 mixin baseCasts; 134 static CanvasItem _new() 135 { 136 static godot_class_constructor constructor; 137 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CanvasItem"); 138 if(constructor is null) return typeof(this).init; 139 return cast(CanvasItem)(constructor()); 140 } 141 @disable new(size_t s); 142 /// 143 enum BlendMode : int 144 { 145 /** 146 Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value. 147 */ 148 blendModeMix = 0, 149 /** 150 Additive blending mode. 151 */ 152 blendModeAdd = 1, 153 /** 154 Subtractive blending mode. 155 */ 156 blendModeSub = 2, 157 /** 158 Multiplicative blending mode. 159 */ 160 blendModeMul = 3, 161 /** 162 Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value. 163 */ 164 blendModePremultAlpha = 4, 165 /** 166 Disable blending mode. Colors including alpha are written as is. Only applicable for render targets with a transparent background. No lighting will be applied. 167 */ 168 blendModeDisabled = 5, 169 } 170 /// 171 enum Constants : int 172 { 173 blendModeMix = 0, 174 blendModeAdd = 1, 175 blendModeSub = 2, 176 blendModeMul = 3, 177 blendModePremultAlpha = 4, 178 blendModeDisabled = 5, 179 /** 180 Canvas item transform has changed. Notification is only received if enabled by $(D setNotifyTransform) or $(D setNotifyLocalTransform). 181 */ 182 notificationTransformChanged = 29, 183 /** 184 CanvasItem is requested to draw. 185 */ 186 notificationDraw = 30, 187 /** 188 Canvas item visibility has changed. 189 */ 190 notificationVisibilityChanged = 31, 191 /** 192 Canvas item has entered the canvas. 193 */ 194 notificationEnterCanvas = 32, 195 /** 196 Canvas item has exited the canvas. 197 */ 198 notificationExitCanvas = 33, 199 } 200 /** 201 Called (if exists) to draw the canvas item. 202 */ 203 void _draw() 204 { 205 Array _GODOT_args = Array.empty_array; 206 String _GODOT_method_name = String("_draw"); 207 this.callv(_GODOT_method_name, _GODOT_args); 208 } 209 /** 210 211 */ 212 void _toplevelRaiseSelf() 213 { 214 Array _GODOT_args = Array.empty_array; 215 String _GODOT_method_name = String("_toplevel_raise_self"); 216 this.callv(_GODOT_method_name, _GODOT_args); 217 } 218 /** 219 220 */ 221 void _updateCallback() 222 { 223 Array _GODOT_args = Array.empty_array; 224 String _GODOT_method_name = String("_update_callback"); 225 this.callv(_GODOT_method_name, _GODOT_args); 226 } 227 /** 228 229 */ 230 void _editSetState(in Dictionary state) 231 { 232 Array _GODOT_args = Array.empty_array; 233 _GODOT_args.append(state); 234 String _GODOT_method_name = String("_edit_set_state"); 235 this.callv(_GODOT_method_name, _GODOT_args); 236 } 237 /** 238 239 */ 240 Dictionary _editGetState() const 241 { 242 Array _GODOT_args = Array.empty_array; 243 String _GODOT_method_name = String("_edit_get_state"); 244 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Dictionary); 245 } 246 /** 247 248 */ 249 void _editSetPosition(in Vector2 position) 250 { 251 Array _GODOT_args = Array.empty_array; 252 _GODOT_args.append(position); 253 String _GODOT_method_name = String("_edit_set_position"); 254 this.callv(_GODOT_method_name, _GODOT_args); 255 } 256 /** 257 258 */ 259 Vector2 _editGetPosition() const 260 { 261 Array _GODOT_args = Array.empty_array; 262 String _GODOT_method_name = String("_edit_get_position"); 263 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Vector2); 264 } 265 /** 266 267 */ 268 void _editSetScale(in Vector2 scale) 269 { 270 Array _GODOT_args = Array.empty_array; 271 _GODOT_args.append(scale); 272 String _GODOT_method_name = String("_edit_set_scale"); 273 this.callv(_GODOT_method_name, _GODOT_args); 274 } 275 /** 276 277 */ 278 Vector2 _editGetScale() const 279 { 280 Array _GODOT_args = Array.empty_array; 281 String _GODOT_method_name = String("_edit_get_scale"); 282 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Vector2); 283 } 284 /** 285 286 */ 287 void _editSetRect(in Rect2 rect) 288 { 289 Array _GODOT_args = Array.empty_array; 290 _GODOT_args.append(rect); 291 String _GODOT_method_name = String("_edit_set_rect"); 292 this.callv(_GODOT_method_name, _GODOT_args); 293 } 294 /** 295 296 */ 297 Rect2 _editGetRect() const 298 { 299 Array _GODOT_args = Array.empty_array; 300 String _GODOT_method_name = String("_edit_get_rect"); 301 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Rect2); 302 } 303 /** 304 305 */ 306 bool _editUseRect() const 307 { 308 Array _GODOT_args = Array.empty_array; 309 String _GODOT_method_name = String("_edit_use_rect"); 310 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 311 } 312 /** 313 314 */ 315 void _editSetRotation(in double degrees) 316 { 317 Array _GODOT_args = Array.empty_array; 318 _GODOT_args.append(degrees); 319 String _GODOT_method_name = String("_edit_set_rotation"); 320 this.callv(_GODOT_method_name, _GODOT_args); 321 } 322 /** 323 324 */ 325 double _editGetRotation() const 326 { 327 Array _GODOT_args = Array.empty_array; 328 String _GODOT_method_name = String("_edit_get_rotation"); 329 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double); 330 } 331 /** 332 333 */ 334 bool _editUseRotation() const 335 { 336 Array _GODOT_args = Array.empty_array; 337 String _GODOT_method_name = String("_edit_use_rotation"); 338 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 339 } 340 /** 341 342 */ 343 void _editSetPivot(in Vector2 pivot) 344 { 345 Array _GODOT_args = Array.empty_array; 346 _GODOT_args.append(pivot); 347 String _GODOT_method_name = String("_edit_set_pivot"); 348 this.callv(_GODOT_method_name, _GODOT_args); 349 } 350 /** 351 352 */ 353 Vector2 _editGetPivot() const 354 { 355 Array _GODOT_args = Array.empty_array; 356 String _GODOT_method_name = String("_edit_get_pivot"); 357 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Vector2); 358 } 359 /** 360 361 */ 362 bool _editUsePivot() const 363 { 364 Array _GODOT_args = Array.empty_array; 365 String _GODOT_method_name = String("_edit_use_pivot"); 366 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 367 } 368 /** 369 Return the canvas item RID used by $(D VisualServer) for this item. 370 */ 371 RID getCanvasItem() const 372 { 373 checkClassBinding!(typeof(this))(); 374 return ptrcall!(RID)(_classBinding.getCanvasItem, _godot_object); 375 } 376 /** 377 378 */ 379 void setVisible(in bool visible) 380 { 381 checkClassBinding!(typeof(this))(); 382 ptrcall!(void)(_classBinding.setVisible, _godot_object, visible); 383 } 384 /** 385 386 */ 387 bool isVisible() const 388 { 389 checkClassBinding!(typeof(this))(); 390 return ptrcall!(bool)(_classBinding.isVisible, _godot_object); 391 } 392 /** 393 Returns `true` if the node is present in the $(D SceneTree), its $(D visible) property is `true` and its inherited visibility is also `true`. 394 */ 395 bool isVisibleInTree() const 396 { 397 checkClassBinding!(typeof(this))(); 398 return ptrcall!(bool)(_classBinding.isVisibleInTree, _godot_object); 399 } 400 /** 401 Show the CanvasItem currently hidden. 402 */ 403 void show() 404 { 405 checkClassBinding!(typeof(this))(); 406 ptrcall!(void)(_classBinding.show, _godot_object); 407 } 408 /** 409 Hide the CanvasItem currently visible. 410 */ 411 void hide() 412 { 413 checkClassBinding!(typeof(this))(); 414 ptrcall!(void)(_classBinding.hide, _godot_object); 415 } 416 /** 417 Queue the CanvasItem for update. `NOTIFICATION_DRAW` will be called on idle time to request redraw. 418 */ 419 void update() 420 { 421 checkClassBinding!(typeof(this))(); 422 ptrcall!(void)(_classBinding.update, _godot_object); 423 } 424 /** 425 Sets as top level. This means that it will not inherit transform from parent canvas items. 426 */ 427 void setAsToplevel(in bool enable) 428 { 429 checkClassBinding!(typeof(this))(); 430 ptrcall!(void)(_classBinding.setAsToplevel, _godot_object, enable); 431 } 432 /** 433 Return if set as toplevel. See $(D setAsToplevel). 434 */ 435 bool isSetAsToplevel() const 436 { 437 checkClassBinding!(typeof(this))(); 438 return ptrcall!(bool)(_classBinding.isSetAsToplevel, _godot_object); 439 } 440 /** 441 442 */ 443 void setLightMask(in long light_mask) 444 { 445 checkClassBinding!(typeof(this))(); 446 ptrcall!(void)(_classBinding.setLightMask, _godot_object, light_mask); 447 } 448 /** 449 450 */ 451 long getLightMask() const 452 { 453 checkClassBinding!(typeof(this))(); 454 return ptrcall!(long)(_classBinding.getLightMask, _godot_object); 455 } 456 /** 457 458 */ 459 void setModulate(in Color modulate) 460 { 461 checkClassBinding!(typeof(this))(); 462 ptrcall!(void)(_classBinding.setModulate, _godot_object, modulate); 463 } 464 /** 465 466 */ 467 Color getModulate() const 468 { 469 checkClassBinding!(typeof(this))(); 470 return ptrcall!(Color)(_classBinding.getModulate, _godot_object); 471 } 472 /** 473 474 */ 475 void setSelfModulate(in Color self_modulate) 476 { 477 checkClassBinding!(typeof(this))(); 478 ptrcall!(void)(_classBinding.setSelfModulate, _godot_object, self_modulate); 479 } 480 /** 481 482 */ 483 Color getSelfModulate() const 484 { 485 checkClassBinding!(typeof(this))(); 486 return ptrcall!(Color)(_classBinding.getSelfModulate, _godot_object); 487 } 488 /** 489 490 */ 491 void setDrawBehindParent(in bool enable) 492 { 493 checkClassBinding!(typeof(this))(); 494 ptrcall!(void)(_classBinding.setDrawBehindParent, _godot_object, enable); 495 } 496 /** 497 498 */ 499 bool isDrawBehindParentEnabled() const 500 { 501 checkClassBinding!(typeof(this))(); 502 return ptrcall!(bool)(_classBinding.isDrawBehindParentEnabled, _godot_object); 503 } 504 /** 505 506 */ 507 void _setOnTop(in bool on_top) 508 { 509 Array _GODOT_args = Array.empty_array; 510 _GODOT_args.append(on_top); 511 String _GODOT_method_name = String("_set_on_top"); 512 this.callv(_GODOT_method_name, _GODOT_args); 513 } 514 /** 515 516 */ 517 bool _isOnTop() const 518 { 519 Array _GODOT_args = Array.empty_array; 520 String _GODOT_method_name = String("_is_on_top"); 521 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 522 } 523 /** 524 Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. 525 */ 526 void drawLine(in Vector2 from, in Vector2 to, in Color color, in double width = 1, in bool antialiased = false) 527 { 528 checkClassBinding!(typeof(this))(); 529 ptrcall!(void)(_classBinding.drawLine, _godot_object, from, to, color, width, antialiased); 530 } 531 /** 532 Draws interconnected line segments with a uniform `color` and `width` and optional antialiasing. 533 */ 534 void drawPolyline(in PoolVector2Array points, in Color color, in double width = 1, in bool antialiased = false) 535 { 536 checkClassBinding!(typeof(this))(); 537 ptrcall!(void)(_classBinding.drawPolyline, _godot_object, points, color, width, antialiased); 538 } 539 /** 540 Draws interconnected line segments with a uniform `width`, segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between `points` and `colors`. 541 */ 542 void drawPolylineColors(in PoolVector2Array points, in PoolColorArray colors, in double width = 1, in bool antialiased = false) 543 { 544 checkClassBinding!(typeof(this))(); 545 ptrcall!(void)(_classBinding.drawPolylineColors, _godot_object, points, colors, width, antialiased); 546 } 547 /** 548 Draws multiple, parallel lines with a uniform `color` and `width` and optional antialiasing. 549 */ 550 void drawMultiline(in PoolVector2Array points, in Color color, in double width = 1, in bool antialiased = false) 551 { 552 checkClassBinding!(typeof(this))(); 553 ptrcall!(void)(_classBinding.drawMultiline, _godot_object, points, color, width, antialiased); 554 } 555 /** 556 Draws multiple, parallel lines with a uniform `width`, segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between `points` and `colors`. 557 */ 558 void drawMultilineColors(in PoolVector2Array points, in PoolColorArray colors, in double width = 1, in bool antialiased = false) 559 { 560 checkClassBinding!(typeof(this))(); 561 ptrcall!(void)(_classBinding.drawMultilineColors, _godot_object, points, colors, width, antialiased); 562 } 563 /** 564 Draws a colored rectangle. 565 */ 566 void drawRect(in Rect2 rect, in Color color, in bool filled = true) 567 { 568 checkClassBinding!(typeof(this))(); 569 ptrcall!(void)(_classBinding.drawRect, _godot_object, rect, color, filled); 570 } 571 /** 572 Draws a colored circle. 573 */ 574 void drawCircle(in Vector2 position, in double radius, in Color color) 575 { 576 checkClassBinding!(typeof(this))(); 577 ptrcall!(void)(_classBinding.drawCircle, _godot_object, position, radius, color); 578 } 579 /** 580 Draws a texture at a given position. 581 */ 582 void drawTexture(Texture texture, in Vector2 position, in Color modulate = Color(1,1,1,1), Texture normal_map = Texture.init) 583 { 584 checkClassBinding!(typeof(this))(); 585 ptrcall!(void)(_classBinding.drawTexture, _godot_object, texture, position, modulate, normal_map); 586 } 587 /** 588 Draws a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture. 589 */ 590 void drawTextureRect(Texture texture, in Rect2 rect, in bool tile, in Color modulate = Color(1,1,1,1), in bool transpose = false, Texture normal_map = Texture.init) 591 { 592 checkClassBinding!(typeof(this))(); 593 ptrcall!(void)(_classBinding.drawTextureRect, _godot_object, texture, rect, tile, modulate, transpose, normal_map); 594 } 595 /** 596 Draws a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture. 597 */ 598 void drawTextureRectRegion(Texture texture, in Rect2 rect, in Rect2 src_rect, in Color modulate = Color(1,1,1,1), in bool transpose = false, Texture normal_map = Texture.init, in bool clip_uv = true) 599 { 600 checkClassBinding!(typeof(this))(); 601 ptrcall!(void)(_classBinding.drawTextureRectRegion, _godot_object, texture, rect, src_rect, modulate, transpose, normal_map, clip_uv); 602 } 603 /** 604 Draws a styled rectangle. 605 */ 606 void drawStyleBox(StyleBox style_box, in Rect2 rect) 607 { 608 checkClassBinding!(typeof(this))(); 609 ptrcall!(void)(_classBinding.drawStyleBox, _godot_object, style_box, rect); 610 } 611 /** 612 Draws a custom primitive, 1 point for a point, 2 points for a line, 3 points for a triangle and 4 points for a quad. 613 */ 614 void drawPrimitive(in PoolVector2Array points, in PoolColorArray colors, in PoolVector2Array uvs, Texture texture = Texture.init, in double width = 1, Texture normal_map = Texture.init) 615 { 616 checkClassBinding!(typeof(this))(); 617 ptrcall!(void)(_classBinding.drawPrimitive, _godot_object, points, colors, uvs, texture, width, normal_map); 618 } 619 /** 620 Draws a polygon of any amount of points, convex or concave. 621 */ 622 void drawPolygon(in PoolVector2Array points, in PoolColorArray colors, in PoolVector2Array uvs = PoolVector2Array.init, Texture texture = Texture.init, Texture normal_map = Texture.init, in bool antialiased = false) 623 { 624 checkClassBinding!(typeof(this))(); 625 ptrcall!(void)(_classBinding.drawPolygon, _godot_object, points, colors, uvs, texture, normal_map, antialiased); 626 } 627 /** 628 Draws a colored polygon of any amount of points, convex or concave. 629 */ 630 void drawColoredPolygon(in PoolVector2Array points, in Color color, in PoolVector2Array uvs = PoolVector2Array.init, Texture texture = Texture.init, Texture normal_map = Texture.init, in bool antialiased = false) 631 { 632 checkClassBinding!(typeof(this))(); 633 ptrcall!(void)(_classBinding.drawColoredPolygon, _godot_object, points, color, uvs, texture, normal_map, antialiased); 634 } 635 /** 636 Draws a string using a custom font. 637 */ 638 void drawString(StringArg2)(Font font, in Vector2 position, in StringArg2 text, in Color modulate = Color(1,1,1,1), in long clip_w = -1) 639 { 640 checkClassBinding!(typeof(this))(); 641 ptrcall!(void)(_classBinding.drawString, _godot_object, font, position, text, modulate, clip_w); 642 } 643 /** 644 Draws a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char. 645 */ 646 double drawChar(StringArg2, StringArg3)(Font font, in Vector2 position, in StringArg2 _char, in StringArg3 next, in Color modulate = Color(1,1,1,1)) 647 { 648 checkClassBinding!(typeof(this))(); 649 return ptrcall!(double)(_classBinding.drawChar, _godot_object, font, position, _char, next, modulate); 650 } 651 /** 652 653 */ 654 void drawMesh(Mesh mesh, Texture texture, Texture normal_map = Texture.init) 655 { 656 checkClassBinding!(typeof(this))(); 657 ptrcall!(void)(_classBinding.drawMesh, _godot_object, mesh, texture, normal_map); 658 } 659 /** 660 661 */ 662 void drawMultimesh(Mesh mesh, Texture texture, Texture normal_map = Texture.init) 663 { 664 checkClassBinding!(typeof(this))(); 665 ptrcall!(void)(_classBinding.drawMultimesh, _godot_object, mesh, texture, normal_map); 666 } 667 /** 668 Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. 669 */ 670 void drawSetTransform(in Vector2 position, in double rotation, in Vector2 scale) 671 { 672 checkClassBinding!(typeof(this))(); 673 ptrcall!(void)(_classBinding.drawSetTransform, _godot_object, position, rotation, scale); 674 } 675 /** 676 Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this. 677 */ 678 void drawSetTransformMatrix(in Transform2D xform) 679 { 680 checkClassBinding!(typeof(this))(); 681 ptrcall!(void)(_classBinding.drawSetTransformMatrix, _godot_object, xform); 682 } 683 /** 684 Get the transform matrix of this item. 685 */ 686 Transform2D getTransform() const 687 { 688 checkClassBinding!(typeof(this))(); 689 return ptrcall!(Transform2D)(_classBinding.getTransform, _godot_object); 690 } 691 /** 692 Get the global transform matrix of this item. 693 */ 694 Transform2D getGlobalTransform() const 695 { 696 checkClassBinding!(typeof(this))(); 697 return ptrcall!(Transform2D)(_classBinding.getGlobalTransform, _godot_object); 698 } 699 /** 700 Get the global transform matrix of this item in relation to the canvas. 701 */ 702 Transform2D getGlobalTransformWithCanvas() const 703 { 704 checkClassBinding!(typeof(this))(); 705 return ptrcall!(Transform2D)(_classBinding.getGlobalTransformWithCanvas, _godot_object); 706 } 707 /** 708 Get this item's transform in relation to the viewport. 709 */ 710 Transform2D getViewportTransform() const 711 { 712 checkClassBinding!(typeof(this))(); 713 return ptrcall!(Transform2D)(_classBinding.getViewportTransform, _godot_object); 714 } 715 /** 716 Get the viewport's boundaries as a $(D Rect2). 717 */ 718 Rect2 getViewportRect() const 719 { 720 checkClassBinding!(typeof(this))(); 721 return ptrcall!(Rect2)(_classBinding.getViewportRect, _godot_object); 722 } 723 /** 724 Get the transform matrix of this item's canvas. 725 */ 726 Transform2D getCanvasTransform() const 727 { 728 checkClassBinding!(typeof(this))(); 729 return ptrcall!(Transform2D)(_classBinding.getCanvasTransform, _godot_object); 730 } 731 /** 732 Get the mouse position relative to this item's position. 733 */ 734 Vector2 getLocalMousePosition() const 735 { 736 checkClassBinding!(typeof(this))(); 737 return ptrcall!(Vector2)(_classBinding.getLocalMousePosition, _godot_object); 738 } 739 /** 740 Get the global position of the mouse. 741 */ 742 Vector2 getGlobalMousePosition() const 743 { 744 checkClassBinding!(typeof(this))(); 745 return ptrcall!(Vector2)(_classBinding.getGlobalMousePosition, _godot_object); 746 } 747 /** 748 Return the $(D RID) of the $(D World2D) canvas where this item is in. 749 */ 750 RID getCanvas() const 751 { 752 checkClassBinding!(typeof(this))(); 753 return ptrcall!(RID)(_classBinding.getCanvas, _godot_object); 754 } 755 /** 756 Get the $(D World2D) where this item is in. 757 */ 758 Ref!World2D getWorld2d() const 759 { 760 checkClassBinding!(typeof(this))(); 761 return ptrcall!(World2D)(_classBinding.getWorld2d, _godot_object); 762 } 763 /** 764 765 */ 766 void setMaterial(Material material) 767 { 768 checkClassBinding!(typeof(this))(); 769 ptrcall!(void)(_classBinding.setMaterial, _godot_object, material); 770 } 771 /** 772 773 */ 774 Ref!Material getMaterial() const 775 { 776 checkClassBinding!(typeof(this))(); 777 return ptrcall!(Material)(_classBinding.getMaterial, _godot_object); 778 } 779 /** 780 781 */ 782 void setUseParentMaterial(in bool enable) 783 { 784 checkClassBinding!(typeof(this))(); 785 ptrcall!(void)(_classBinding.setUseParentMaterial, _godot_object, enable); 786 } 787 /** 788 789 */ 790 bool getUseParentMaterial() const 791 { 792 checkClassBinding!(typeof(this))(); 793 return ptrcall!(bool)(_classBinding.getUseParentMaterial, _godot_object); 794 } 795 /** 796 If `enable` is `true`, children will be updated with local transform data. 797 */ 798 void setNotifyLocalTransform(in bool enable) 799 { 800 checkClassBinding!(typeof(this))(); 801 ptrcall!(void)(_classBinding.setNotifyLocalTransform, _godot_object, enable); 802 } 803 /** 804 Returns `true` if local transform notifications are communicated to children. 805 */ 806 bool isLocalTransformNotificationEnabled() const 807 { 808 checkClassBinding!(typeof(this))(); 809 return ptrcall!(bool)(_classBinding.isLocalTransformNotificationEnabled, _godot_object); 810 } 811 /** 812 If `enable` is `true`, children will be updated with global transform data. 813 */ 814 void setNotifyTransform(in bool enable) 815 { 816 checkClassBinding!(typeof(this))(); 817 ptrcall!(void)(_classBinding.setNotifyTransform, _godot_object, enable); 818 } 819 /** 820 Returns `true` if global transform notifications are communicated to children. 821 */ 822 bool isTransformNotificationEnabled() const 823 { 824 checkClassBinding!(typeof(this))(); 825 return ptrcall!(bool)(_classBinding.isTransformNotificationEnabled, _godot_object); 826 } 827 /** 828 829 */ 830 void forceUpdateTransform() 831 { 832 checkClassBinding!(typeof(this))(); 833 ptrcall!(void)(_classBinding.forceUpdateTransform, _godot_object); 834 } 835 /** 836 Assigns `screen_point` as this node's new local transform. 837 */ 838 Vector2 makeCanvasPositionLocal(in Vector2 screen_point) const 839 { 840 checkClassBinding!(typeof(this))(); 841 return ptrcall!(Vector2)(_classBinding.makeCanvasPositionLocal, _godot_object, screen_point); 842 } 843 /** 844 Transformations issued by `event`'s inputs are applied in local space instead of global space. 845 */ 846 Ref!InputEvent makeInputLocal(InputEvent event) const 847 { 848 checkClassBinding!(typeof(this))(); 849 return ptrcall!(InputEvent)(_classBinding.makeInputLocal, _godot_object, event); 850 } 851 /** 852 If `true` this `CanvasItem` is drawn. Default value: `true`. 853 */ 854 @property bool visible() 855 { 856 return isVisible(); 857 } 858 /// ditto 859 @property void visible(bool v) 860 { 861 setVisible(v); 862 } 863 /** 864 The color applied to textures on this `CanvasItem`. Default value: `Color(1, 1, 1, 1)` (opaque "white"). 865 */ 866 @property Color modulate() 867 { 868 return getModulate(); 869 } 870 /// ditto 871 @property void modulate(Color v) 872 { 873 setModulate(v); 874 } 875 /** 876 The color applied to textures on this `CanvasItem`. This is not inherited by children `CanvasItem`s. Default value: `Color(1, 1, 1, 1)` (opaque "white").. 877 */ 878 @property Color selfModulate() 879 { 880 return getSelfModulate(); 881 } 882 /// ditto 883 @property void selfModulate(Color v) 884 { 885 setSelfModulate(v); 886 } 887 /** 888 If `true` the object draws behind its parent. Default value: `false`. 889 */ 890 @property bool showBehindParent() 891 { 892 return isDrawBehindParentEnabled(); 893 } 894 /// ditto 895 @property void showBehindParent(bool v) 896 { 897 setDrawBehindParent(v); 898 } 899 /** 900 If `true` the object draws on top of its parent. Default value: `true`. 901 */ 902 @property bool showOnTop() 903 { 904 return _isOnTop(); 905 } 906 /// ditto 907 @property void showOnTop(bool v) 908 { 909 _setOnTop(v); 910 } 911 /** 912 The rendering layers in which this `CanvasItem` responds to $(D Light2D) nodes. Default value: `1`. 913 */ 914 @property long lightMask() 915 { 916 return getLightMask(); 917 } 918 /// ditto 919 @property void lightMask(long v) 920 { 921 setLightMask(v); 922 } 923 /** 924 If `true` the parent `CanvasItem`'s $(D material) property is used as this one's material. Default value: `false`. 925 */ 926 @property bool useParentMaterial() 927 { 928 return getUseParentMaterial(); 929 } 930 /// ditto 931 @property void useParentMaterial(bool v) 932 { 933 setUseParentMaterial(v); 934 } 935 }