File indexing completed on 2024-05-12 15:58:17
0001 /* 0002 * SPDX-FileCopyrightText: 2004 Adrian Page <adrian@pagenet.plus.com> 0003 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #ifndef KIS_GRADIENT_PAINTER_H_ 0008 #define KIS_GRADIENT_PAINTER_H_ 0009 0010 #include <QScopedPointer> 0011 0012 #include <KoColor.h> 0013 0014 #include "kis_types.h" 0015 #include "kis_painter.h" 0016 0017 #include <kritaimage_export.h> 0018 0019 0020 /** 0021 * XXX: Docs! 0022 */ 0023 class KRITAIMAGE_EXPORT KisGradientPainter : public KisPainter 0024 { 0025 0026 public: 0027 0028 KisGradientPainter(); 0029 KisGradientPainter(KisPaintDeviceSP device); 0030 KisGradientPainter(KisPaintDeviceSP device, KisSelectionSP selection); 0031 0032 ~KisGradientPainter() override; 0033 0034 enum enumGradientShape { 0035 GradientShapeLinear, 0036 GradientShapeBiLinear, 0037 GradientShapeRadial, 0038 GradientShapeSquare, 0039 GradientShapeConical, 0040 GradientShapeConicalSymetric, 0041 GradientShapeSpiral, 0042 GradientShapeReverseSpiral, 0043 GradientShapePolygonal 0044 }; 0045 0046 enum enumGradientRepeat { 0047 GradientRepeatNone, 0048 GradientRepeatForwards, 0049 GradientRepeatAlternate 0050 }; 0051 0052 void setGradientShape(enumGradientShape shape); 0053 0054 void precalculateShape(); 0055 0056 /** 0057 * Paint a gradient in the rect between startx, starty, width and height. 0058 */ 0059 bool paintGradient(const QPointF& gradientVectorStart, 0060 const QPointF& gradientVectorEnd, 0061 enumGradientRepeat repeat, 0062 double antiAliasThreshold, 0063 bool reverseGradient, 0064 qint32 startx, 0065 qint32 starty, 0066 qint32 width, 0067 qint32 height, 0068 bool useDithering = false); 0069 0070 // convenience overload 0071 bool paintGradient(const QPointF& gradientVectorStart, 0072 const QPointF& gradientVectorEnd, 0073 enumGradientRepeat repeat, 0074 double antiAliasThreshold, 0075 bool reverseGradient, 0076 const QRect &applyRect, 0077 bool useDithering = false); 0078 0079 template <class T> 0080 bool paintGradient(const QPointF& gradientVectorStart, 0081 const QPointF& gradientVectorEnd, 0082 enumGradientRepeat repeat, 0083 double antiAliasThreshold, 0084 bool reverseGradient, 0085 bool useDithering, 0086 const QRect &applyRect, 0087 T & paintPolicy); 0088 0089 private: 0090 struct Private; 0091 const QScopedPointer<Private> m_d; 0092 }; 0093 #endif //KIS_GRADIENT_PAINTER_H_