StrokeSelection.h header
#include <ew/app/StrokeSelection.h>
Namespace ew::app
PointRef struct
struct ew::app::PointRef
One point of a glyph, named by which stroke it belongs to and where in that stroke it sits.
Members
qsizetype ew::app::script::PointRef::stroke = 0
Which stroke of the glyph, by index.
qsizetype ew::app::script::PointRef::point = 0
Which point of that stroke, by index.
bool ew::app::script::PointRef::operator==(const PointRef &other) const =default
Value equality over both indices.
Enumerations
enum class AlignEdge { Left, HorizontalCenter, Right, Top, VerticalCenter, Bottom }
Which axis a set of points is lined up on.
Functions
std::vector< ew::core::conlang::Stroke > ew::app::script::alignSelection(const std::vector< ew::core::conlang::Stroke > &strokes, const std::vector< PointRef > &selection, AlignEdge edge)
strokes with every point of selection moved onto edge of the selection's own bounds.
std::vector< ew::core::conlang::Stroke > ew::app::script::distributeSelection(const std::vector< ew::core::conlang::Stroke > &strokes, const std::vector< PointRef > &selection, bool horizontal)
strokes with the points of selection spread evenly between the two extremes they already occupy, along x when horizontal and along y otherwise.
qsizetype ew::app::script::insertionIndex(const ew::core::conlang::Stroke &stroke, double x, double y)
Where a new point at (x, y) should be inserted into stroke: the index it would take, chosen by the SEGMENT it lies nearest.
Nearest-segment rather than the end of the list, because a user clicking on the middle of a curve means "put one here", and appending instead draws a line back across the glyph.
std::optional< PointRef > ew::app::script::pointAt(const std::vector< ew::core::conlang::Stroke > &strokes, double x, double y, double radius)
The point of strokes within radius of (x, y) and nearest to it, or nullopt.
A locked or hidden stroke is never grabbed: both states exist precisely so the user can work around a stroke without disturbing it.
std::vector< PointRef > ew::app::script::pointsInLasso(const std::vector< ew::core::conlang::Stroke > &strokes, const std::vector< ew::core::conlang::StrokePoint > &lasso)
Every point of strokes inside the closed polygon lasso.
std::vector< PointRef > ew::app::script::pointsInRectangle(const std::vector< ew::core::conlang::Stroke > &strokes, double x1, double y1, double x2, double y2)
Every point of strokes inside the rectangle with opposite corners (x1, y1) and (x2, y2) – a marquee selection.
StrokeBounds ew::app::script::selectionBounds(const std::vector< ew::core::conlang::Stroke > &strokes, const std::vector< PointRef > &selection)
The extent of the selection within strokes – what a transform is centred and scaled on.
std::vector< ew::core::conlang::Stroke > ew::app::script::transformSelection(const std::vector< ew::core::conlang::Stroke > &strokes, const std::vector< PointRef > &selection, const StrokeTransform &transform)
strokes with transform applied to exactly the points in selection.
A reference to a stroke or point that does not exist is skipped rather than treated as an error: a selection can outlive the edit that shortened a stroke, and dropping the stale part is the behaviour that keeps a canvas usable.
Constants
double ew::app::script::kGrabRadius = 0.035
The default distance, in glyph-box units, within which a click counts as grabbing a point.
Deliberately generous. The prototype used a four-pixel handle, and a near-miss then registered as a click on empty canvas and ADDED a stray point – the single most-reported bug in it. A miss must cost nothing; the way to make that true is to make misses rare and to keep "add a point" on a different gesture entirely (see insertionIndex).