19
19
#ifndef _SPRAY_BRUSH_H_
20
20
#define _SPRAY_BRUSH_H_
25
22
#include <KoColor.h>
27
24
#include "kis_paint_device.h"
28
25
#include "kis_painter.h"
29
26
#include "kis_paint_information.h"
31
#include "kis_spray_paintop_settings.h"
28
#include "kis_color_option.h"
33
30
#include "random_gauss.h"
38
class KisSprayProperties{
42
quint16 particleCount;
64
qreal randomRotationWeight;
65
qreal followCursorWeigth;
41
SprayBrush(const KoColor &inkColor);
44
SprayBrush(KoColor inkColor);
45
void paint(KisPaintDeviceSP dev, const KisPaintInformation& info, const KoColor &color);
77
void paint(KisPaintDeviceSP dab, KisPaintDeviceSP source, const KisPaintInformation& info, qreal rotation, qreal scale, const KoColor &color, const KoColor &bgColor);
78
void setProperties(KisSprayProperties * properties, KisColorProperties * colorProperties){
79
m_properties = properties;
80
m_colorProperties = colorProperties;
86
quint32 m_particlesCount;
90
KisPainter * m_painter;
91
KisPaintDeviceSP m_imageDevice;
95
const KisSprayProperties * m_properties;
96
const KisColorProperties * m_colorProperties;
99
/// rotation in radians according the settings (gauss distribution, uniform distribution or fixed angle)
100
qreal rotationAngle();
47
101
/// Paints Wu Particle
48
102
void paintParticle(KisRandomAccessor &writeAccessor, const KoColor &color, qreal rx, qreal ry);
49
103
void paintCircle(KisPainter * painter, qreal x, qreal y, int radius, int steps);
50
104
void paintEllipse(KisPainter * painter, qreal x, qreal y, int a, int b, qreal angle, int steps);
51
105
void paintRectangle(KisPainter * painter, qreal x, qreal y, int width, int height, qreal angle, int steps);
53
void paintMetaballs(KisPaintDeviceSP dev, const KisPaintInformation &info, const KoColor &painterColor);
54
void paintDistanceMap(KisPaintDeviceSP dev, const KisPaintInformation &info, const KoColor &painterColor);
56
107
void paintOutline(KisPaintDeviceSP dev, const KoColor& painterColor, qreal posX, qreal posY, qreal radius);
58
void setDiameter(int diameter) {
59
m_diameter = diameter;
60
m_radius = diameter * 0.5;
63
void setCoverity(qreal coverage) {
64
m_coverage = coverage;
67
void setJitterSize(bool jitterSize) {
68
m_jitterSize = jitterSize;
71
void setJitterMovement(bool jitterMovement) {
72
m_jitterMovement = jitterMovement;
75
// set the amount of the jittering brush position
76
void setAmount(qreal amount) {
80
void setScale(qreal scale) {
84
void setObject(int object) {
88
void setShape(int shape) {
92
void setJitterShapeSize(bool jitterShapeSize) {
93
m_jitterShapeSize = jitterShapeSize;
96
void setObjectDimension(int width, int height) {
106
qreal objectWidth() {
110
qreal objectHeight() {
116
void setUseDensity(bool useDensity) {
117
m_useDensity = useDensity;
120
void setParticleCount(int particleCount) {
121
m_particlesCount = particleCount;
124
void setMaxTreshold(qreal tresh) {
128
void setMinTreshold(qreal tresh) {
132
void setRendering(bool highQuality) {
133
m_highQuality = highQuality;
136
void setRadius(qreal radiusX, qreal radiusY) {
137
m_radiusX = qRound(radiusX);
138
m_radiusY = qRound(radiusY);
141
void setComputeArea(QRect area) {
142
m_computeArea = area;
145
// set true if the particles should have random opacity
146
void setUseRandomOpacity(bool isRandom) {
147
m_randomOpacity = isRandom;
150
void setSettingsObject(const KisSprayPaintOpSettings* settings) {
151
m_settings = settings;
164
bool m_jitterMovement;
168
// amount of jitter for movement
177
bool m_jitterShapeSize;
180
int m_particlesCount;
188
bool m_randomOpacity;
197
RandomGauss * m_rand;
198
KisPainter * m_painter;
200
const KisSprayPaintOpSettings* m_settings;
109
/// mix a with b.b mix with weight and a with 1.0 - weight
110
inline qreal linearInterpolation(qreal a, qreal b, qreal weight){
111
return (1.0 - weight) * a + weight * b;
114
// TODO: move this somewhere where I can reuse it
115
/// convert radians to degrees
116
inline qreal rad2deg(qreal rad){
117
return rad * (180.0/M_PI);
120
/// convert degrees to radians
121
inline qreal deg2rad(quint16 deg){
122
return deg * (M_PI/180.0);