[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bcalligra=5D_krita/ui/tool=3A_smoothing=3A_take_time?=
From: Geoffry Song <goffrie () gmail ! com>
Date: 2011-06-26 23:12:49
Message-ID: 20110626231249.643ADA60A6 () git ! kde ! org
[Download RAW message or body]
Git commit 76edd666c4333a8a472d2b7b8d9d4ce1577893d2 by Geoffry Song.
Committed on 27/06/2011 at 01:07.
Pushed by geoffrysong into branch 'master'.
smoothing: take time into account
Scale control tangents by the time interval between points
M +10 -6 krita/ui/tool/kis_tool_freehand.cc
http://commits.kde.org/calligra/76edd666c4333a8a472d2b7b8d9d4ce1577893d2
diff --git a/krita/ui/tool/kis_tool_freehand.cc b/krita/ui/tool/kis_tool_freehand.cc
index 0d0e429..1354cd0 100644
--- a/krita/ui/tool/kis_tool_freehand.cc
+++ b/krita/ui/tool/kis_tool_freehand.cc
@@ -247,11 +247,14 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
if (m_smooth) {
if (!m_haveTangent) {
m_haveTangent = true;
- m_previousTangent = (info.pos() - m_previousPaintInformation.pos()) * \
(m_smoothness / 3.0); + m_previousTangent = (info.pos() - \
m_previousPaintInformation.pos()) * m_smoothness / + \
(3.0 * (info.currentTime() - m_previousPaintInformation.currentTime())); } else {
- QPointF newTangent = (info.pos() - m_olderPaintInformation.pos()) * \
(m_smoothness / 6.0);
- QPointF control1 = m_olderPaintInformation.pos() + m_previousTangent;
- QPointF control2 = m_previousPaintInformation.pos() - newTangent;
+ QPointF newTangent = (info.pos() - m_olderPaintInformation.pos()) * \
m_smoothness / + (3.0 * (info.currentTime() - \
m_olderPaintInformation.currentTime())); + qreal scaleFactor = \
(m_previousPaintInformation.currentTime() - m_olderPaintInformation.currentTime()); + \
QPointF control1 = m_olderPaintInformation.pos() + m_previousTangent * scaleFactor; + \
QPointF control2 = m_previousPaintInformation.pos() - newTangent * scaleFactor; \
paintBezierCurve(m_olderPaintInformation, control1,
control2,
@@ -294,8 +297,9 @@ void KisToolFreehand::finishStroke()
// shouldn't happen
return;
}
- QPointF newTangent = (m_previousPaintInformation.pos() - \
m_olderPaintInformation.pos()) * (m_smoothness / 3.0);
- QPointF control1 = m_olderPaintInformation.pos() + m_previousTangent;
+ QPointF newTangent = (m_previousPaintInformation.pos() - \
m_olderPaintInformation.pos()) * m_smoothness / 3.0; + qreal scaleFactor = \
(m_previousPaintInformation.currentTime() - m_olderPaintInformation.currentTime()); + \
QPointF control1 = m_olderPaintInformation.pos() + m_previousTangent * scaleFactor; \
QPointF control2 = m_previousPaintInformation.pos() - newTangent; \
paintBezierCurve(m_olderPaintInformation, control1,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic