/**************************************************************************/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/texture.h"3334class CurveTexture : public Texture2D {35GDCLASS(CurveTexture, Texture2D);36RES_BASE_EXTENSION("curvetex")37public:38enum TextureMode {39TEXTURE_MODE_RGB,40TEXTURE_MODE_RED,41};4243private:44mutable RID _texture;45Ref<Curve> _curve;46int _width = 256;47int _current_width = 0;48TextureMode texture_mode = TEXTURE_MODE_RGB;49TextureMode _current_texture_mode = TEXTURE_MODE_RGB;5051void _update();5253protected:54static void _bind_methods();5556public:57void set_width(int p_width);58int get_width() const override;5960void set_texture_mode(TextureMode p_mode);61TextureMode get_texture_mode() const;6263void ensure_default_setup(float p_min = 0, float p_max = 1);6465void set_curve(Ref<Curve> p_curve);66Ref<Curve> get_curve() const;6768virtual RID get_rid() const override;6970virtual int get_height() const override { return 1; }71virtual bool has_alpha() const override { return false; }7273~CurveTexture();74};7576VARIANT_ENUM_CAST(CurveTexture::TextureMode)7778class CurveXYZTexture : public Texture2D {79GDCLASS(CurveXYZTexture, Texture2D);80RES_BASE_EXTENSION("curvetex")8182private:83mutable RID _texture;84Ref<Curve> _curve_x;85Ref<Curve> _curve_y;86Ref<Curve> _curve_z;87int _width = 256;88int _current_width = 0;8990void _update();9192protected:93static void _bind_methods();9495public:96void set_width(int p_width);97int get_width() const override;9899void ensure_default_setup(float p_min = 0, float p_max = 1);100101void set_curve_x(Ref<Curve> p_curve);102Ref<Curve> get_curve_x() const;103104void set_curve_y(Ref<Curve> p_curve);105Ref<Curve> get_curve_y() const;106107void set_curve_z(Ref<Curve> p_curve);108Ref<Curve> get_curve_z() const;109110virtual RID get_rid() const override;111112virtual int get_height() const override { return 1; }113virtual bool has_alpha() const override { return false; }114115~CurveXYZTexture();116};117118119