JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
juce::ColourGradient Class Referencefinal

Describes the layout and colours that should be used to paint a colour gradient. More...

#include "juce_ColourGradient.h"

Public Member Functions

 ColourGradient () noexcept
 Creates an uninitialised gradient.
 
 ColourGradient (const ColourGradient &)
 
 ColourGradient (ColourGradient &&) noexcept
 
ColourGradientoperator= (const ColourGradient &)
 
ColourGradientoperator= (ColourGradient &&) noexcept
 
 ColourGradient (Colour colour1, float x1, float y1, Colour colour2, float x2, float y2, bool isRadial)
 Creates a gradient object.
 
 ColourGradient (Colour colour1, Point< float > point1, Colour colour2, Point< float > point2, bool isRadial)
 Creates a gradient object.
 
 ~ColourGradient ()
 Destructor.
 
void clearColours ()
 Removes any colours that have been added.
 
int addColour (double proportionAlongGradient, Colour colour)
 Adds a colour at a point along the length of the gradient.
 
void removeColour (int index)
 Removes one of the colours from the gradient.
 
void multiplyOpacity (float multiplier) noexcept
 Multiplies the alpha value of all the colours by the given scale factor.
 
int getNumColours () const noexcept
 Returns the number of colour-stops that have been added.
 
double getColourPosition (int index) const noexcept
 Returns the position along the length of the gradient of the colour with this index.
 
Colour getColour (int index) const noexcept
 Returns the colour that was added with a given index.
 
void setColour (int index, Colour newColour) noexcept
 Changes the colour at a given index.
 
Colour getColourAtPosition (double position) const noexcept
 Returns the an interpolated colour at any position along the gradient.
 
int createLookupTable (const AffineTransform &transform, HeapBlock< PixelARGB > &resultLookupTable) const
 Creates a set of interpolated premultiplied ARGB values.
 
void createLookupTable (PixelARGB *resultLookupTable, int numEntries) const noexcept
 Creates a set of interpolated premultiplied ARGB values.
 
template<size_t NumEntries>
void createLookupTable (PixelARGB(&resultLookupTable)[NumEntries]) const noexcept
 Creates a set of interpolated premultiplied ARGB values.
 
bool isOpaque () const noexcept
 Returns true if all colours are opaque.
 
bool isInvisible () const noexcept
 Returns true if all colours are completely transparent.
 
bool operator== (const ColourGradient &) const noexcept
 
bool operator!= (const ColourGradient &) const noexcept
 

Static Public Member Functions

static ColourGradient vertical (Colour colour1, float y1, Colour colour2, float y2)
 Creates a vertical linear gradient between two Y coordinates.
 
static ColourGradient horizontal (Colour colour1, float x1, Colour colour2, float x2)
 Creates a horizontal linear gradient between two X coordinates.
 
template<typename Type >
static ColourGradient vertical (Colour colourTop, Colour colourBottom, Rectangle< Type > area)
 Creates a vertical linear gradient from top to bottom in a rectangle.
 
template<typename Type >
static ColourGradient horizontal (Colour colourLeft, Colour colourRight, Rectangle< Type > area)
 Creates a horizontal linear gradient from right to left in a rectangle.
 

Public Attributes

Point< floatpoint1
 
Point< floatpoint2
 
bool isRadial
 If true, the gradient should be filled circularly, centred around point1, with point2 defining a point on the circumference.
 

Detailed Description

Describes the layout and colours that should be used to paint a colour gradient.

See also
Graphics::setGradientFill

@tags{Graphics}

Definition at line 37 of file juce_ColourGradient.h.

Constructor & Destructor Documentation

◆ ColourGradient() [1/5]

juce::ColourGradient::ColourGradient ( )
noexcept

Creates an uninitialised gradient.

If you use this constructor instead of the other one, be sure to set all the object's public member variables before using it!

Definition at line 29 of file juce_ColourGradient.cpp.

◆ ColourGradient() [2/5]

juce::ColourGradient::ColourGradient ( const ColourGradient other)

Definition at line 39 of file juce_ColourGradient.cpp.

◆ ColourGradient() [3/5]

juce::ColourGradient::ColourGradient ( ColourGradient &&  other)
noexcept

Definition at line 43 of file juce_ColourGradient.cpp.

◆ ColourGradient() [4/5]

juce::ColourGradient::ColourGradient ( Colour  colour1,
float  x1,
float  y1,
Colour  colour2,
float  x2,
float  y2,
bool  isRadial 
)

Creates a gradient object.

(x1, y1) is the location to draw with colour1. Likewise (x2, y2) is where colour2 should be. In between them there's a gradient.

If isRadial is true, the colours form a circular gradient with (x1, y1) at its centre.

The alpha transparencies of the colours are used, so note that if you blend from transparent to a solid colour, the RGB of the transparent colour will become visible in parts of the gradient. e.g. blending from Colour::transparentBlack to Colours::white will produce a muddy grey colour midway, but Colour::transparentWhite to Colours::white will be white all the way across.

See also
ColourGradient

Definition at line 66 of file juce_ColourGradient.cpp.

◆ ColourGradient() [5/5]

juce::ColourGradient::ColourGradient ( Colour  colour1,
Point< float point1,
Colour  colour2,
Point< float point2,
bool  isRadial 
)

Creates a gradient object.

point1 is the location to draw with colour1. Likewise point2 is where colour2 should be. In between them there's a gradient.

If isRadial is true, the colours form a circular gradient with point1 at its centre.

The alpha transparencies of the colours are used, so note that if you blend from transparent to a solid colour, the RGB of the transparent colour will become visible in parts of the gradient. e.g. blending from Colour::transparentBlack to Colours::white will produce a muddy grey colour midway, but Colour::transparentWhite to Colours::white will be white all the way across.

See also
ColourGradient

Definition at line 73 of file juce_ColourGradient.cpp.

◆ ~ColourGradient()

juce::ColourGradient::~ColourGradient ( )

Destructor.

Definition at line 83 of file juce_ColourGradient.cpp.

Member Function Documentation

◆ addColour()

int juce::ColourGradient::addColour ( double  proportionAlongGradient,
Colour  colour 
)

Adds a colour at a point along the length of the gradient.

This allows the gradient to go through a spectrum of colours, instead of just a start and end colour.

Parameters
proportionAlongGradienta value between 0 and 1.0, which is the proportion of the distance along the line between the two points at which the colour should occur.
colourthe colour that should be used at this point
Returns
the index at which the new point was added

Definition at line 113 of file juce_ColourGradient.cpp.

◆ clearColours()

void juce::ColourGradient::clearColours ( )

Removes any colours that have been added.

This will also remove any start and end colours, so the gradient won't work. You'll need to add more colours with addColour().

Definition at line 108 of file juce_ColourGradient.cpp.

◆ createLookupTable() [1/3]

int juce::ColourGradient::createLookupTable ( const AffineTransform transform,
HeapBlock< PixelARGB > &  resultLookupTable 
) const

Creates a set of interpolated premultiplied ARGB values.

This will resize the HeapBlock, fill it with the colours, and will return the number of colours that it added. When calling this, the ColourGradient must have at least 2 colour stops specified.

Definition at line 228 of file juce_ColourGradient.cpp.

◆ createLookupTable() [2/3]

void juce::ColourGradient::createLookupTable ( PixelARGB resultLookupTable,
int  numEntries 
) const
noexcept

Creates a set of interpolated premultiplied ARGB values.

This will fill an array of a user-specified size with the gradient, interpolating to fit. The numEntries argument specifies the size of the array, and this size must be greater than zero. When calling this, the ColourGradient must have at least 2 colour stops specified.

Definition at line 197 of file juce_ColourGradient.cpp.

◆ createLookupTable() [3/3]

template<size_t NumEntries>
void juce::ColourGradient::createLookupTable ( PixelARGB(&)  resultLookupTable[NumEntries]) const
noexcept

Creates a set of interpolated premultiplied ARGB values.

This will fill an array of a user-specified size with the gradient, interpolating to fit. When calling this, the ColourGradient must have at least 2 colour stops specified.

Definition at line 193 of file juce_ColourGradient.h.

◆ getColour()

Colour juce::ColourGradient::getColour ( int  index) const
noexcept

Returns the colour that was added with a given index.

The index is from 0 to getNumColours() - 1.

Definition at line 161 of file juce_ColourGradient.cpp.

◆ getColourAtPosition()

Colour juce::ColourGradient::getColourAtPosition ( double  position) const
noexcept

Returns the an interpolated colour at any position along the gradient.

Parameters
positionthe position along the gradient, between 0 and 1

Definition at line 175 of file juce_ColourGradient.cpp.

◆ getColourPosition()

double juce::ColourGradient::getColourPosition ( int  index) const
noexcept

Returns the position along the length of the gradient of the colour with this index.

The index is from 0 to getNumColours() - 1. The return value will be between 0.0 and 1.0

Definition at line 153 of file juce_ColourGradient.cpp.

◆ getNumColours()

int juce::ColourGradient::getNumColours ( ) const
noexcept

Returns the number of colour-stops that have been added.

Definition at line 148 of file juce_ColourGradient.cpp.

◆ horizontal() [1/2]

ColourGradient juce::ColourGradient::horizontal ( Colour  colour1,
float  x1,
Colour  colour2,
float  x2 
)
static

Creates a horizontal linear gradient between two X coordinates.

Definition at line 90 of file juce_ColourGradient.cpp.

◆ horizontal() [2/2]

template<typename Type >
static ColourGradient juce::ColourGradient::horizontal ( Colour  colourLeft,
Colour  colourRight,
Rectangle< Type >  area 
)
static

Creates a horizontal linear gradient from right to left in a rectangle.

Definition at line 113 of file juce_ColourGradient.h.

◆ isInvisible()

bool juce::ColourGradient::isInvisible ( ) const
noexcept

Returns true if all colours are completely transparent.

Definition at line 250 of file juce_ColourGradient.cpp.

◆ isOpaque()

bool juce::ColourGradient::isOpaque ( ) const
noexcept

Returns true if all colours are opaque.

Definition at line 241 of file juce_ColourGradient.cpp.

◆ multiplyOpacity()

void juce::ColourGradient::multiplyOpacity ( float  multiplier)
noexcept

Multiplies the alpha value of all the colours by the given scale factor.

Definition at line 141 of file juce_ColourGradient.cpp.

◆ operator!=()

bool juce::ColourGradient::operator!= ( const ColourGradient other) const
noexcept

Definition at line 102 of file juce_ColourGradient.cpp.

◆ operator=() [1/2]

ColourGradient & juce::ColourGradient::operator= ( ColourGradient &&  other)
noexcept

Definition at line 57 of file juce_ColourGradient.cpp.

◆ operator=() [2/2]

ColourGradient & juce::ColourGradient::operator= ( const ColourGradient other)

Definition at line 48 of file juce_ColourGradient.cpp.

◆ operator==()

bool juce::ColourGradient::operator== ( const ColourGradient other) const
noexcept

Definition at line 95 of file juce_ColourGradient.cpp.

◆ removeColour()

void juce::ColourGradient::removeColour ( int  index)

Removes one of the colours from the gradient.

Definition at line 135 of file juce_ColourGradient.cpp.

◆ setColour()

void juce::ColourGradient::setColour ( int  index,
Colour  newColour 
)
noexcept

Changes the colour at a given index.

The index is from 0 to getNumColours() - 1.

Definition at line 169 of file juce_ColourGradient.cpp.

◆ vertical() [1/2]

ColourGradient juce::ColourGradient::vertical ( Colour  colour1,
float  y1,
Colour  colour2,
float  y2 
)
static

Creates a vertical linear gradient between two Y coordinates.

Definition at line 85 of file juce_ColourGradient.cpp.

◆ vertical() [2/2]

template<typename Type >
static ColourGradient juce::ColourGradient::vertical ( Colour  colourTop,
Colour  colourBottom,
Rectangle< Type >  area 
)
static

Creates a vertical linear gradient from top to bottom in a rectangle.

Definition at line 106 of file juce_ColourGradient.h.

Member Data Documentation

◆ isRadial

bool juce::ColourGradient::isRadial

If true, the gradient should be filled circularly, centred around point1, with point2 defining a point on the circumference.

If false, the gradient is linear between the two points.

Definition at line 213 of file juce_ColourGradient.h.

◆ point1

Point<float> juce::ColourGradient::point1

Definition at line 206 of file juce_ColourGradient.h.

◆ point2

Point<float> juce::ColourGradient::point2

Definition at line 206 of file juce_ColourGradient.h.


The documentation for this class was generated from the following files: