Inheritance #

RefCounted

- AESContext
- AStar2D
- AStar3D
- AStarGrid2D
- AudioEffectInstance (1)
- AudioSample
- AudioSamplePlayback
- AudioStreamPlayback (5)
- CameraFeed
- CharFXTransform
- ConfigFile
- Crypto
- DTLSServer
- DirAccess
- ENetConnection
- EditorContextMenuPlugin
- EditorDebuggerPlugin
- EditorDebuggerSession
- EditorExportPlatform (6)
- EditorExportPlugin
- EditorExportPreset
- EditorFeatureProfile
- EditorFileSystemImportFormatSupportQuery
- EditorInspectorPlugin
- EditorResourceConversionPlugin
- EditorResourcePreviewGenerator
- EditorResourceTooltipPlugin
- EditorSceneFormatImporter (4)
- EditorScenePostImport
- EditorScenePostImportPlugin
- EditorScript
- EditorTranslationParserPlugin
- EncodedObjectAsID
- EngineProfiler
- Expression
- FileAccess
- GLTFObjectModelProperty
- HMACContext
- HTTPClient
- HashingContext
- ImageFormatLoader (1)
- JavaClass
- JavaObject
- JavaScriptObject
- KinematicCollision2D
- KinematicCollision3D
- Lightmapper (1)
- MeshConvexDecompositionSettings
- MeshDataTool
- MultiplayerAPI (2)
- Mutex
- NavigationPathQueryParameters2D
- NavigationPathQueryParameters3D
- NavigationPathQueryResult2D
- NavigationPathQueryResult3D
- Node3DGizmo (1)
- OggPacketSequencePlayback
- OpenXRAPIExtension
- PCKPacker
- PackedDataContainerRef
- PacketPeer (8)
- PhysicsPointQueryParameters2D
- PhysicsPointQueryParameters3D
- PhysicsRayQueryParameters2D
- PhysicsRayQueryParameters3D
- PhysicsShapeQueryParameters2D
- PhysicsShapeQueryParameters3D
- PhysicsTestMotionParameters2D
- PhysicsTestMotionParameters3D
- PhysicsTestMotionResult2D
- PhysicsTestMotionResult3D
- RDAttachmentFormat
- RDFramebufferPass
- RDPipelineColorBlendState
- RDPipelineColorBlendStateAttachment
- RDPipelineDepthStencilState
- RDPipelineMultisampleState
- RDPipelineRasterizationState
- RDPipelineSpecializationConstant
- RDSamplerState
- RDShaderSource
- RDTextureFormat
- RDTextureView
- RDUniform
- RDVertexAttribute
- RandomNumberGenerator
- RegEx
- RegExMatch
- RenderSceneBuffers (2)
- RenderSceneBuffersConfiguration
- Resource (103)
- ResourceFormatLoader
- ResourceFormatSaver
- ResourceImporter (16)
- SceneState
- SceneTreeTimer
- Semaphore
- SkinReference
- StreamPeer (5)
- SurfaceTool
- TCPServer
- TLSOptions
- TextLine
- TextParagraph
- TextServer (1)
- Thread
- TranslationDomain
- TriangleMesh
- Tween
- Tweener (5)
- UDPServer
- UPNP
- UPNPDevice
- WeakRef
- WebRTCPeerConnection (1)
- XMLParser
- XRInterface (4)
- XRPose
- XRTracker (2)
- ZIPPacker
- ZIPReader
Resource

- Animation
- AnimationLibrary
- AnimationNode (6)
- AnimationNodeStateMachinePlayback
- AnimationNodeStateMachineTransition
- AudioBusLayout
- AudioEffect (17)
- AudioStream (10)
- BitMap
- BoneMap
- ButtonGroup
- CameraAttributes (2)
- ColorPalette
- Compositor
- CompositorEffect
- CryptoKey
- Curve
- Curve2D
- Curve3D
- EditorNode3DGizmoPlugin
- EditorSettings
- Environment
- Font (3)
- GDExtension
- GLTFAccessor
- GLTFAnimation
- GLTFBufferView
- GLTFCamera
- GLTFDocument (1)
- GLTFDocumentExtension (1)
- GLTFLight
- GLTFMesh
- GLTFNode
- GLTFPhysicsBody
- GLTFPhysicsShape
- GLTFSkeleton
- GLTFSkin
- GLTFSpecGloss
- GLTFState (1)
- GLTFTexture
- GLTFTextureSampler
- Gradient
- Image
- ImporterMesh
- InputEvent (6)
- JSON
- LabelSettings
- LightmapGIData
- Material (9)
- Mesh (4)
- MeshLibrary
- MissingResource
- MultiMesh
- NavigationMesh
- NavigationMeshSourceGeometryData2D
- NavigationMeshSourceGeometryData3D
- NavigationPolygon
- Noise (1)
- Occluder3D (5)
- OccluderPolygon2D
- OggPacketSequence
- OpenXRAction
- OpenXRActionMap
- OpenXRActionSet
- OpenXRBindingModifier (2)
- OpenXRHapticBase (1)
- OpenXRIPBinding
- OpenXRInteractionProfile
- PackedDataContainer
- PackedScene
- PhysicsMaterial
- PolygonPathFinder
- RDShaderFile
- RDShaderSPIRV
- RichTextEffect
- SceneReplicationConfig
- Script (3)
- Shader (1)
- ShaderInclude
- Shape2D (8)
- Shape3D (9)
- Shortcut
- SkeletonModification2D (7)
- SkeletonModificationStack2D
- SkeletonProfile (1)
- Skin
- Sky
- SpriteFrames
- StyleBox (4)
- SyntaxHighlighter (2)
- Texture (3)
- Theme
- TileMapPattern
- TileSet
- TileSetSource (2)
- Translation (1)
- VideoStream (1)
- VideoStreamPlayback
- VisualShaderNode (62)
- VoxelGIData
- World2D
- World3D
- X509Certificate
Gradient
Table of contents

Gradient #

is_refcounted, is_instantiable, resource, core, not_builtin_classes

A color transition.

This resource describes a color transition by defining a set of colored points and how to interpolate between them.

See also Curve which supports more complex easing methods, but does not support colors.

Members #

var colors: PackedColorArray = PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)#

Gradient's colors as a PackedColorArray.

Note: Setting this property updates all colors at once. To update any color individually use set_color.

var interpolation_color_space = GRADIENT_COLOR_SPACE_SRGB#

The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always be in sRGB space. See ColorSpace for available modes.

Note: This setting has no effect when interpolation_mode is set to GRADIENT_INTERPOLATE_CONSTANT.

var interpolation_mode = GRADIENT_INTERPOLATE_LINEAR#

The algorithm used to interpolate between points of the gradient. See InterpolationMode for available modes.

var offsets: PackedFloat32Array = PackedFloat32Array(0, 1)#

Gradient's offsets as a PackedFloat32Array.

Note: Setting this property updates all offsets at once. To update any offset individually use set_offset.

Methods #

func add_point(color: Color) -> void#

Adds the specified color to the gradient, with the specified offset.

func get_color(point: int) -> Color#

Returns the color of the gradient color at index point.

func get_offset(point: int) -> float#

Returns the offset of the gradient color at index point.

const func get_point_count() -> int#

Returns the number of colors in the gradient.

func remove_point(point: int) -> void#

Removes the color at index point.

func reverse() -> void#

Reverses/mirrors the gradient.

Note: This method mirrors all points around the middle of the gradient, which may produce unexpected results when interpolation_mode is set to GRADIENT_INTERPOLATE_CONSTANT.

func sample(offset: float) -> Color#

Returns the interpolated color specified by offset.

func set_color(color: Color) -> void#

Sets the color of the gradient color at index point.

func set_offset(offset: float) -> void#

Sets the offset for the gradient color at index point.

Annotations #

Constants #

const GRADIENT_INTERPOLATE_LINEAR = 0 enum InterpolationMode#

Linear interpolation.

const GRADIENT_INTERPOLATE_CONSTANT = 1 enum InterpolationMode#

Constant interpolation, color changes abruptly at each point and stays uniform between. This might cause visible aliasing when used for a gradient texture in some cases.

const GRADIENT_INTERPOLATE_CUBIC = 2 enum InterpolationMode#

Cubic interpolation.

const GRADIENT_COLOR_SPACE_SRGB = 0 enum ColorSpace#

sRGB color space.

const GRADIENT_COLOR_SPACE_LINEAR_SRGB = 1 enum ColorSpace#

Linear sRGB color space.

const GRADIENT_COLOR_SPACE_OKLAB = 2 enum ColorSpace#

Oklab color space. This color space provides a smooth and uniform-looking transition between colors.

Constructors #

Enums #

InterpolationMode#

enum InterpolationMode { GRADIENT_INTERPOLATE_LINEAR = 0, GRADIENT_INTERPOLATE_CONSTANT = 1, GRADIENT_INTERPOLATE_CUBIC = 2, }

ColorSpace#

enum ColorSpace { GRADIENT_COLOR_SPACE_SRGB = 0, GRADIENT_COLOR_SPACE_LINEAR_SRGB = 1, GRADIENT_COLOR_SPACE_OKLAB = 2, }

Operators #

Signals #

Theme Items #

Tutorials #