1 /** 2 A color interpolator resource which can be used to generate colors between user-defined color points. 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.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.resource; 25 /** 26 A color interpolator resource which can be used to generate colors between user-defined color points. 27 28 Given a set of colors, this resource will interpolate them in order. This means that if you have color 1, color 2 and color 3, the ramp will interpolate from color 1 to color 2 and from color 2 to color 3. The ramp will initially have 2 colors (black and white), one (black) at ramp lower offset 0 and the other (white) at the ramp higher offset 1. 29 */ 30 @GodotBaseClass struct Gradient 31 { 32 package(godot) 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 GDNativeClassBinding 40 { 41 __gshared: 42 @GodotName("add_point") GodotMethod!(void, double, Color) addPoint; 43 @GodotName("get_color") GodotMethod!(Color, long) getColor; 44 @GodotName("get_colors") GodotMethod!(PoolColorArray) getColors; 45 @GodotName("get_offset") GodotMethod!(double, long) getOffset; 46 @GodotName("get_offsets") GodotMethod!(PoolRealArray) getOffsets; 47 @GodotName("get_point_count") GodotMethod!(long) getPointCount; 48 @GodotName("interpolate") GodotMethod!(Color, double) interpolate; 49 @GodotName("remove_point") GodotMethod!(void, long) removePoint; 50 @GodotName("set_color") GodotMethod!(void, long, Color) setColor; 51 @GodotName("set_colors") GodotMethod!(void, PoolColorArray) setColors; 52 @GodotName("set_offset") GodotMethod!(void, long, double) setOffset; 53 @GodotName("set_offsets") GodotMethod!(void, PoolRealArray) setOffsets; 54 } 55 /// 56 pragma(inline, true) bool opEquals(in Gradient other) const 57 { return _godot_object.ptr is other._godot_object.ptr; } 58 /// 59 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 60 { _godot_object.ptr = n; return null; } 61 /// 62 pragma(inline, true) bool opEquals(typeof(null) n) const 63 { return _godot_object.ptr is n; } 64 /// 65 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 66 mixin baseCasts; 67 /// Construct a new instance of Gradient. 68 /// Note: use `memnew!Gradient` instead. 69 static Gradient _new() 70 { 71 static godot_class_constructor constructor; 72 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Gradient"); 73 if(constructor is null) return typeof(this).init; 74 return cast(Gradient)(constructor()); 75 } 76 @disable new(size_t s); 77 /** 78 Adds the specified color to the end of the ramp, with the specified offset. 79 */ 80 void addPoint(in double offset, in Color color) 81 { 82 checkClassBinding!(typeof(this))(); 83 ptrcall!(void)(GDNativeClassBinding.addPoint, _godot_object, offset, color); 84 } 85 /** 86 Returns the color of the ramp color at index `point`. 87 */ 88 Color getColor(in long point) 89 { 90 checkClassBinding!(typeof(this))(); 91 return ptrcall!(Color)(GDNativeClassBinding.getColor, _godot_object, point); 92 } 93 /** 94 95 */ 96 PoolColorArray getColors() const 97 { 98 checkClassBinding!(typeof(this))(); 99 return ptrcall!(PoolColorArray)(GDNativeClassBinding.getColors, _godot_object); 100 } 101 /** 102 Returns the offset of the ramp color at index `point`. 103 */ 104 double getOffset(in long point) 105 { 106 checkClassBinding!(typeof(this))(); 107 return ptrcall!(double)(GDNativeClassBinding.getOffset, _godot_object, point); 108 } 109 /** 110 111 */ 112 PoolRealArray getOffsets() const 113 { 114 checkClassBinding!(typeof(this))(); 115 return ptrcall!(PoolRealArray)(GDNativeClassBinding.getOffsets, _godot_object); 116 } 117 /** 118 Returns the number of colors in the ramp. 119 */ 120 long getPointCount() const 121 { 122 checkClassBinding!(typeof(this))(); 123 return ptrcall!(long)(GDNativeClassBinding.getPointCount, _godot_object); 124 } 125 /** 126 Returns the interpolated color specified by `offset`. 127 */ 128 Color interpolate(in double offset) 129 { 130 checkClassBinding!(typeof(this))(); 131 return ptrcall!(Color)(GDNativeClassBinding.interpolate, _godot_object, offset); 132 } 133 /** 134 Removes the color at the index `point`. 135 */ 136 void removePoint(in long point) 137 { 138 checkClassBinding!(typeof(this))(); 139 ptrcall!(void)(GDNativeClassBinding.removePoint, _godot_object, point); 140 } 141 /** 142 Sets the color of the ramp color at index `point`. 143 */ 144 void setColor(in long point, in Color color) 145 { 146 checkClassBinding!(typeof(this))(); 147 ptrcall!(void)(GDNativeClassBinding.setColor, _godot_object, point, color); 148 } 149 /** 150 151 */ 152 void setColors(in PoolColorArray colors) 153 { 154 checkClassBinding!(typeof(this))(); 155 ptrcall!(void)(GDNativeClassBinding.setColors, _godot_object, colors); 156 } 157 /** 158 Sets the offset for the ramp color at index `point`. 159 */ 160 void setOffset(in long point, in double offset) 161 { 162 checkClassBinding!(typeof(this))(); 163 ptrcall!(void)(GDNativeClassBinding.setOffset, _godot_object, point, offset); 164 } 165 /** 166 167 */ 168 void setOffsets(in PoolRealArray offsets) 169 { 170 checkClassBinding!(typeof(this))(); 171 ptrcall!(void)(GDNativeClassBinding.setOffsets, _godot_object, offsets); 172 } 173 /** 174 Gradient's colors returned as a $(D PoolColorArray). 175 */ 176 @property PoolColorArray colors() 177 { 178 return getColors(); 179 } 180 /// ditto 181 @property void colors(PoolColorArray v) 182 { 183 setColors(v); 184 } 185 /** 186 Gradient's offsets returned as a $(D PoolRealArray). 187 */ 188 @property PoolRealArray offsets() 189 { 190 return getOffsets(); 191 } 192 /// ditto 193 @property void offsets(PoolRealArray v) 194 { 195 setOffsets(v); 196 } 197 }