1 /**
2 Casts light in a 2D environment.
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.light2d;
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 Casts light in a 2D environment.
29 
30 Light is defined by a (usually grayscale) texture, a color, an energy value, a mode (see constants), and various other parameters (range and shadows-related). Note that Light2D can be used as a mask.
31 */
32 @GodotBaseClass struct Light2D
33 {
34 	enum string _GODOT_internal_name = "Light2D";
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_enabled") GodotMethod!(void, bool) setEnabled;
45 		@GodotName("is_enabled") GodotMethod!(bool) isEnabled;
46 		@GodotName("set_editor_only") GodotMethod!(void, bool) setEditorOnly;
47 		@GodotName("is_editor_only") GodotMethod!(bool) isEditorOnly;
48 		@GodotName("set_texture") GodotMethod!(void, Texture) setTexture;
49 		@GodotName("get_texture") GodotMethod!(Texture) getTexture;
50 		@GodotName("set_texture_offset") GodotMethod!(void, Vector2) setTextureOffset;
51 		@GodotName("get_texture_offset") GodotMethod!(Vector2) getTextureOffset;
52 		@GodotName("set_color") GodotMethod!(void, Color) setColor;
53 		@GodotName("get_color") GodotMethod!(Color) getColor;
54 		@GodotName("set_height") GodotMethod!(void, double) setHeight;
55 		@GodotName("get_height") GodotMethod!(double) getHeight;
56 		@GodotName("set_energy") GodotMethod!(void, double) setEnergy;
57 		@GodotName("get_energy") GodotMethod!(double) getEnergy;
58 		@GodotName("set_texture_scale") GodotMethod!(void, double) setTextureScale;
59 		@GodotName("get_texture_scale") GodotMethod!(double) getTextureScale;
60 		@GodotName("set_z_range_min") GodotMethod!(void, long) setZRangeMin;
61 		@GodotName("get_z_range_min") GodotMethod!(long) getZRangeMin;
62 		@GodotName("set_z_range_max") GodotMethod!(void, long) setZRangeMax;
63 		@GodotName("get_z_range_max") GodotMethod!(long) getZRangeMax;
64 		@GodotName("set_layer_range_min") GodotMethod!(void, long) setLayerRangeMin;
65 		@GodotName("get_layer_range_min") GodotMethod!(long) getLayerRangeMin;
66 		@GodotName("set_layer_range_max") GodotMethod!(void, long) setLayerRangeMax;
67 		@GodotName("get_layer_range_max") GodotMethod!(long) getLayerRangeMax;
68 		@GodotName("set_item_cull_mask") GodotMethod!(void, long) setItemCullMask;
69 		@GodotName("get_item_cull_mask") GodotMethod!(long) getItemCullMask;
70 		@GodotName("set_item_shadow_cull_mask") GodotMethod!(void, long) setItemShadowCullMask;
71 		@GodotName("get_item_shadow_cull_mask") GodotMethod!(long) getItemShadowCullMask;
72 		@GodotName("set_mode") GodotMethod!(void, long) setMode;
73 		@GodotName("get_mode") GodotMethod!(Light2D.Mode) getMode;
74 		@GodotName("set_shadow_enabled") GodotMethod!(void, bool) setShadowEnabled;
75 		@GodotName("is_shadow_enabled") GodotMethod!(bool) isShadowEnabled;
76 		@GodotName("set_shadow_buffer_size") GodotMethod!(void, long) setShadowBufferSize;
77 		@GodotName("get_shadow_buffer_size") GodotMethod!(long) getShadowBufferSize;
78 		@GodotName("set_shadow_smooth") GodotMethod!(void, double) setShadowSmooth;
79 		@GodotName("get_shadow_smooth") GodotMethod!(double) getShadowSmooth;
80 		@GodotName("set_shadow_gradient_length") GodotMethod!(void, double) setShadowGradientLength;
81 		@GodotName("get_shadow_gradient_length") GodotMethod!(double) getShadowGradientLength;
82 		@GodotName("set_shadow_filter") GodotMethod!(void, long) setShadowFilter;
83 		@GodotName("get_shadow_filter") GodotMethod!(Light2D.ShadowFilter) getShadowFilter;
84 		@GodotName("set_shadow_color") GodotMethod!(void, Color) setShadowColor;
85 		@GodotName("get_shadow_color") GodotMethod!(Color) getShadowColor;
86 	}
87 	bool opEquals(in Light2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
88 	Light2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
89 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
90 	mixin baseCasts;
91 	static Light2D _new()
92 	{
93 		static godot_class_constructor constructor;
94 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Light2D");
95 		if(constructor is null) return typeof(this).init;
96 		return cast(Light2D)(constructor());
97 	}
98 	@disable new(size_t s);
99 	/// 
100 	enum ShadowFilter : int
101 	{
102 		/**
103 		No filter applies to the shadow map. See $(D shadowFilter).
104 		*/
105 		shadowFilterNone = 0,
106 		/**
107 		Percentage closer filtering (3 samples) applies to the shadow map. See $(D shadowFilter).
108 		*/
109 		shadowFilterPcf3 = 1,
110 		/**
111 		Percentage closer filtering (5 samples) applies to the shadow map. See $(D shadowFilter).
112 		*/
113 		shadowFilterPcf5 = 2,
114 		/**
115 		Percentage closer filtering (7 samples) applies to the shadow map. See $(D shadowFilter).
116 		*/
117 		shadowFilterPcf7 = 3,
118 		/**
119 		Percentage closer filtering (9 samples) applies to the shadow map. See $(D shadowFilter).
120 		*/
121 		shadowFilterPcf9 = 4,
122 		/**
123 		Percentage closer filtering (13 samples) applies to the shadow map. See $(D shadowFilter).
124 		*/
125 		shadowFilterPcf13 = 5,
126 	}
127 	/// 
128 	enum Mode : int
129 	{
130 		/**
131 		Adds the value of pixels corresponding to the Light2D to the values of pixels under it. This is the common behaviour of a light.
132 		*/
133 		modeAdd = 0,
134 		/**
135 		Subtracts the value of pixels corresponding to the Light2D to the values of pixels under it, resulting in inversed light effect.
136 		*/
137 		modeSub = 1,
138 		/**
139 		Mix the value of pixels corresponding to the Light2D to the values of pixels under it by linear interpolation.
140 		*/
141 		modeMix = 2,
142 		/**
143 		The light texture of the Light2D is used as a mask, hiding or revealing parts of the screen underneath depending on the value of each pixel of the light (mask) texture.
144 		*/
145 		modeMask = 3,
146 	}
147 	/// 
148 	enum Constants : int
149 	{
150 		modeAdd = 0,
151 		shadowFilterNone = 0,
152 		modeSub = 1,
153 		shadowFilterPcf3 = 1,
154 		modeMix = 2,
155 		shadowFilterPcf5 = 2,
156 		modeMask = 3,
157 		shadowFilterPcf7 = 3,
158 		shadowFilterPcf9 = 4,
159 		shadowFilterPcf13 = 5,
160 	}
161 	/**
162 	
163 	*/
164 	void setEnabled(in bool enabled)
165 	{
166 		checkClassBinding!(typeof(this))();
167 		ptrcall!(void)(_classBinding.setEnabled, _godot_object, enabled);
168 	}
169 	/**
170 	
171 	*/
172 	bool isEnabled() const
173 	{
174 		checkClassBinding!(typeof(this))();
175 		return ptrcall!(bool)(_classBinding.isEnabled, _godot_object);
176 	}
177 	/**
178 	
179 	*/
180 	void setEditorOnly(in bool editor_only)
181 	{
182 		checkClassBinding!(typeof(this))();
183 		ptrcall!(void)(_classBinding.setEditorOnly, _godot_object, editor_only);
184 	}
185 	/**
186 	
187 	*/
188 	bool isEditorOnly() const
189 	{
190 		checkClassBinding!(typeof(this))();
191 		return ptrcall!(bool)(_classBinding.isEditorOnly, _godot_object);
192 	}
193 	/**
194 	
195 	*/
196 	void setTexture(Texture texture)
197 	{
198 		checkClassBinding!(typeof(this))();
199 		ptrcall!(void)(_classBinding.setTexture, _godot_object, texture);
200 	}
201 	/**
202 	
203 	*/
204 	Ref!Texture getTexture() const
205 	{
206 		checkClassBinding!(typeof(this))();
207 		return ptrcall!(Texture)(_classBinding.getTexture, _godot_object);
208 	}
209 	/**
210 	
211 	*/
212 	void setTextureOffset(in Vector2 texture_offset)
213 	{
214 		checkClassBinding!(typeof(this))();
215 		ptrcall!(void)(_classBinding.setTextureOffset, _godot_object, texture_offset);
216 	}
217 	/**
218 	
219 	*/
220 	Vector2 getTextureOffset() const
221 	{
222 		checkClassBinding!(typeof(this))();
223 		return ptrcall!(Vector2)(_classBinding.getTextureOffset, _godot_object);
224 	}
225 	/**
226 	
227 	*/
228 	void setColor(in Color color)
229 	{
230 		checkClassBinding!(typeof(this))();
231 		ptrcall!(void)(_classBinding.setColor, _godot_object, color);
232 	}
233 	/**
234 	
235 	*/
236 	Color getColor() const
237 	{
238 		checkClassBinding!(typeof(this))();
239 		return ptrcall!(Color)(_classBinding.getColor, _godot_object);
240 	}
241 	/**
242 	
243 	*/
244 	void setHeight(in double height)
245 	{
246 		checkClassBinding!(typeof(this))();
247 		ptrcall!(void)(_classBinding.setHeight, _godot_object, height);
248 	}
249 	/**
250 	
251 	*/
252 	double getHeight() const
253 	{
254 		checkClassBinding!(typeof(this))();
255 		return ptrcall!(double)(_classBinding.getHeight, _godot_object);
256 	}
257 	/**
258 	
259 	*/
260 	void setEnergy(in double energy)
261 	{
262 		checkClassBinding!(typeof(this))();
263 		ptrcall!(void)(_classBinding.setEnergy, _godot_object, energy);
264 	}
265 	/**
266 	
267 	*/
268 	double getEnergy() const
269 	{
270 		checkClassBinding!(typeof(this))();
271 		return ptrcall!(double)(_classBinding.getEnergy, _godot_object);
272 	}
273 	/**
274 	
275 	*/
276 	void setTextureScale(in double texture_scale)
277 	{
278 		checkClassBinding!(typeof(this))();
279 		ptrcall!(void)(_classBinding.setTextureScale, _godot_object, texture_scale);
280 	}
281 	/**
282 	
283 	*/
284 	double getTextureScale() const
285 	{
286 		checkClassBinding!(typeof(this))();
287 		return ptrcall!(double)(_classBinding.getTextureScale, _godot_object);
288 	}
289 	/**
290 	
291 	*/
292 	void setZRangeMin(in long z)
293 	{
294 		checkClassBinding!(typeof(this))();
295 		ptrcall!(void)(_classBinding.setZRangeMin, _godot_object, z);
296 	}
297 	/**
298 	
299 	*/
300 	long getZRangeMin() const
301 	{
302 		checkClassBinding!(typeof(this))();
303 		return ptrcall!(long)(_classBinding.getZRangeMin, _godot_object);
304 	}
305 	/**
306 	
307 	*/
308 	void setZRangeMax(in long z)
309 	{
310 		checkClassBinding!(typeof(this))();
311 		ptrcall!(void)(_classBinding.setZRangeMax, _godot_object, z);
312 	}
313 	/**
314 	
315 	*/
316 	long getZRangeMax() const
317 	{
318 		checkClassBinding!(typeof(this))();
319 		return ptrcall!(long)(_classBinding.getZRangeMax, _godot_object);
320 	}
321 	/**
322 	
323 	*/
324 	void setLayerRangeMin(in long layer)
325 	{
326 		checkClassBinding!(typeof(this))();
327 		ptrcall!(void)(_classBinding.setLayerRangeMin, _godot_object, layer);
328 	}
329 	/**
330 	
331 	*/
332 	long getLayerRangeMin() const
333 	{
334 		checkClassBinding!(typeof(this))();
335 		return ptrcall!(long)(_classBinding.getLayerRangeMin, _godot_object);
336 	}
337 	/**
338 	
339 	*/
340 	void setLayerRangeMax(in long layer)
341 	{
342 		checkClassBinding!(typeof(this))();
343 		ptrcall!(void)(_classBinding.setLayerRangeMax, _godot_object, layer);
344 	}
345 	/**
346 	
347 	*/
348 	long getLayerRangeMax() const
349 	{
350 		checkClassBinding!(typeof(this))();
351 		return ptrcall!(long)(_classBinding.getLayerRangeMax, _godot_object);
352 	}
353 	/**
354 	
355 	*/
356 	void setItemCullMask(in long item_cull_mask)
357 	{
358 		checkClassBinding!(typeof(this))();
359 		ptrcall!(void)(_classBinding.setItemCullMask, _godot_object, item_cull_mask);
360 	}
361 	/**
362 	
363 	*/
364 	long getItemCullMask() const
365 	{
366 		checkClassBinding!(typeof(this))();
367 		return ptrcall!(long)(_classBinding.getItemCullMask, _godot_object);
368 	}
369 	/**
370 	
371 	*/
372 	void setItemShadowCullMask(in long item_shadow_cull_mask)
373 	{
374 		checkClassBinding!(typeof(this))();
375 		ptrcall!(void)(_classBinding.setItemShadowCullMask, _godot_object, item_shadow_cull_mask);
376 	}
377 	/**
378 	
379 	*/
380 	long getItemShadowCullMask() const
381 	{
382 		checkClassBinding!(typeof(this))();
383 		return ptrcall!(long)(_classBinding.getItemShadowCullMask, _godot_object);
384 	}
385 	/**
386 	
387 	*/
388 	void setMode(in long mode)
389 	{
390 		checkClassBinding!(typeof(this))();
391 		ptrcall!(void)(_classBinding.setMode, _godot_object, mode);
392 	}
393 	/**
394 	
395 	*/
396 	Light2D.Mode getMode() const
397 	{
398 		checkClassBinding!(typeof(this))();
399 		return ptrcall!(Light2D.Mode)(_classBinding.getMode, _godot_object);
400 	}
401 	/**
402 	
403 	*/
404 	void setShadowEnabled(in bool enabled)
405 	{
406 		checkClassBinding!(typeof(this))();
407 		ptrcall!(void)(_classBinding.setShadowEnabled, _godot_object, enabled);
408 	}
409 	/**
410 	
411 	*/
412 	bool isShadowEnabled() const
413 	{
414 		checkClassBinding!(typeof(this))();
415 		return ptrcall!(bool)(_classBinding.isShadowEnabled, _godot_object);
416 	}
417 	/**
418 	
419 	*/
420 	void setShadowBufferSize(in long size)
421 	{
422 		checkClassBinding!(typeof(this))();
423 		ptrcall!(void)(_classBinding.setShadowBufferSize, _godot_object, size);
424 	}
425 	/**
426 	
427 	*/
428 	long getShadowBufferSize() const
429 	{
430 		checkClassBinding!(typeof(this))();
431 		return ptrcall!(long)(_classBinding.getShadowBufferSize, _godot_object);
432 	}
433 	/**
434 	
435 	*/
436 	void setShadowSmooth(in double smooth)
437 	{
438 		checkClassBinding!(typeof(this))();
439 		ptrcall!(void)(_classBinding.setShadowSmooth, _godot_object, smooth);
440 	}
441 	/**
442 	
443 	*/
444 	double getShadowSmooth() const
445 	{
446 		checkClassBinding!(typeof(this))();
447 		return ptrcall!(double)(_classBinding.getShadowSmooth, _godot_object);
448 	}
449 	/**
450 	
451 	*/
452 	void setShadowGradientLength(in double multiplier)
453 	{
454 		checkClassBinding!(typeof(this))();
455 		ptrcall!(void)(_classBinding.setShadowGradientLength, _godot_object, multiplier);
456 	}
457 	/**
458 	
459 	*/
460 	double getShadowGradientLength() const
461 	{
462 		checkClassBinding!(typeof(this))();
463 		return ptrcall!(double)(_classBinding.getShadowGradientLength, _godot_object);
464 	}
465 	/**
466 	
467 	*/
468 	void setShadowFilter(in long filter)
469 	{
470 		checkClassBinding!(typeof(this))();
471 		ptrcall!(void)(_classBinding.setShadowFilter, _godot_object, filter);
472 	}
473 	/**
474 	
475 	*/
476 	Light2D.ShadowFilter getShadowFilter() const
477 	{
478 		checkClassBinding!(typeof(this))();
479 		return ptrcall!(Light2D.ShadowFilter)(_classBinding.getShadowFilter, _godot_object);
480 	}
481 	/**
482 	
483 	*/
484 	void setShadowColor(in Color shadow_color)
485 	{
486 		checkClassBinding!(typeof(this))();
487 		ptrcall!(void)(_classBinding.setShadowColor, _godot_object, shadow_color);
488 	}
489 	/**
490 	
491 	*/
492 	Color getShadowColor() const
493 	{
494 		checkClassBinding!(typeof(this))();
495 		return ptrcall!(Color)(_classBinding.getShadowColor, _godot_object);
496 	}
497 	/**
498 	If `true` Light2D will emit light. Default value: `true`.
499 	*/
500 	@property bool enabled()
501 	{
502 		return isEnabled();
503 	}
504 	/// ditto
505 	@property void enabled(bool v)
506 	{
507 		setEnabled(v);
508 	}
509 	/**
510 	If `true` Light2D will only appear when editing the scene. Default value: `false`.
511 	*/
512 	@property bool editorOnly()
513 	{
514 		return isEditorOnly();
515 	}
516 	/// ditto
517 	@property void editorOnly(bool v)
518 	{
519 		setEditorOnly(v);
520 	}
521 	/**
522 	The offset of the Light2D's `texture`.
523 	*/
524 	@property Vector2 offset()
525 	{
526 		return getTextureOffset();
527 	}
528 	/// ditto
529 	@property void offset(Vector2 v)
530 	{
531 		setTextureOffset(v);
532 	}
533 	/**
534 	The `texture`'s scale factor.
535 	*/
536 	@property double textureScale()
537 	{
538 		return getTextureScale();
539 	}
540 	/// ditto
541 	@property void textureScale(double v)
542 	{
543 		setTextureScale(v);
544 	}
545 	/**
546 	The Light2D's $(D Color).
547 	*/
548 	@property Color color()
549 	{
550 		return getColor();
551 	}
552 	/// ditto
553 	@property void color(Color v)
554 	{
555 		setColor(v);
556 	}
557 	/**
558 	The Light2D's energy value. The larger the value, the stronger the light.
559 	*/
560 	@property double energy()
561 	{
562 		return getEnergy();
563 	}
564 	/// ditto
565 	@property void energy(double v)
566 	{
567 		setEnergy(v);
568 	}
569 	/**
570 	The Light2D's mode. See MODE_* constants for values.
571 	*/
572 	@property Light2D.Mode mode()
573 	{
574 		return getMode();
575 	}
576 	/// ditto
577 	@property void mode(long v)
578 	{
579 		setMode(v);
580 	}
581 	/**
582 	The height of the Light2D. Used with 2D normal mapping.
583 	*/
584 	@property double rangeHeight()
585 	{
586 		return getHeight();
587 	}
588 	/// ditto
589 	@property void rangeHeight(double v)
590 	{
591 		setHeight(v);
592 	}
593 	/**
594 	Minimum `z` value of objects that are affected by the Light2D. Default value: `-1024`.
595 	*/
596 	@property long rangeZMin()
597 	{
598 		return getZRangeMin();
599 	}
600 	/// ditto
601 	@property void rangeZMin(long v)
602 	{
603 		setZRangeMin(v);
604 	}
605 	/**
606 	Maximum `Z` value of objects that are affected by the Light2D. Default value: `1024`.
607 	*/
608 	@property long rangeZMax()
609 	{
610 		return getZRangeMax();
611 	}
612 	/// ditto
613 	@property void rangeZMax(long v)
614 	{
615 		setZRangeMax(v);
616 	}
617 	/**
618 	Minimum layer value of objects that are affected by the Light2D. Default value: `0`.
619 	*/
620 	@property long rangeLayerMin()
621 	{
622 		return getLayerRangeMin();
623 	}
624 	/// ditto
625 	@property void rangeLayerMin(long v)
626 	{
627 		setLayerRangeMin(v);
628 	}
629 	/**
630 	Maximum layer value of objects that are affected by the Light2D. Default value: `0`.
631 	*/
632 	@property long rangeLayerMax()
633 	{
634 		return getLayerRangeMax();
635 	}
636 	/// ditto
637 	@property void rangeLayerMax(long v)
638 	{
639 		setLayerRangeMax(v);
640 	}
641 	/**
642 	The layer mask. Only objects with a matching mask will be affected by the Light2D.
643 	*/
644 	@property long rangeItemCullMask()
645 	{
646 		return getItemCullMask();
647 	}
648 	/// ditto
649 	@property void rangeItemCullMask(long v)
650 	{
651 		setItemCullMask(v);
652 	}
653 	/**
654 	If `true` the Light2D will cast shadows. Default value: `false`.
655 	*/
656 	@property bool shadowEnabled()
657 	{
658 		return isShadowEnabled();
659 	}
660 	/// ditto
661 	@property void shadowEnabled(bool v)
662 	{
663 		setShadowEnabled(v);
664 	}
665 	/**
666 	$(D Color) of shadows cast by the Light2D.
667 	*/
668 	@property Color shadowColor()
669 	{
670 		return getShadowColor();
671 	}
672 	/// ditto
673 	@property void shadowColor(Color v)
674 	{
675 		setShadowColor(v);
676 	}
677 	/**
678 	Shadow buffer size. Default value: `2048`.
679 	*/
680 	@property long shadowBufferSize()
681 	{
682 		return getShadowBufferSize();
683 	}
684 	/// ditto
685 	@property void shadowBufferSize(long v)
686 	{
687 		setShadowBufferSize(v);
688 	}
689 	/**
690 	Smooth shadow gradient length.
691 	*/
692 	@property double shadowGradientLength()
693 	{
694 		return getShadowGradientLength();
695 	}
696 	/// ditto
697 	@property void shadowGradientLength(double v)
698 	{
699 		setShadowGradientLength(v);
700 	}
701 	/**
702 	Shadow filter type. Use SHADOW_FILTER_* constants to set `shadow_filter`. Default value: `None`.
703 	*/
704 	@property Light2D.ShadowFilter shadowFilter()
705 	{
706 		return getShadowFilter();
707 	}
708 	/// ditto
709 	@property void shadowFilter(long v)
710 	{
711 		setShadowFilter(v);
712 	}
713 	/**
714 	Smoothing value for shadows.
715 	*/
716 	@property double shadowFilterSmooth()
717 	{
718 		return getShadowSmooth();
719 	}
720 	/// ditto
721 	@property void shadowFilterSmooth(double v)
722 	{
723 		setShadowSmooth(v);
724 	}
725 	/**
726 	The shadow mask. Used with $(D LightOccluder2D) to cast shadows. Only occluders with a matching shadow mask will cast shadows.
727 	*/
728 	@property long shadowItemCullMask()
729 	{
730 		return getItemShadowCullMask();
731 	}
732 	/// ditto
733 	@property void shadowItemCullMask(long v)
734 	{
735 		setItemShadowCullMask(v);
736 	}
737 }