Krita Source Code Documentation
Loading...
Searching...
No Matches
Ruler.cc
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
3
*
4
* SPDX-License-Identifier: LGPL-2.0-or-later
5
*/
6
7
#include "
Ruler.h
"
8
9
Ruler::Ruler
() :
p1
(QPointF(10, 10)),
p2
(QPointF(100, 190))
10
{
11
}
12
13
Ruler::~Ruler
()
14
{
15
}
16
17
QPointF
Ruler::project
(
const
QPointF& pt)
18
{
19
double
x1 =
p1
.x();
20
double
y1 =
p1
.y();
21
double
x2 =
p2
.x();
22
double
y2 =
p2
.y();
23
double
a1 = (y2 - y1) / (x2 - x1);
24
double
b1 = y1 - x1 * a1;
25
double
a2 = (x2 - x1) / (y1 - y2);
26
double
b2 = pt.y() - a2 * pt.x();
27
double
xm = (b2 - b1) / (a1 - a2);
28
return
QPointF(xm, xm * a1 + b1);
29
}
30
31
const
QPointF&
Ruler::point1
()
const
32
{
33
return
p1
;
34
}
35
36
const
QPointF&
Ruler::point2
()
const
37
{
38
return
p2
;
39
}
p2
QPointF p2
Definition
KisBezierUtils.cpp:499
p1
QPointF p1
Definition
KisBezierUtils.cpp:499
Ruler.h
Ruler::point2
const QPointF & point2() const
Definition
Ruler.cc:36
Ruler::p2
QPointF p2
Definition
Ruler.h:28
Ruler::p1
QPointF p1
Definition
Ruler.h:27
Ruler::point1
const QPointF & point1() const
Definition
Ruler.cc:31
Ruler::Ruler
Ruler()
Definition
Ruler.cc:9
Ruler::project
QPointF project(const QPointF &)
Definition
Ruler.cc:17
Ruler::~Ruler
~Ruler()
Definition
Ruler.cc:13
plugins
assistants
Assistants
Ruler.cc
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52