33#include <Pt/Gfx/Color.h>
34#include <Pt/Gfx/Point.h>
35#include <Pt/Gfx/Image.h>
36#include <Pt/SmartPtr.h>
93 {
return _stops.empty(); }
98 {
return _stops.size(); }
110 { _stops.push_back(
ColorStop(position, color) ); }
115 {
return _stops[n]; }
120 {
return _stops.front(); }
125 {
return _stops.back(); }
133 std::vector<ColorStop> _stops;
204 const Gfx::PointF& origin = Gfx::PointF());
230 float endX,
float endY,
236 const PointF& end,
float endRadius,
242 float endX,
float endY,
float endRadius,
318 Brush(BrushData* data);
330 , _fillStyle(
Brush::Solid)
331 , _positionMode(
Brush::Relative)
333 , _gradient(
Brush::Horizontal)
334 , _gradientBeginRadius(0.0f)
335 , _gradientEndRadius(0.0f)
336 , _textureMode(
Brush::SourcePixels)
341 BrushData(
const Color& color)
343 , _fillStyle(Brush::Solid)
344 , _positionMode(Brush::Relative)
346 , _gradient(Brush::Horizontal)
347 , _gradientBeginRadius(0.0f)
348 , _gradientEndRadius(0.0f)
349 , _textureMode(Brush::SourcePixels)
354 BrushData(
const Image& texture,
const PointF& textureOrigin);
356 BrushData(
const BrushData& other);
358 BrushData& operator=(
const BrushData& other);
361 BrushData(
const Color& from,
const Color& to,
367 {
return _fillStyle; }
370 {
return _positionMode; }
372 void setSolid(
const Color& color);
374 const Color& color()
const
375 {
return _gradientStops.empty() ? _color : _gradientStops.front().color(); }
381 void setLinearGradient(
const PointF& begin,
const PointF& end,
382 const ColorStops& colorStops);
385 void setLinearGradient(
float beginX,
float beginY,
386 float endX,
float endY,
387 const ColorStops& colorStops);
391 void setRadialGradient(
const PointF& begin,
float beginRadius,
392 const PointF& end,
float endRadius,
393 const ColorStops& colorStops);
396 void setRadialGradient(
float beginX,
float beginY,
float beginRadius,
397 float endX,
float endY,
float endRadius,
398 const ColorStops& colorStops);
401 {
return _gradient; }
404 const Color& gradientColor()
const
405 {
return _gradientStops.empty() ? _color : _gradientStops.back().color(); }
407 const ColorStops& gradientStops()
const
408 {
return _gradientStops; }
410 const PointF& gradientBegin()
const
411 {
return _gradientBegin; }
413 float gradientBeginRadius()
const
414 {
return _gradientBeginRadius; }
416 const PointF& gradientEnd()
const
417 {
return _gradientEnd; }
419 float gradientEndRadius()
const
420 {
return _gradientEndRadius; }
422 void setImageTexture(
const Image& texture,
const PointF& textureOrigin);
424 const Image& texture()
const;
427 {
return _textureMode; }
429 const PointF& textureOrigin()
const
430 {
return _textureOrigin; }
432 bool isGradient()
const
433 {
return _fillStyle == Brush::Gradient; }
435 bool isTexture()
const
436 {
return _fillStyle == Brush::Texture; }
448 ColorStops _gradientStops;
449 PointF _gradientBegin;
450 float _gradientBeginRadius;
452 float _gradientEndRadius;
455 PointF _textureOrigin;
Off-screen image that can be painted.
Definition Bitmap.h:71
Fill color, gradient or texture.
Definition Brush.h:151
Brush(const Color &color)
Constructs a solid brush.
PositionMode positionMode() const
Returns how brush coordinates are interpreted.
bool isTexture() const
Returns true if the brush uses a texture.
bool isGradient() const
Returns true if the brush uses a gradient.
const Color & gradientColor() const
Returns the legacy secondary gradient color.
FillStyle fillStyle() const
Returns the brushes fill style.
void setColor(const Color &color)
Sets the solid fill color.
static Brush verticalGradient(const Color &from, const Color &to)
Constructs a vertical gradient brush from two colors.
TextureMode
Identifies how image texture coordinates are interpreted.
Definition Brush.h:183
const ColorStops & gradientStops() const
Color stops of a gradient.
PositionMode
Identifies how brush coordinates are interpreted.
Definition Brush.h:165
TextureMode textureMode() const
Returns how the texture origin is interpreted.
const PointF & gradientBegin() const
Begin of a linear or radial gradient.
static Brush linearGradient(float beginX, float beginY, float endX, float endY, const ColorStops &colorStops)
Constructs a relative positioned linear gradient.
static Brush radialGradient(float beginX, float beginY, float beginRadius, float endX, float endY, float endRadius, const ColorStops &colorStops)
Constructs a relative positioned radial gradient.
GradientStyle gradient() const
Returns the gradient style.
FillStyle
Identifies the fill source used by the brush.
Definition Brush.h:156
float gradientEndRadius() const
Radius of a radial gradient end circle.
const Color & color() const
Returns the solid or first gradient color.
static Brush horizontalGradient(const Color &from, const Color &to)
Constructs a horizontal gradient brush from two colors.
GradientStyle
Identifies the gradient variant used by the brush.
Definition Brush.h:173
static Brush linearGradient(const PointF &begin, const PointF &end, const ColorStops &colorStops)
Constructs an absolute positioned linear gradient.
static Brush horizontalGradient(const ColorStops &colorStops)
Constructs a horizontal gradient brush from color stops.
bool isNull() const
Returns true if the brush is null.
static Brush imageTexture(const Image &image, const Gfx::PointF &origin=Gfx::PointF())
Constructs an image texture brush.
const PointF & gradientEnd() const
End of a linear or radial gradient.
Brush()
Contructs a null brush.
static Brush radialGradient(const PointF &begin, float beginRadius, const PointF &end, float endRadius, const ColorStops &colorStops)
Constructs an absolute positioned radial gradient.
float gradientBeginRadius() const
Radius of a radial gradient begin circle.
const Image & texture() const
Returns the texture image.
const PointF & textureOrigin() const
Returns the texture pattern origin.
static Brush verticalGradient(const ColorStops &colorStops)
Constructs a vertical gradient brush from color stops.
Color stop for a gradient brush.
Definition Brush.h:49
float position() const
Returns the normalized stop position.
Definition Brush.h:60
const Color & color() const
Returns the stop color.
Definition Brush.h:65
ColorStop(float position, const Color &color)
Constructs a color stop.
Definition Brush.h:53
Ordered collection of gradient color stops.
Definition Brush.h:78
const ColorStop & operator[](std::size_t n) const
Returns the stop at the given index.
Definition Brush.h:114
void calculateInterpolatedColor(Color &res, const float position) const
Calculates the interpolated color for a position.
~ColorStops()
Destroys the collection.
Definition Brush.h:87
bool empty() const
Returns true if no stops are stored.
Definition Brush.h:92
ColorStops()
Constructs an empty collection.
Definition Brush.h:82
void add(float position, const Color &color)
Appends a color stop.
Definition Brush.h:109
void clear()
Removes all stored stops.
Definition Brush.h:102
std::size_t size() const
Returns the number of stored stops.
Definition Brush.h:97
const ColorStop & front() const
Returns the first stop.
Definition Brush.h:119
const ColorStop & back() const
Returns the last stop.
Definition Brush.h:124
8-bit ARGB color.
Definition Color.h:65
Policy based smart pointer.
Definition SmartPtr.h:462
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33