1 /**
2 A 2D polygon.
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.polygon2d;
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.texture;
25 import godot.canvasitem;
26 import godot.node;
27 /**
28 A 2D polygon.
29 
30 A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.
31 */
32 @GodotBaseClass struct Polygon2D
33 {
34 	enum string _GODOT_internal_name = "Polygon2D";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Node2D _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct _classBinding
42 	{
43 		__gshared:
44 		@GodotName("set_polygon") GodotMethod!(void, PoolVector2Array) setPolygon;
45 		@GodotName("get_polygon") GodotMethod!(PoolVector2Array) getPolygon;
46 		@GodotName("set_uv") GodotMethod!(void, PoolVector2Array) setUv;
47 		@GodotName("get_uv") GodotMethod!(PoolVector2Array) getUv;
48 		@GodotName("set_color") GodotMethod!(void, Color) setColor;
49 		@GodotName("get_color") GodotMethod!(Color) getColor;
50 		@GodotName("set_splits") GodotMethod!(void, PoolIntArray) setSplits;
51 		@GodotName("get_splits") GodotMethod!(PoolIntArray) getSplits;
52 		@GodotName("set_vertex_colors") GodotMethod!(void, PoolColorArray) setVertexColors;
53 		@GodotName("get_vertex_colors") GodotMethod!(PoolColorArray) getVertexColors;
54 		@GodotName("set_texture") GodotMethod!(void, Texture) setTexture;
55 		@GodotName("get_texture") GodotMethod!(Texture) getTexture;
56 		@GodotName("set_texture_offset") GodotMethod!(void, Vector2) setTextureOffset;
57 		@GodotName("get_texture_offset") GodotMethod!(Vector2) getTextureOffset;
58 		@GodotName("set_texture_rotation") GodotMethod!(void, double) setTextureRotation;
59 		@GodotName("get_texture_rotation") GodotMethod!(double) getTextureRotation;
60 		@GodotName("set_texture_rotation_degrees") GodotMethod!(void, double) setTextureRotationDegrees;
61 		@GodotName("get_texture_rotation_degrees") GodotMethod!(double) getTextureRotationDegrees;
62 		@GodotName("set_texture_scale") GodotMethod!(void, Vector2) setTextureScale;
63 		@GodotName("get_texture_scale") GodotMethod!(Vector2) getTextureScale;
64 		@GodotName("set_invert") GodotMethod!(void, bool) setInvert;
65 		@GodotName("get_invert") GodotMethod!(bool) getInvert;
66 		@GodotName("set_antialiased") GodotMethod!(void, bool) setAntialiased;
67 		@GodotName("get_antialiased") GodotMethod!(bool) getAntialiased;
68 		@GodotName("set_invert_border") GodotMethod!(void, double) setInvertBorder;
69 		@GodotName("get_invert_border") GodotMethod!(double) getInvertBorder;
70 		@GodotName("set_offset") GodotMethod!(void, Vector2) setOffset;
71 		@GodotName("get_offset") GodotMethod!(Vector2) getOffset;
72 		@GodotName("add_bone") GodotMethod!(void, NodePath, PoolRealArray) addBone;
73 		@GodotName("get_bone_count") GodotMethod!(long) getBoneCount;
74 		@GodotName("get_bone_path") GodotMethod!(NodePath, long) getBonePath;
75 		@GodotName("get_bone_weights") GodotMethod!(PoolRealArray, long) getBoneWeights;
76 		@GodotName("erase_bone") GodotMethod!(void, long) eraseBone;
77 		@GodotName("clear_bones") GodotMethod!(void) clearBones;
78 		@GodotName("set_bone_path") GodotMethod!(void, long, NodePath) setBonePath;
79 		@GodotName("set_bone_weights") GodotMethod!(void, long, PoolRealArray) setBoneWeights;
80 		@GodotName("set_skeleton") GodotMethod!(void, NodePath) setSkeleton;
81 		@GodotName("get_skeleton") GodotMethod!(NodePath) getSkeleton;
82 		@GodotName("_set_bones") GodotMethod!(void, Array) _setBones;
83 		@GodotName("_get_bones") GodotMethod!(Array) _getBones;
84 	}
85 	bool opEquals(in Polygon2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
86 	Polygon2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
87 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
88 	mixin baseCasts;
89 	static Polygon2D _new()
90 	{
91 		static godot_class_constructor constructor;
92 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Polygon2D");
93 		if(constructor is null) return typeof(this).init;
94 		return cast(Polygon2D)(constructor());
95 	}
96 	@disable new(size_t s);
97 	/**
98 	
99 	*/
100 	void setPolygon(in PoolVector2Array polygon)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(_classBinding.setPolygon, _godot_object, polygon);
104 	}
105 	/**
106 	
107 	*/
108 	PoolVector2Array getPolygon() const
109 	{
110 		checkClassBinding!(typeof(this))();
111 		return ptrcall!(PoolVector2Array)(_classBinding.getPolygon, _godot_object);
112 	}
113 	/**
114 	
115 	*/
116 	void setUv(in PoolVector2Array uv)
117 	{
118 		checkClassBinding!(typeof(this))();
119 		ptrcall!(void)(_classBinding.setUv, _godot_object, uv);
120 	}
121 	/**
122 	
123 	*/
124 	PoolVector2Array getUv() const
125 	{
126 		checkClassBinding!(typeof(this))();
127 		return ptrcall!(PoolVector2Array)(_classBinding.getUv, _godot_object);
128 	}
129 	/**
130 	
131 	*/
132 	void setColor(in Color color)
133 	{
134 		checkClassBinding!(typeof(this))();
135 		ptrcall!(void)(_classBinding.setColor, _godot_object, color);
136 	}
137 	/**
138 	
139 	*/
140 	Color getColor() const
141 	{
142 		checkClassBinding!(typeof(this))();
143 		return ptrcall!(Color)(_classBinding.getColor, _godot_object);
144 	}
145 	/**
146 	
147 	*/
148 	void setSplits(in PoolIntArray splits)
149 	{
150 		checkClassBinding!(typeof(this))();
151 		ptrcall!(void)(_classBinding.setSplits, _godot_object, splits);
152 	}
153 	/**
154 	
155 	*/
156 	PoolIntArray getSplits() const
157 	{
158 		checkClassBinding!(typeof(this))();
159 		return ptrcall!(PoolIntArray)(_classBinding.getSplits, _godot_object);
160 	}
161 	/**
162 	
163 	*/
164 	void setVertexColors(in PoolColorArray vertex_colors)
165 	{
166 		checkClassBinding!(typeof(this))();
167 		ptrcall!(void)(_classBinding.setVertexColors, _godot_object, vertex_colors);
168 	}
169 	/**
170 	
171 	*/
172 	PoolColorArray getVertexColors() const
173 	{
174 		checkClassBinding!(typeof(this))();
175 		return ptrcall!(PoolColorArray)(_classBinding.getVertexColors, _godot_object);
176 	}
177 	/**
178 	
179 	*/
180 	void setTexture(Texture texture)
181 	{
182 		checkClassBinding!(typeof(this))();
183 		ptrcall!(void)(_classBinding.setTexture, _godot_object, texture);
184 	}
185 	/**
186 	
187 	*/
188 	Ref!Texture getTexture() const
189 	{
190 		checkClassBinding!(typeof(this))();
191 		return ptrcall!(Texture)(_classBinding.getTexture, _godot_object);
192 	}
193 	/**
194 	
195 	*/
196 	void setTextureOffset(in Vector2 texture_offset)
197 	{
198 		checkClassBinding!(typeof(this))();
199 		ptrcall!(void)(_classBinding.setTextureOffset, _godot_object, texture_offset);
200 	}
201 	/**
202 	
203 	*/
204 	Vector2 getTextureOffset() const
205 	{
206 		checkClassBinding!(typeof(this))();
207 		return ptrcall!(Vector2)(_classBinding.getTextureOffset, _godot_object);
208 	}
209 	/**
210 	
211 	*/
212 	void setTextureRotation(in double texture_rotation)
213 	{
214 		checkClassBinding!(typeof(this))();
215 		ptrcall!(void)(_classBinding.setTextureRotation, _godot_object, texture_rotation);
216 	}
217 	/**
218 	
219 	*/
220 	double getTextureRotation() const
221 	{
222 		checkClassBinding!(typeof(this))();
223 		return ptrcall!(double)(_classBinding.getTextureRotation, _godot_object);
224 	}
225 	/**
226 	
227 	*/
228 	void setTextureRotationDegrees(in double texture_rotation)
229 	{
230 		checkClassBinding!(typeof(this))();
231 		ptrcall!(void)(_classBinding.setTextureRotationDegrees, _godot_object, texture_rotation);
232 	}
233 	/**
234 	
235 	*/
236 	double getTextureRotationDegrees() const
237 	{
238 		checkClassBinding!(typeof(this))();
239 		return ptrcall!(double)(_classBinding.getTextureRotationDegrees, _godot_object);
240 	}
241 	/**
242 	
243 	*/
244 	void setTextureScale(in Vector2 texture_scale)
245 	{
246 		checkClassBinding!(typeof(this))();
247 		ptrcall!(void)(_classBinding.setTextureScale, _godot_object, texture_scale);
248 	}
249 	/**
250 	
251 	*/
252 	Vector2 getTextureScale() const
253 	{
254 		checkClassBinding!(typeof(this))();
255 		return ptrcall!(Vector2)(_classBinding.getTextureScale, _godot_object);
256 	}
257 	/**
258 	
259 	*/
260 	void setInvert(in bool invert)
261 	{
262 		checkClassBinding!(typeof(this))();
263 		ptrcall!(void)(_classBinding.setInvert, _godot_object, invert);
264 	}
265 	/**
266 	
267 	*/
268 	bool getInvert() const
269 	{
270 		checkClassBinding!(typeof(this))();
271 		return ptrcall!(bool)(_classBinding.getInvert, _godot_object);
272 	}
273 	/**
274 	
275 	*/
276 	void setAntialiased(in bool antialiased)
277 	{
278 		checkClassBinding!(typeof(this))();
279 		ptrcall!(void)(_classBinding.setAntialiased, _godot_object, antialiased);
280 	}
281 	/**
282 	
283 	*/
284 	bool getAntialiased() const
285 	{
286 		checkClassBinding!(typeof(this))();
287 		return ptrcall!(bool)(_classBinding.getAntialiased, _godot_object);
288 	}
289 	/**
290 	
291 	*/
292 	void setInvertBorder(in double invert_border)
293 	{
294 		checkClassBinding!(typeof(this))();
295 		ptrcall!(void)(_classBinding.setInvertBorder, _godot_object, invert_border);
296 	}
297 	/**
298 	
299 	*/
300 	double getInvertBorder() const
301 	{
302 		checkClassBinding!(typeof(this))();
303 		return ptrcall!(double)(_classBinding.getInvertBorder, _godot_object);
304 	}
305 	/**
306 	
307 	*/
308 	void setOffset(in Vector2 offset)
309 	{
310 		checkClassBinding!(typeof(this))();
311 		ptrcall!(void)(_classBinding.setOffset, _godot_object, offset);
312 	}
313 	/**
314 	
315 	*/
316 	Vector2 getOffset() const
317 	{
318 		checkClassBinding!(typeof(this))();
319 		return ptrcall!(Vector2)(_classBinding.getOffset, _godot_object);
320 	}
321 	/**
322 	
323 	*/
324 	void addBone(NodePathArg0)(in NodePathArg0 path, in PoolRealArray weights)
325 	{
326 		checkClassBinding!(typeof(this))();
327 		ptrcall!(void)(_classBinding.addBone, _godot_object, path, weights);
328 	}
329 	/**
330 	
331 	*/
332 	long getBoneCount() const
333 	{
334 		checkClassBinding!(typeof(this))();
335 		return ptrcall!(long)(_classBinding.getBoneCount, _godot_object);
336 	}
337 	/**
338 	
339 	*/
340 	NodePath getBonePath(in long index) const
341 	{
342 		checkClassBinding!(typeof(this))();
343 		return ptrcall!(NodePath)(_classBinding.getBonePath, _godot_object, index);
344 	}
345 	/**
346 	
347 	*/
348 	PoolRealArray getBoneWeights(in long index) const
349 	{
350 		checkClassBinding!(typeof(this))();
351 		return ptrcall!(PoolRealArray)(_classBinding.getBoneWeights, _godot_object, index);
352 	}
353 	/**
354 	
355 	*/
356 	void eraseBone(in long index)
357 	{
358 		checkClassBinding!(typeof(this))();
359 		ptrcall!(void)(_classBinding.eraseBone, _godot_object, index);
360 	}
361 	/**
362 	
363 	*/
364 	void clearBones()
365 	{
366 		checkClassBinding!(typeof(this))();
367 		ptrcall!(void)(_classBinding.clearBones, _godot_object);
368 	}
369 	/**
370 	
371 	*/
372 	void setBonePath(NodePathArg1)(in long index, in NodePathArg1 path)
373 	{
374 		checkClassBinding!(typeof(this))();
375 		ptrcall!(void)(_classBinding.setBonePath, _godot_object, index, path);
376 	}
377 	/**
378 	
379 	*/
380 	void setBoneWeights(in long index, in PoolRealArray weights)
381 	{
382 		checkClassBinding!(typeof(this))();
383 		ptrcall!(void)(_classBinding.setBoneWeights, _godot_object, index, weights);
384 	}
385 	/**
386 	
387 	*/
388 	void setSkeleton(NodePathArg0)(in NodePathArg0 skeleton)
389 	{
390 		checkClassBinding!(typeof(this))();
391 		ptrcall!(void)(_classBinding.setSkeleton, _godot_object, skeleton);
392 	}
393 	/**
394 	
395 	*/
396 	NodePath getSkeleton() const
397 	{
398 		checkClassBinding!(typeof(this))();
399 		return ptrcall!(NodePath)(_classBinding.getSkeleton, _godot_object);
400 	}
401 	/**
402 	
403 	*/
404 	void _setBones(in Array bones)
405 	{
406 		Array _GODOT_args = Array.empty_array;
407 		_GODOT_args.append(bones);
408 		String _GODOT_method_name = String("_set_bones");
409 		this.callv(_GODOT_method_name, _GODOT_args);
410 	}
411 	/**
412 	
413 	*/
414 	Array _getBones() const
415 	{
416 		Array _GODOT_args = Array.empty_array;
417 		String _GODOT_method_name = String("_get_bones");
418 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array);
419 	}
420 	/**
421 	The polygon's list of vertices. The final point will be connected to the first.
422 	*/
423 	@property PoolVector2Array polygon()
424 	{
425 		return getPolygon();
426 	}
427 	/// ditto
428 	@property void polygon(PoolVector2Array v)
429 	{
430 		setPolygon(v);
431 	}
432 	/**
433 	Texture coordinates for each vertex of the polygon. There should be one `uv` per polygon vertex. If there are fewer, undefined vertices will use `(0, 0)`.
434 	*/
435 	@property PoolVector2Array uv()
436 	{
437 		return getUv();
438 	}
439 	/// ditto
440 	@property void uv(PoolVector2Array v)
441 	{
442 		setUv(v);
443 	}
444 	/**
445 	
446 	*/
447 	@property PoolIntArray splits()
448 	{
449 		return getSplits();
450 	}
451 	/// ditto
452 	@property void splits(PoolIntArray v)
453 	{
454 		setSplits(v);
455 	}
456 	/**
457 	The polygon's fill color. If `texture` is defined, it will be multiplied by this color. It will also be the default color for vertices not set in `vertex_colors`.
458 	*/
459 	@property Color color()
460 	{
461 		return getColor();
462 	}
463 	/// ditto
464 	@property void color(Color v)
465 	{
466 		setColor(v);
467 	}
468 	/**
469 	Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use `color`.
470 	*/
471 	@property PoolColorArray vertexColors()
472 	{
473 		return getVertexColors();
474 	}
475 	/// ditto
476 	@property void vertexColors(PoolColorArray v)
477 	{
478 		setVertexColors(v);
479 	}
480 	/**
481 	The offset applied to each vertex.
482 	*/
483 	@property Vector2 offset()
484 	{
485 		return getOffset();
486 	}
487 	/// ditto
488 	@property void offset(Vector2 v)
489 	{
490 		setOffset(v);
491 	}
492 	/**
493 	If `true` polygon edges will be anti-aliased. Default value: `false`.
494 	*/
495 	@property bool antialiased()
496 	{
497 		return getAntialiased();
498 	}
499 	/// ditto
500 	@property void antialiased(bool v)
501 	{
502 		setAntialiased(v);
503 	}
504 	/**
505 	The polygon's fill texture. Use `uv` to set texture coordinates.
506 	*/
507 	@property Texture texture()
508 	{
509 		return getTexture();
510 	}
511 	/// ditto
512 	@property void texture(Texture v)
513 	{
514 		setTexture(v);
515 	}
516 	/**
517 	Amount to offset the polygon's `texture`. If `(0, 0)` the texture's origin (its top-left corner) will be placed at the polygon's `position`.
518 	*/
519 	@property Vector2 textureOffset()
520 	{
521 		return getTextureOffset();
522 	}
523 	/// ditto
524 	@property void textureOffset(Vector2 v)
525 	{
526 		setTextureOffset(v);
527 	}
528 	/**
529 	Amount to multiply the `uv` coordinates when using a `texture`. Larger values make the texture smaller, and vice versa.
530 	*/
531 	@property Vector2 textureScale()
532 	{
533 		return getTextureScale();
534 	}
535 	/// ditto
536 	@property void textureScale(Vector2 v)
537 	{
538 		setTextureScale(v);
539 	}
540 	/**
541 	The texture's rotation in degrees.
542 	*/
543 	@property double textureRotationDegrees()
544 	{
545 		return getTextureRotationDegrees();
546 	}
547 	/// ditto
548 	@property void textureRotationDegrees(double v)
549 	{
550 		setTextureRotationDegrees(v);
551 	}
552 	/**
553 	The texture's rotation in radians.
554 	*/
555 	@property double textureRotation()
556 	{
557 		return getTextureRotation();
558 	}
559 	/// ditto
560 	@property void textureRotation(double v)
561 	{
562 		setTextureRotation(v);
563 	}
564 	/**
565 	
566 	*/
567 	@property NodePath skeleton()
568 	{
569 		return getSkeleton();
570 	}
571 	/// ditto
572 	@property void skeleton(NodePath v)
573 	{
574 		setSkeleton(v);
575 	}
576 	/**
577 	If `true` polygon will be inverted, containing the area outside the defined points and extending to the `invert_border`. Default value: `false`.
578 	*/
579 	@property bool invertEnable()
580 	{
581 		return getInvert();
582 	}
583 	/// ditto
584 	@property void invertEnable(bool v)
585 	{
586 		setInvert(v);
587 	}
588 	/**
589 	Added padding applied to the bounding box when using `invert`. Setting this value too small may result in a "Bad Polygon" error. Default value: `100`.
590 	*/
591 	@property double invertBorder()
592 	{
593 		return getInvertBorder();
594 	}
595 	/// ditto
596 	@property void invertBorder(double v)
597 	{
598 		setInvertBorder(v);
599 	}
600 	/**
601 	
602 	*/
603 	@property Array bones()
604 	{
605 		return _getBones();
606 	}
607 	/// ditto
608 	@property void bones(Array v)
609 	{
610 		_setBones(v);
611 	}
612 }