1 /** 2 Color interpolator node. 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.gradient; 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.resource; 24 import godot.reference; 25 /** 26 Color interpolator node. 27 28 Given a set of colors, this node will interpolate them in order, meaning, that if you have color 1, color 2 and color3, the ramp will interpolate (generate the colors between two colors) from color 1 to color 2 and from color 2 to color 3. Initially the ramp will have 2 colors (black and white), one (black) at ramp lower offset offset 0 and the other (white) at the ramp higher offset 1. 29 */ 30 @GodotBaseClass struct Gradient 31 { 32 enum string _GODOT_internal_name = "Gradient"; 33 public: 34 @nogc nothrow: 35 union { godot_object _godot_object; Resource _GODOT_base; } 36 alias _GODOT_base this; 37 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 38 package(godot) __gshared bool _classBindingInitialized = false; 39 package(godot) static struct _classBinding 40 { 41 __gshared: 42 @GodotName("add_point") GodotMethod!(void, double, Color) addPoint; 43 @GodotName("remove_point") GodotMethod!(void, long) removePoint; 44 @GodotName("set_offset") GodotMethod!(void, long, double) setOffset; 45 @GodotName("get_offset") GodotMethod!(double, long) getOffset; 46 @GodotName("set_color") GodotMethod!(void, long, Color) setColor; 47 @GodotName("get_color") GodotMethod!(Color, long) getColor; 48 @GodotName("interpolate") GodotMethod!(Color, double) interpolate; 49 @GodotName("get_point_count") GodotMethod!(long) getPointCount; 50 @GodotName("set_offsets") GodotMethod!(void, PoolRealArray) setOffsets; 51 @GodotName("get_offsets") GodotMethod!(PoolRealArray) getOffsets; 52 @GodotName("set_colors") GodotMethod!(void, PoolColorArray) setColors; 53 @GodotName("get_colors") GodotMethod!(PoolColorArray) getColors; 54 } 55 bool opEquals(in Gradient other) const { return _godot_object.ptr is other._godot_object.ptr; } 56 Gradient opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 57 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 58 mixin baseCasts; 59 static Gradient _new() 60 { 61 static godot_class_constructor constructor; 62 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Gradient"); 63 if(constructor is null) return typeof(this).init; 64 return cast(Gradient)(constructor()); 65 } 66 @disable new(size_t s); 67 /** 68 Adds the specified color to the end of the ramp, with the specified offset 69 */ 70 void addPoint(in double offset, in Color color) 71 { 72 checkClassBinding!(typeof(this))(); 73 ptrcall!(void)(_classBinding.addPoint, _godot_object, offset, color); 74 } 75 /** 76 Removes the color at the index $(I offset) 77 */ 78 void removePoint(in long offset) 79 { 80 checkClassBinding!(typeof(this))(); 81 ptrcall!(void)(_classBinding.removePoint, _godot_object, offset); 82 } 83 /** 84 Sets the offset for the ramp color at index $(I point) 85 */ 86 void setOffset(in long point, in double offset) 87 { 88 checkClassBinding!(typeof(this))(); 89 ptrcall!(void)(_classBinding.setOffset, _godot_object, point, offset); 90 } 91 /** 92 Returns the offset of the ramp color at index $(I point) 93 */ 94 double getOffset(in long point) const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(double)(_classBinding.getOffset, _godot_object, point); 98 } 99 /** 100 Sets the color of the ramp color at index $(I point) 101 */ 102 void setColor(in long point, in Color color) 103 { 104 checkClassBinding!(typeof(this))(); 105 ptrcall!(void)(_classBinding.setColor, _godot_object, point, color); 106 } 107 /** 108 Returns the color of the ramp color at index $(I point) 109 */ 110 Color getColor(in long point) const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(Color)(_classBinding.getColor, _godot_object, point); 114 } 115 /** 116 Returns the interpolated color specified by $(I offset) 117 */ 118 Color interpolate(in double offset) 119 { 120 checkClassBinding!(typeof(this))(); 121 return ptrcall!(Color)(_classBinding.interpolate, _godot_object, offset); 122 } 123 /** 124 Returns the number of colors in the ramp 125 */ 126 long getPointCount() const 127 { 128 checkClassBinding!(typeof(this))(); 129 return ptrcall!(long)(_classBinding.getPointCount, _godot_object); 130 } 131 /** 132 133 */ 134 void setOffsets(in PoolRealArray offsets) 135 { 136 checkClassBinding!(typeof(this))(); 137 ptrcall!(void)(_classBinding.setOffsets, _godot_object, offsets); 138 } 139 /** 140 141 */ 142 PoolRealArray getOffsets() const 143 { 144 checkClassBinding!(typeof(this))(); 145 return ptrcall!(PoolRealArray)(_classBinding.getOffsets, _godot_object); 146 } 147 /** 148 149 */ 150 void setColors(in PoolColorArray colors) 151 { 152 checkClassBinding!(typeof(this))(); 153 ptrcall!(void)(_classBinding.setColors, _godot_object, colors); 154 } 155 /** 156 157 */ 158 PoolColorArray getColors() const 159 { 160 checkClassBinding!(typeof(this))(); 161 return ptrcall!(PoolColorArray)(_classBinding.getColors, _godot_object); 162 } 163 /** 164 Gradient's offsets returned as a $(D PoolRealArray). 165 */ 166 @property PoolRealArray offsets() 167 { 168 return getOffsets(); 169 } 170 /// ditto 171 @property void offsets(PoolRealArray v) 172 { 173 setOffsets(v); 174 } 175 /** 176 Gradient's colors returned as a $(D PoolColorArray). 177 */ 178 @property PoolColorArray colors() 179 { 180 return getColors(); 181 } 182 /// ditto 183 @property void colors(PoolColorArray v) 184 { 185 setColors(v); 186 } 187 }