Krita Source Code Documentation
Loading...
Searching...
No Matches
hairy_brush.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2008-2010 Lukáš Tvrdý <lukast.dev@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef _HAIRY_BRUSH_H_
8#define _HAIRY_BRUSH_H_
9
10#include <QVector>
11#include <QTransform>
12
13#include <KoColor.h>
14
15#include "trajectory.h"
16#include "bristle.h"
17
18#include <kis_paint_device.h>
21
22class KoCompositeOp;
23
24
55
57{
58
59public:
60 HairyBrush();
62
63 void paintLine(KisPaintDeviceSP dab, KisPaintDeviceSP layer, const KisPaintInformation &pi1, const KisPaintInformation &pi2, qreal scale, qreal rotation);
65 void setInkColor(const KoColor &color) {
66 m_color = color;
67 }
69 void setProperties(KisHairyProperties * properties) {
70 m_properties = properties;
71 }
73 void fromDabWithDensity(KisFixedPaintDeviceSP dab, qreal density);
74
75private:
77 void addBristleInk(Bristle *bristle,const QPointF &pos, const KoColor &color);
79 void plotPixel(int wx, int wy, const KoColor &color);
81 void darkenPixel(int wx, int wy, const KoColor &color);
83 void paintParticle(QPointF pos, const KoColor& color, qreal weight);
85 void paintParticle(QPointF pos, const KoColor& color);
87 void colorifyBristles(KisPaintDeviceSP source, QPointF point);
88
89 void repositionBristles(double angle, double slope);
91 double computeMousePressure(double distance);
92
94 void saturationDepletion(Bristle * bristle, KoColor &bristleColor, qreal pressure, qreal inkDepletion);
96 void opacityDepletion(Bristle * bristle, KoColor &bristleColor, qreal pressure, qreal inkDepletion);
98 qreal fetchInkDepletion(Bristle * bristle, int inkDepletionSize);
99
100 void initAndCache();
101
102private:
104
106 QTransform m_transform;
107
108 // used for interpolation the path of bristles
110 QHash<QString, QVariant> m_params;
111 // temporary device
114 const KoCompositeOp * m_compositeOp {nullptr};
115 quint32 m_pixelSize {0};
116
117 int m_counter {0};
118
119 double m_lastAngle {0.0};
120 double m_oldPressure {1.0};
122
125
126 // internal counter counts the calls of paint, the counter is 1 when the first call occurs
127 inline bool firstStroke() const {
128 return (m_counter == 1);
129 }
130};
131
132#endif
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
qreal distance(const QPointF &p1, const QPointF &p2)
bool firstStroke() const
QHash< QString, QVariant > m_params
void paintParticle(QPointF pos, const KoColor &color, qreal weight)
paint wu particle by copying the color and setup just the opacity, weight is complementary to opacity...
double m_oldPressure
const KoCompositeOp * m_compositeOp
double m_lastAngle
QTransform m_transform
QVector< Bristle * > m_bristles
void plotPixel(int wx, int wy, const KoColor &color)
composite single pixel to dab
KisPaintDeviceSP m_dab
void initAndCache()
void opacityDepletion(Bristle *bristle, KoColor &bristleColor, qreal pressure, qreal inkDepletion)
simulate running out of ink through opacity decreasing
const KisHairyProperties * m_properties
void saturationDepletion(Bristle *bristle, KoColor &bristleColor, qreal pressure, qreal inkDepletion)
simulate running out of saturation
KoColorTransformation * m_transfo
void setInkColor(const KoColor &color)
set ink color for the whole bristle shape
Definition hairy_brush.h:65
void colorifyBristles(KisPaintDeviceSP source, QPointF point)
similar to sample input color in spray
void addBristleInk(Bristle *bristle, const QPointF &pos, const KoColor &color)
paints single bristle
int m_saturationId
KoColor m_color
Trajectory m_trajectory
double computeMousePressure(double distance)
compute mouse pressure according distance
void darkenPixel(int wx, int wy, const KoColor &color)
check the opacity of dab pixel and if the opacity is less than color, it will copy color to dab
void fromDabWithDensity(KisFixedPaintDeviceSP dab, qreal density)
set the shape of the bristles according the dab
void repositionBristles(double angle, double slope)
void setProperties(KisHairyProperties *properties)
set parameters for the brush engine
Definition hairy_brush.h:69
KisRandomAccessorSP m_dabAccessor
void paintLine(KisPaintDeviceSP dab, KisPaintDeviceSP layer, const KisPaintInformation &pi1, const KisPaintInformation &pi2, qreal scale, qreal rotation)
qreal fetchInkDepletion(Bristle *bristle, int inkDepletionSize)
fetch actual ink status according depletion curve
quint32 m_pixelSize
quint8 bristleInkAmountWeight
Definition hairy_brush.h:46
quint8 inkDepletionWeight
Definition hairy_brush.h:47
quint8 bristleLengthWeight
Definition hairy_brush.h:45
QVector< qreal > inkDepletionCurve
Definition hairy_brush.h:31