StrokeSnapping.h header
#include <ew/app/StrokeSnapping.h>
Namespace ew::app
SnapResult struct
struct ew::app::SnapResult
Where a snapped point landed and what pulled it there.
The reason is carried so the canvas can SAY what it snapped to – a point that jumps with no explanation reads as the editor fighting the user, and "snapped to baseline" turns the same jump into the tool being helpful.
Members
ew::core::conlang::StrokePoint ew::app::script::SnapResult::point
The point after snapping. Equal to the input when nothing was near enough.
QString ew::app::script::SnapResult::reason
What pulled it, for the canvas to display (a guide's name, "grid", "point", "angle"); empty when nothing did.
bool ew::app::script::SnapResult::snapped = false
Whether anything pulled it.
bool ew::app::script::SnapResult::operator==(const SnapResult &other) const =default
Value equality over all fields.
SnapSettings struct
struct ew::app::SnapSettings
What a point may be pulled toward, and how close it has to get.
Members
double ew::app::script::SnapSettings::radius = 0.02
How near, in glyph-box units, a target has to be to pull the point.
bool ew::app::script::SnapSettings::toGuides = true
Whether to snap to the script's guides.
bool ew::app::script::SnapSettings::toGrid = true
Whether to snap to the drawing grid.
bool ew::app::script::SnapSettings::toPoints = true
Whether to snap to points already drawn.
bool ew::app::script::SnapSettings::toAngle = false
Whether to constrain the segment's ANGLE from the previous point.
bool ew::app::script::SnapSettings::operator==(const SnapSettings &other) const =default
Value equality over all fields.
Functions
SnapResult ew::app::script::snapPoint(const ew::core::conlang::StrokePoint &point, const ew::core::conlang::ScriptMetrics &metrics, const std::vector< ew::core::conlang::Stroke > &existing, const SnapSettings &settings)
point pulled to the nearest of whatever settings allows, given the script's metrics and the points already drawn in existing.
The result is RETURNED, never written back into the stroke the caller holds. The prototype this feature comes from applied endpoint snapping to the stored array on every click, which flattened each point as it was placed; snapping belongs to the moment of input and to rendering, and the user's own coordinates stay exactly as they gave them.
ew::core::conlang::StrokePoint ew::app::script::snapToAngle(const ew::core::conlang::StrokePoint &previous, const ew::core::conlang::StrokePoint &point, double incrementDegrees)
point moved so the segment from previous to it lies on a multiple of incrementDegrees, keeping its distance from previous. An increment of zero returns point unchanged.