1 /**
2 A $(D Texture) based on an $(D Image).
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.imagetexture;
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.texture;
24 import godot.image;
25 import godot.resource;
26 import godot.reference;
27 /**
28 A $(D Texture) based on an $(D Image).
29 
30 Can be created from an $(D Image) with $(D createFromImage).
31 */
32 @GodotBaseClass struct ImageTexture
33 {
34 	enum string _GODOT_internal_name = "ImageTexture";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Texture _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("create") GodotMethod!(void, long, long, long, long) create;
45 		@GodotName("create_from_image") GodotMethod!(void, Image, long) createFromImage;
46 		@GodotName("get_format") GodotMethod!(Image.Format) getFormat;
47 		@GodotName("load") GodotMethod!(GodotError, String) load;
48 		@GodotName("set_data") GodotMethod!(void, Image) setData;
49 		@GodotName("set_storage") GodotMethod!(void, long) setStorage;
50 		@GodotName("get_storage") GodotMethod!(ImageTexture.Storage) getStorage;
51 		@GodotName("set_lossy_storage_quality") GodotMethod!(void, double) setLossyStorageQuality;
52 		@GodotName("get_lossy_storage_quality") GodotMethod!(double) getLossyStorageQuality;
53 		@GodotName("set_size_override") GodotMethod!(void, Vector2) setSizeOverride;
54 		@GodotName("_reload_hook") GodotMethod!(void, RID) _reloadHook;
55 	}
56 	bool opEquals(in ImageTexture other) const { return _godot_object.ptr is other._godot_object.ptr; }
57 	ImageTexture opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
58 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
59 	mixin baseCasts;
60 	static ImageTexture _new()
61 	{
62 		static godot_class_constructor constructor;
63 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ImageTexture");
64 		if(constructor is null) return typeof(this).init;
65 		return cast(ImageTexture)(constructor());
66 	}
67 	@disable new(size_t s);
68 	/// 
69 	enum Storage : int
70 	{
71 		/**
72 		$(D Image) data is stored raw and unaltered.
73 		*/
74 		storageRaw = 0,
75 		/**
76 		$(D Image) data is compressed with a lossy algorithm. You can set the storage quality with $(D setLossyStorageQuality).
77 		*/
78 		storageCompressLossy = 1,
79 		/**
80 		$(D Image) data is compressed with a lossless algorithm.
81 		*/
82 		storageCompressLossless = 2,
83 	}
84 	/// 
85 	enum Constants : int
86 	{
87 		storageRaw = 0,
88 		storageCompressLossy = 1,
89 		storageCompressLossless = 2,
90 	}
91 	/**
92 	Create a new `ImageTexture` with "width" and "height".
93 	"format" one of $(D Image).FORMAT_*.
94 	"flags" one or more of $(D Texture).FLAG_*.
95 	*/
96 	void create(in long width, in long height, in long format, in long flags = 7)
97 	{
98 		checkClassBinding!(typeof(this))();
99 		ptrcall!(void)(_classBinding.create, _godot_object, width, height, format, flags);
100 	}
101 	/**
102 	Create a new `ImageTexture` from an $(D Image) with "flags" from $(D Texture).FLAG_*. An sRGB to linear color space conversion can take place, according to $(D Image).FORMAT_*.
103 	*/
104 	void createFromImage(Image image, in long flags = 7)
105 	{
106 		checkClassBinding!(typeof(this))();
107 		ptrcall!(void)(_classBinding.createFromImage, _godot_object, image, flags);
108 	}
109 	/**
110 	Return the format of the `ImageTexture`, one of $(D Image).FORMAT_*.
111 	*/
112 	Image.Format getFormat() const
113 	{
114 		checkClassBinding!(typeof(this))();
115 		return ptrcall!(Image.Format)(_classBinding.getFormat, _godot_object);
116 	}
117 	/**
118 	Load an `ImageTexture` from a file path.
119 	*/
120 	GodotError load(StringArg0)(in StringArg0 path)
121 	{
122 		checkClassBinding!(typeof(this))();
123 		return ptrcall!(GodotError)(_classBinding.load, _godot_object, path);
124 	}
125 	/**
126 	Set the $(D Image) of this `ImageTexture`.
127 	*/
128 	void setData(Image image)
129 	{
130 		checkClassBinding!(typeof(this))();
131 		ptrcall!(void)(_classBinding.setData, _godot_object, image);
132 	}
133 	/**
134 	
135 	*/
136 	void setStorage(in long mode)
137 	{
138 		checkClassBinding!(typeof(this))();
139 		ptrcall!(void)(_classBinding.setStorage, _godot_object, mode);
140 	}
141 	/**
142 	
143 	*/
144 	ImageTexture.Storage getStorage() const
145 	{
146 		checkClassBinding!(typeof(this))();
147 		return ptrcall!(ImageTexture.Storage)(_classBinding.getStorage, _godot_object);
148 	}
149 	/**
150 	
151 	*/
152 	void setLossyStorageQuality(in double quality)
153 	{
154 		checkClassBinding!(typeof(this))();
155 		ptrcall!(void)(_classBinding.setLossyStorageQuality, _godot_object, quality);
156 	}
157 	/**
158 	
159 	*/
160 	double getLossyStorageQuality() const
161 	{
162 		checkClassBinding!(typeof(this))();
163 		return ptrcall!(double)(_classBinding.getLossyStorageQuality, _godot_object);
164 	}
165 	/**
166 	Resizes the `ImageTexture` to the specified dimensions.
167 	*/
168 	void setSizeOverride(in Vector2 size)
169 	{
170 		checkClassBinding!(typeof(this))();
171 		ptrcall!(void)(_classBinding.setSizeOverride, _godot_object, size);
172 	}
173 	/**
174 	
175 	*/
176 	void _reloadHook(in RID rid)
177 	{
178 		Array _GODOT_args = Array.empty_array;
179 		_GODOT_args.append(rid);
180 		String _GODOT_method_name = String("_reload_hook");
181 		this.callv(_GODOT_method_name, _GODOT_args);
182 	}
183 	/**
184 	The storage type (raw, lossy, or compressed).
185 	*/
186 	@property ImageTexture.Storage storage()
187 	{
188 		return getStorage();
189 	}
190 	/// ditto
191 	@property void storage(long v)
192 	{
193 		setStorage(v);
194 	}
195 	/**
196 	The storage quality for `ImageTexture`.STORAGE_COMPRESS_LOSSY.
197 	*/
198 	@property double lossyQuality()
199 	{
200 		return getLossyStorageQuality();
201 	}
202 	/// ditto
203 	@property void lossyQuality(double v)
204 	{
205 		setLossyStorageQuality(v);
206 	}
207 }