1 /* 2 * Copyright 2023, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 * Zardshard 8 */ 9 #ifndef STYLE_TRANSFORMER_H 10 #define STYLE_TRANSFORMER_H 11 12 13 #include "IconBuild.h" 14 15 16 class BPoint; 17 18 _BEGIN_ICON_NAMESPACE 19 20 21 /*! Warps a shape's style. 22 Implements the same interface as any other class of the agg:trans_ series. 23 This class can be used wherever AGG needs a transformer (for example, 24 agg::span_interpolator_linear<StyleTransformer> is valid). 25 */ 26 class StyleTransformer { 27 public: 28 StyleTransformer() {} 29 virtual ~StyleTransformer(); 30 31 /*! Transform a single point of the shape's style. 32 This function should be fast since it will be called many times. 33 34 \note This function is lowercase so that it satisfies the role of an agg 35 transformer 36 */ 37 virtual void transform(double* x, double* y) const = 0; 38 39 /*! Alias of \c transform. 40 Use of this in our code is preffered because it follows the normal 41 capitalization scheme. 42 */ 43 void Transform(double* x, double* y) const 44 { transform(x, y); } 45 void Transform(BPoint* point) const; 46 BPoint Transform(const BPoint& point) const; 47 48 virtual void Invert() = 0; 49 50 /*! Is the transformation a linear transformation? 51 This allows using linear interpolation instead of calling \c transform 52 for each point. */ 53 virtual bool IsLinear() 54 { return false; } 55 }; 56 57 58 _END_ICON_NAMESPACE 59 60 61 #endif // STYLE_TRANSFORMER_H 62