1 /** 2 A 2D line. 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.line2d; 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.classdb; 23 import godot.node2d; 24 import godot.gradient; 25 import godot.texture; 26 import godot.canvasitem; 27 import godot.node; 28 /** 29 A 2D line. 30 31 A line through several points in 2D space. 32 */ 33 @GodotBaseClass struct Line2D 34 { 35 enum string _GODOT_internal_name = "Line2D"; 36 public: 37 @nogc nothrow: 38 union { godot_object _godot_object; Node2D _GODOT_base; } 39 alias _GODOT_base this; 40 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 41 package(godot) __gshared bool _classBindingInitialized = false; 42 package(godot) static struct _classBinding 43 { 44 __gshared: 45 @GodotName("set_points") GodotMethod!(void, PoolVector2Array) setPoints; 46 @GodotName("get_points") GodotMethod!(PoolVector2Array) getPoints; 47 @GodotName("set_point_position") GodotMethod!(void, long, Vector2) setPointPosition; 48 @GodotName("get_point_position") GodotMethod!(Vector2, long) getPointPosition; 49 @GodotName("get_point_count") GodotMethod!(long) getPointCount; 50 @GodotName("add_point") GodotMethod!(void, Vector2) addPoint; 51 @GodotName("remove_point") GodotMethod!(void, long) removePoint; 52 @GodotName("set_width") GodotMethod!(void, double) setWidth; 53 @GodotName("get_width") GodotMethod!(double) getWidth; 54 @GodotName("set_default_color") GodotMethod!(void, Color) setDefaultColor; 55 @GodotName("get_default_color") GodotMethod!(Color) getDefaultColor; 56 @GodotName("set_gradient") GodotMethod!(void, Gradient) setGradient; 57 @GodotName("get_gradient") GodotMethod!(Gradient) getGradient; 58 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 59 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 60 @GodotName("set_texture_mode") GodotMethod!(void, long) setTextureMode; 61 @GodotName("get_texture_mode") GodotMethod!(Line2D.LineTextureMode) getTextureMode; 62 @GodotName("set_joint_mode") GodotMethod!(void, long) setJointMode; 63 @GodotName("get_joint_mode") GodotMethod!(Line2D.LineJointMode) getJointMode; 64 @GodotName("set_begin_cap_mode") GodotMethod!(void, long) setBeginCapMode; 65 @GodotName("get_begin_cap_mode") GodotMethod!(Line2D.LineCapMode) getBeginCapMode; 66 @GodotName("set_end_cap_mode") GodotMethod!(void, long) setEndCapMode; 67 @GodotName("get_end_cap_mode") GodotMethod!(Line2D.LineCapMode) getEndCapMode; 68 @GodotName("set_sharp_limit") GodotMethod!(void, double) setSharpLimit; 69 @GodotName("get_sharp_limit") GodotMethod!(double) getSharpLimit; 70 @GodotName("set_round_precision") GodotMethod!(void, long) setRoundPrecision; 71 @GodotName("get_round_precision") GodotMethod!(long) getRoundPrecision; 72 @GodotName("_gradient_changed") GodotMethod!(void) _gradientChanged; 73 } 74 bool opEquals(in Line2D other) const { return _godot_object.ptr is other._godot_object.ptr; } 75 Line2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 76 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 77 mixin baseCasts; 78 static Line2D _new() 79 { 80 static godot_class_constructor constructor; 81 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Line2D"); 82 if(constructor is null) return typeof(this).init; 83 return cast(Line2D)(constructor()); 84 } 85 @disable new(size_t s); 86 /// 87 enum LineTextureMode : int 88 { 89 /** 90 Takes the left pixels of the texture and renders it over the whole line. 91 */ 92 lineTextureNone = 0, 93 /** 94 Tiles the texture over the line. The texture need to be imported with Repeat Enabled for it to work properly. 95 */ 96 lineTextureTile = 1, 97 /** 98 Stretches the texture across the line. Import the texture with Repeat Disabled for best results. 99 */ 100 lineTextureStretch = 2, 101 } 102 /// 103 enum LineCapMode : int 104 { 105 /** 106 Don't have a line cap. 107 */ 108 lineCapNone = 0, 109 /** 110 Draws the line cap as a box. 111 */ 112 lineCapBox = 1, 113 /** 114 Draws the line cap as a circle. 115 */ 116 lineCapRound = 2, 117 } 118 /// 119 enum LineJointMode : int 120 { 121 /** 122 The line's joints will be pointy. If `sharp_limit` is greater than the rotation of a joint, it becomes a bevel joint instead. 123 */ 124 lineJointSharp = 0, 125 /** 126 The line's joints will be bevelled/chamfered. 127 */ 128 lineJointBevel = 1, 129 /** 130 The line's joints will be rounded. 131 */ 132 lineJointRound = 2, 133 } 134 /// 135 enum Constants : int 136 { 137 lineCapNone = 0, 138 lineJointSharp = 0, 139 lineTextureNone = 0, 140 lineCapBox = 1, 141 lineTextureTile = 1, 142 lineJointBevel = 1, 143 lineJointRound = 2, 144 lineTextureStretch = 2, 145 lineCapRound = 2, 146 } 147 /** 148 149 */ 150 void setPoints(in PoolVector2Array points) 151 { 152 checkClassBinding!(typeof(this))(); 153 ptrcall!(void)(_classBinding.setPoints, _godot_object, points); 154 } 155 /** 156 157 */ 158 PoolVector2Array getPoints() const 159 { 160 checkClassBinding!(typeof(this))(); 161 return ptrcall!(PoolVector2Array)(_classBinding.getPoints, _godot_object); 162 } 163 /** 164 Overwrites the position in point `i` with the supplied `position`. 165 */ 166 void setPointPosition(in long i, in Vector2 position) 167 { 168 checkClassBinding!(typeof(this))(); 169 ptrcall!(void)(_classBinding.setPointPosition, _godot_object, i, position); 170 } 171 /** 172 Returns point `i`'s position. 173 */ 174 Vector2 getPointPosition(in long i) const 175 { 176 checkClassBinding!(typeof(this))(); 177 return ptrcall!(Vector2)(_classBinding.getPointPosition, _godot_object, i); 178 } 179 /** 180 Returns the Line2D's amount of points. 181 */ 182 long getPointCount() const 183 { 184 checkClassBinding!(typeof(this))(); 185 return ptrcall!(long)(_classBinding.getPointCount, _godot_object); 186 } 187 /** 188 Add a point at the `position`. Appends the point at the end of the line. 189 */ 190 void addPoint(in Vector2 position) 191 { 192 checkClassBinding!(typeof(this))(); 193 ptrcall!(void)(_classBinding.addPoint, _godot_object, position); 194 } 195 /** 196 Remove the point at index `i` from the line. 197 */ 198 void removePoint(in long i) 199 { 200 checkClassBinding!(typeof(this))(); 201 ptrcall!(void)(_classBinding.removePoint, _godot_object, i); 202 } 203 /** 204 205 */ 206 void setWidth(in double width) 207 { 208 checkClassBinding!(typeof(this))(); 209 ptrcall!(void)(_classBinding.setWidth, _godot_object, width); 210 } 211 /** 212 213 */ 214 double getWidth() const 215 { 216 checkClassBinding!(typeof(this))(); 217 return ptrcall!(double)(_classBinding.getWidth, _godot_object); 218 } 219 /** 220 221 */ 222 void setDefaultColor(in Color color) 223 { 224 checkClassBinding!(typeof(this))(); 225 ptrcall!(void)(_classBinding.setDefaultColor, _godot_object, color); 226 } 227 /** 228 229 */ 230 Color getDefaultColor() const 231 { 232 checkClassBinding!(typeof(this))(); 233 return ptrcall!(Color)(_classBinding.getDefaultColor, _godot_object); 234 } 235 /** 236 237 */ 238 void setGradient(Gradient color) 239 { 240 checkClassBinding!(typeof(this))(); 241 ptrcall!(void)(_classBinding.setGradient, _godot_object, color); 242 } 243 /** 244 245 */ 246 Ref!Gradient getGradient() const 247 { 248 checkClassBinding!(typeof(this))(); 249 return ptrcall!(Gradient)(_classBinding.getGradient, _godot_object); 250 } 251 /** 252 253 */ 254 void setTexture(Texture texture) 255 { 256 checkClassBinding!(typeof(this))(); 257 ptrcall!(void)(_classBinding.setTexture, _godot_object, texture); 258 } 259 /** 260 261 */ 262 Ref!Texture getTexture() const 263 { 264 checkClassBinding!(typeof(this))(); 265 return ptrcall!(Texture)(_classBinding.getTexture, _godot_object); 266 } 267 /** 268 269 */ 270 void setTextureMode(in long mode) 271 { 272 checkClassBinding!(typeof(this))(); 273 ptrcall!(void)(_classBinding.setTextureMode, _godot_object, mode); 274 } 275 /** 276 277 */ 278 Line2D.LineTextureMode getTextureMode() const 279 { 280 checkClassBinding!(typeof(this))(); 281 return ptrcall!(Line2D.LineTextureMode)(_classBinding.getTextureMode, _godot_object); 282 } 283 /** 284 285 */ 286 void setJointMode(in long mode) 287 { 288 checkClassBinding!(typeof(this))(); 289 ptrcall!(void)(_classBinding.setJointMode, _godot_object, mode); 290 } 291 /** 292 293 */ 294 Line2D.LineJointMode getJointMode() const 295 { 296 checkClassBinding!(typeof(this))(); 297 return ptrcall!(Line2D.LineJointMode)(_classBinding.getJointMode, _godot_object); 298 } 299 /** 300 301 */ 302 void setBeginCapMode(in long mode) 303 { 304 checkClassBinding!(typeof(this))(); 305 ptrcall!(void)(_classBinding.setBeginCapMode, _godot_object, mode); 306 } 307 /** 308 309 */ 310 Line2D.LineCapMode getBeginCapMode() const 311 { 312 checkClassBinding!(typeof(this))(); 313 return ptrcall!(Line2D.LineCapMode)(_classBinding.getBeginCapMode, _godot_object); 314 } 315 /** 316 317 */ 318 void setEndCapMode(in long mode) 319 { 320 checkClassBinding!(typeof(this))(); 321 ptrcall!(void)(_classBinding.setEndCapMode, _godot_object, mode); 322 } 323 /** 324 325 */ 326 Line2D.LineCapMode getEndCapMode() const 327 { 328 checkClassBinding!(typeof(this))(); 329 return ptrcall!(Line2D.LineCapMode)(_classBinding.getEndCapMode, _godot_object); 330 } 331 /** 332 333 */ 334 void setSharpLimit(in double limit) 335 { 336 checkClassBinding!(typeof(this))(); 337 ptrcall!(void)(_classBinding.setSharpLimit, _godot_object, limit); 338 } 339 /** 340 341 */ 342 double getSharpLimit() const 343 { 344 checkClassBinding!(typeof(this))(); 345 return ptrcall!(double)(_classBinding.getSharpLimit, _godot_object); 346 } 347 /** 348 349 */ 350 void setRoundPrecision(in long precision) 351 { 352 checkClassBinding!(typeof(this))(); 353 ptrcall!(void)(_classBinding.setRoundPrecision, _godot_object, precision); 354 } 355 /** 356 357 */ 358 long getRoundPrecision() const 359 { 360 checkClassBinding!(typeof(this))(); 361 return ptrcall!(long)(_classBinding.getRoundPrecision, _godot_object); 362 } 363 /** 364 365 */ 366 void _gradientChanged() 367 { 368 Array _GODOT_args = Array.empty_array; 369 String _GODOT_method_name = String("_gradient_changed"); 370 this.callv(_GODOT_method_name, _GODOT_args); 371 } 372 /** 373 The points that form the lines. The line is drawn between every point set in this array. 374 */ 375 @property PoolVector2Array points() 376 { 377 return getPoints(); 378 } 379 /// ditto 380 @property void points(PoolVector2Array v) 381 { 382 setPoints(v); 383 } 384 /** 385 The line's width. 386 */ 387 @property double width() 388 { 389 return getWidth(); 390 } 391 /// ditto 392 @property void width(double v) 393 { 394 setWidth(v); 395 } 396 /** 397 The line's color. Will not be used if a gradient is set. 398 */ 399 @property Color defaultColor() 400 { 401 return getDefaultColor(); 402 } 403 /// ditto 404 @property void defaultColor(Color v) 405 { 406 setDefaultColor(v); 407 } 408 /** 409 The gradient is drawn through the whole line from start to finish. The default color will not be used if a gradient is set. 410 */ 411 @property Gradient gradient() 412 { 413 return getGradient(); 414 } 415 /// ditto 416 @property void gradient(Gradient v) 417 { 418 setGradient(v); 419 } 420 /** 421 The texture used for the line's texture. Uses `texture_mode` for drawing style. 422 */ 423 @property Texture texture() 424 { 425 return getTexture(); 426 } 427 /// ditto 428 @property void texture(Texture v) 429 { 430 setTexture(v); 431 } 432 /** 433 The style to render the `texture` on the line. Use `LINE_TEXTURE_*` constants. Default value: `LINE_TEXTURE_NONE`. 434 */ 435 @property Line2D.LineTextureMode textureMode() 436 { 437 return getTextureMode(); 438 } 439 /// ditto 440 @property void textureMode(long v) 441 { 442 setTextureMode(v); 443 } 444 /** 445 The style for the points between the start and the end. 446 */ 447 @property Line2D.LineJointMode jointMode() 448 { 449 return getJointMode(); 450 } 451 /// ditto 452 @property void jointMode(long v) 453 { 454 setJointMode(v); 455 } 456 /** 457 Controls the style of the line's first point. Use `LINE_CAP_*` constants. Default value: `LINE_CAP_NONE`. 458 */ 459 @property Line2D.LineCapMode beginCapMode() 460 { 461 return getBeginCapMode(); 462 } 463 /// ditto 464 @property void beginCapMode(long v) 465 { 466 setBeginCapMode(v); 467 } 468 /** 469 Controls the style of the line's last point. Use `LINE_CAP_*` constants. Default value: `LINE_CAP_NONE`. 470 */ 471 @property Line2D.LineCapMode endCapMode() 472 { 473 return getEndCapMode(); 474 } 475 /// ditto 476 @property void endCapMode(long v) 477 { 478 setEndCapMode(v); 479 } 480 /** 481 The direction difference in radians between vector points. This value is only used if `joint mode` is set to `LINE_JOINT_SHARP`. 482 */ 483 @property double sharpLimit() 484 { 485 return getSharpLimit(); 486 } 487 /// ditto 488 @property void sharpLimit(double v) 489 { 490 setSharpLimit(v); 491 } 492 /** 493 The smoothness of the rounded joints and caps. This is only used if a cap or joint is set as round. 494 */ 495 @property long roundPrecision() 496 { 497 return getRoundPrecision(); 498 } 499 /// ditto 500 @property void roundPrecision(long v) 501 { 502 setRoundPrecision(v); 503 } 504 }