GradientTexture2D
A Gradient texture with linear, radial, square or conic fill.
Assign Gradient, dimensions and normalized FillFrom/FillTo coordinates. Defaults are 64×64, Fill=Linear, FillFrom=(0,0), FillTo=(1,0), Repeat=None, UseHdr=false and Gradient=null. The constructor does not create a Gradient.
Linear uses projection onto an axis, Radial distance, Square maximum axis distance, and Conic angle. Repeat changes coordinates while generating the pattern; it does not configure the finished texture’s material sampler. Coincident FillFrom and FillTo make every pixel sample Gradient.Sample(0).
This complete checked factory creates a horizontal ramp; assign the returned Texture2D to a compatible element’s Texture property:
using Reckfell;
public static class GradientRamp
{
public static GradientTexture2D Create()
{
using var gradient = new Gradient
{
Offsets = new[] { 0.0f, 1.0f },
Colors = new[] { Colors.Black, Colors.White },
InterpolationMode = Gradient.InterpolationModeEnum.Linear,
InterpolationColorSpace = Gradient.ColorSpace.Srgb,
};
return new GradientTexture2D
{
Gradient = gradient,
Width = 256,
Height = 32,
Fill = GradientTexture2D.FillEnum.Linear,
FillFrom = Vector2.Zero,
FillTo = new Vector2(1, 0),
Repeat = GradientTexture2D.RepeatEnum.None,
};
}
}Changing the shared Gradient updates connected textures; GetImage forces pending generation to finish. Its image data is independent. A null source does not erase existing pixels. UseHdr selects RGBAF instead of clamped RGBA8 but does not enable environment effects or monitor HDR.
Fill modes, Repeat/Mirror, HDR/LDR, regeneration and independent resource reload were checked in Forward+/Vulkan. The example generates texture data, not a graphics-quality illustration. Shader sampling, all resolutions, performance and other backends were not established by this run.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
GradientTexture2DConstructor
public GradientTexture2D();Creates a texture with no assigned Gradient and no generated pixels. Default parameter values do not mean an image already exists.
Properties8
FillProperty
public GradientTexture2D.FillEnum Fill { get; set; }Sampling-coordinate shape: Linear projects onto FillFrom→FillTo; Radial uses distance from FillFrom; Square uses the maximum axis distance; Conic uses the angle around FillFrom with its zero ray toward FillTo. Defaults to Linear.
FillFromProperty
public Vector2 FillFrom { get; set; }Fill origin in normalized texture coordinates, initially (0, 0). It is the center for Radial, Square and Conic. These are not pixel coordinates; the setter does not clamp the vector to 0…1.
FillToProperty
public Vector2 FillTo { get; set; }Second normalized point, initially (1, 0). Defines the linear-axis end, Radial/Square scale or Conic zero ray. When equal to FillFrom, every pixel samples Gradient.Sample(0), regardless of Repeat.
GradientProperty
public Gradient Gradient { get; set; }Color source, null in the C# constructor by default. This is a shared reference, not a copy. Gradient changes queue pixel regeneration; GetImage synchronously handles a pending update. Assigning null disconnects the source but does not clear pixels already created.
HeightProperty
public int Height { get; set; }Height in pixels, initially 64. Accepted range is 1…16384; the image remains a two-dimensional grid. This resource does not generate mipmaps.
RepeatProperty
public GradientTexture2D.RepeatEnum Repeat { get; set; }Gradient-coordinate handling outside 0…1: None clamps, Repeat wraps with period 1, Mirror reflects with period 2. Repeat maps an exact coordinate of 1 to 0. This generates the pattern; it is not the sampler-repeat mode for the finished texture.
UseHdrProperty
public bool UseHdr { get; set; }False by default: RGBA8 pixels with 0…1 clamping and quantization. True selects RGBAF and retains extended range, including values above 1. This controls texture data format; it does not independently enable glow or HDR window output.
WidthProperty
public int Width { get; set; }Width in pixels, initially 64. The setter accepts 1…16384, which does not guarantee available GPU memory. Changing it queues image regeneration.
Methods14
GetFillGradientTexture2D.FillEnum
public GradientTexture2D.FillEnum GetFill();Returns the value of GradientTexture2D.Fill.
GetFillFromVector2
public Vector2 GetFillFrom();Returns the value of GradientTexture2D.FillFrom.
GetFillToVector2
public Vector2 GetFillTo();Returns the value of GradientTexture2D.FillTo.
GetGradientGradient
public Gradient GetGradient();Returns the value of GradientTexture2D.Gradient.
GradientThe current Gradient source, or null when unassigned. This is a shared reference, not a copy.
GetRepeatGradientTexture2D.RepeatEnum
public GradientTexture2D.RepeatEnum GetRepeat();Returns the value of GradientTexture2D.Repeat.
IsUsingHdrbool
public bool IsUsingHdr();Returns the value of GradientTexture2D.UseHdr.
SetFillvoid
public void SetFill(GradientTexture2D.FillEnum fill);Assigns the value of GradientTexture2D.Fill.
| Name | Type | Default |
|---|---|---|
fill | GradientTexture2D.FillEnum | — |
fillLinear, Radial, Square or Conic mode.
SetFillFromvoid
public void SetFillFrom(Vector2 fillFrom);Assigns the value of GradientTexture2D.FillFrom.
| Name | Type | Default |
|---|---|---|
fillFrom | Vector2 | — |
fillFromA normalized origin or center, not a pixel position.
SetFillTovoid
public void SetFillTo(Vector2 fillTo);Assigns the value of GradientTexture2D.FillTo.
| Name | Type | Default |
|---|---|---|
fillTo | Vector2 | — |
fillToA normalized second point defining the axis, scale or zero ray.
SetGradientvoid
public void SetGradient(Gradient gradient);Assigns the value of GradientTexture2D.Gradient.
| Name | Type | Default |
|---|---|---|
gradient | Gradient | — |
gradientA shared Gradient or null. Null does not remove previously generated pixels.
SetHeightvoid
public void SetHeight(int height);Assigns the value of GradientTexture2D.Height.
| Name | Type | Default |
|---|---|---|
height | int | — |
heightHeight in pixels, 1…16384; account for the selected size’s memory cost.
SetRepeatvoid
public void SetRepeat(GradientTexture2D.RepeatEnum repeat);Assigns the value of GradientTexture2D.Repeat.
| Name | Type | Default |
|---|---|---|
repeat | GradientTexture2D.RepeatEnum | — |
repeatNone, Repeat or Mirror for the generated pattern coordinate.
SetUseHdrvoid
public void SetUseHdr(bool enabled);Assigns the value of GradientTexture2D.UseHdr.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledTrue for RGBAF, false for clamped and quantized RGBA8.
SetWidthvoid
public void SetWidth(int width);Assigns the value of GradientTexture2D.Width.
| Name | Type | Default |
|---|---|---|
width | int | — |
widthWidth in pixels, 1…16384; available GPU memory depends on the device.
GradientTexture2D.FillEnum
| Value | Description |
|---|---|
Conic = 3 | The colors are linearly interpolated in a cone pattern. |
Linear = 0 | The colors are linearly interpolated in a straight line. |
Radial = 1 | The colors are linearly interpolated in a circular pattern. |
Square = 2 | The colors are linearly interpolated in a square pattern. |
GradientTexture2D.RepeatEnum
| Value | Description |
|---|---|
Mirror = 2 | The texture is filled starting from |
None = 0 | The gradient fill is restricted to the range defined by |
Repeat = 1 | The texture is filled starting from |