Krita Source Code Documentation
Loading...
Searching...
No Matches
bristle.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2008 Lukas Tvrdy <lukast.dev@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef _BRISTLE_H_
8#define _BRISTLE_H_
9
10#include <cmath>
11#include <KoColor.h>
12
14{
15
16public:
17 Bristle() = default;
18 Bristle(float x, float y, float length);
19 ~Bristle();
20
21 inline float x() const {
22 return m_x;
23 }
24
25 inline float y() const {
26 return m_y;
27 }
28
29 inline float prevX() const {
30 return m_prevX;
31 }
32
33 inline float prevY() const {
34 return m_prevY;
35 }
36
37 inline float length() const {
38 return m_length;
39 }
40
41 inline const KoColor &color() const {
42 return m_color;
43 }
44
45 inline int counter() const {
46 return m_counter;
47 }
48
49 inline void upIncrement() {
50 m_counter++;
51 }
52
53 inline float inkAmount() const {
54 return m_inkAmount;
55 };
56
57 inline float distanceCenter() {
58 return std::sqrt(m_x * m_x + m_y * m_y);
59 }
60
61 inline void setX(float x) {
62 m_x = x;
63 }
64 inline void setY(float y) {
65 m_y = y;
66 }
67
68 inline void setPrevX(float prevX) {
69 m_prevX = prevX;
70 }
71
72 inline void setPrevY(float prevY) {
73 m_prevY = prevY;
74 }
75
76 inline bool enabled() const {
77 return m_enabled;
78 }
79
80 void setLength(float length);
81 void setColor(const KoColor &color);
82
83 void addInk(float value);
84 void removeInk(float value);
85 void setInkAmount(float inkAmount);
86 void setEnabled(bool enabled);
87
88
89private:
90 void init(float x, float y, float length);
91
92 // coordinates of bristle
93 float m_x{0.0f};
94 float m_y{0.0f};
95 float m_prevX{0.0f};
96 float m_prevY{0.0f};
97 float m_length{0.0f}; // z - coordinate
99 float m_inkAmount{0.0f};
100
101 // new dimension in bristle
102 int m_counter{0};
103
104 bool m_enabled{true};
105};
106
107#endif
float value(const T *src, size_t ch)
void addInk(float value)
Definition bristle.cpp:27
bool m_enabled
Definition bristle.h:104
void init(float x, float y, float length)
void upIncrement()
Definition bristle.h:49
float m_length
Definition bristle.h:97
const KoColor & color() const
Definition bristle.h:41
bool enabled() const
Definition bristle.h:76
void setX(float x)
Definition bristle.h:61
~Bristle()
Definition bristle.cpp:17
float x() const
Definition bristle.h:21
int counter() const
Definition bristle.h:45
float m_y
Definition bristle.h:94
void setLength(float length)
Definition bristle.cpp:21
void setPrevY(float prevY)
Definition bristle.h:72
float length() const
Definition bristle.h:37
Bristle()=default
float m_prevY
Definition bristle.h:96
float prevY() const
Definition bristle.h:33
void setInkAmount(float inkAmount)
Definition bristle.cpp:37
void setY(float y)
Definition bristle.h:64
void setEnabled(bool enabled)
Definition bristle.cpp:55
float inkAmount() const
Definition bristle.h:53
void setColor(const KoColor &color)
Definition bristle.cpp:49
float m_x
Definition bristle.h:93
int m_counter
Definition bristle.h:102
float distanceCenter()
Definition bristle.h:57
float y() const
Definition bristle.h:25
void removeInk(float value)
Definition bristle.cpp:32
float prevX() const
Definition bristle.h:29
float m_inkAmount
Definition bristle.h:99
KoColor m_color
Definition bristle.h:98
void setPrevX(float prevX)
Definition bristle.h:68
float m_prevX
Definition bristle.h:95