Krita Source Code Documentation
Loading...
Searching...
No Matches
KisDynamicSensorDistance.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
7
9
11#include <KisCurveOptionData.h>
12
13
14KisDynamicSensorDistance::KisDynamicSensorDistance(const KisSensorWithLengthData &data, std::optional<KisCubicCurve> curveOverride)
15 : KisDynamicSensor(DistanceId, data, curveOverride)
16 , m_periodic(data.isPeriodic)
17 , m_length(data.length)
18{
19}
20
22{
23 if (pi.isHoveringMode()) return 1.0;
24
25 const qreal distance =
27 fmod(pi.totalStrokeLength(), m_length) :
28 qMin(pi.totalStrokeLength(), (qreal)m_length);
29
30 return distance / m_length;
31}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82
const KoID DistanceId("distance", ki18nc("Context: dynamic sensors", "Distance"))
generate a number that increase with distance
qreal distance(const QPointF &p1, const QPointF &p2)
qreal value(const KisPaintInformation &pi) const override
KisDynamicSensorDistance(const KisSensorWithLengthData &data, std::optional< KisCubicCurve > curveOverride)
qreal totalStrokeLength() const
The length of the stroke before painting the current dab.