/**************************************************************************/1/* curve_texture.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/resources/curve.h"33#include "scene/resources/texture.h"3435class CurveTexture : public Texture2D {36GDCLASS(CurveTexture, Texture2D);37RES_BASE_EXTENSION("curvetex")38public:39enum TextureMode {40TEXTURE_MODE_RGB,41TEXTURE_MODE_RED,42};4344private:45mutable RID _texture;46Ref<Curve> _curve;47int _width = 256;48int _current_width = 0;49TextureMode texture_mode = TEXTURE_MODE_RGB;50TextureMode _current_texture_mode = TEXTURE_MODE_RGB;5152void _update();5354protected:55static void _bind_methods();5657public:58void set_width(int p_width);59int get_width() const override;6061void set_texture_mode(TextureMode p_mode);62TextureMode get_texture_mode() const;6364void ensure_default_setup(float p_min = 0, float p_max = 1);6566void set_curve(Ref<Curve> p_curve);67Ref<Curve> get_curve() const;6869virtual RID get_rid() const override;7071virtual int get_height() const override { return 1; }72virtual bool has_alpha() const override { return false; }7374~CurveTexture();75};7677VARIANT_ENUM_CAST(CurveTexture::TextureMode)7879class CurveXYZTexture : public Texture2D {80GDCLASS(CurveXYZTexture, Texture2D);81RES_BASE_EXTENSION("curvetex")8283private:84mutable RID _texture;85Ref<Curve> _curve_x;86Ref<Curve> _curve_y;87Ref<Curve> _curve_z;88int _width = 256;89int _current_width = 0;9091void _update();9293protected:94static void _bind_methods();9596public:97void set_width(int p_width);98int get_width() const override;99100void ensure_default_setup(float p_min = 0, float p_max = 1);101102void set_curve_x(Ref<Curve> p_curve);103Ref<Curve> get_curve_x() const;104105void set_curve_y(Ref<Curve> p_curve);106Ref<Curve> get_curve_y() const;107108void set_curve_z(Ref<Curve> p_curve);109Ref<Curve> get_curve_z() const;110111virtual RID get_rid() const override;112113virtual int get_height() const override { return 1; }114virtual bool has_alpha() const override { return false; }115116~CurveXYZTexture();117};118119120