31 const int size = aSize / 2;
39 const std::array<double, 2> strokes = { aDashSize, aDashSize / 2 };
40 const double dashCycleLen = strokes[0] + strokes[1];
49 constexpr double maxDashes = 100000.0;
51 if( dashCycleLen <= 0.0 || dashCycleLen * aGal.
GetWorldScale() <= 1.0
52 || segLen / dashCycleLen > maxDashes )
60 const double theta = atan2( aSeg.
B.
y - aSeg.
A.
y, aSeg.
B.
x - aSeg.
A.
x );
63 dashCycleLen * cos( theta ),
64 dashCycleLen * sin( theta ),
68 strokes[0] * cos( theta ),
69 strokes[0] * sin( theta ),
72 const unsigned cycleCount =
static_cast<unsigned>( segLen / dashCycleLen ) + 1;
74 for(
unsigned cyclei = 0; cyclei < cycleCount; ++cyclei )
76 const VECTOR2D dashStart = aSeg.
A + cycleVec * cyclei;
77 const VECTOR2D dashEnd = dashStart + dashVec;
82 if(
ClipLine( &clip, dashSeg.A.x, dashSeg.A.y, dashSeg.B.x, dashSeg.B.y ) )
85 aGal.
DrawLine( dashSeg.A, dashSeg.B );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
Abstract interface for drawing on a 2D-surface.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
double GetWorldScale() const
Get the world scale.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
a few functions useful in geometry calculations.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
Utility functions for drawing compound items (i.e.
The Cairo implementation of the graphics abstraction layer.
void DrawCross(GAL &aGal, const VECTOR2I &aPosition, int aSize)
Draw a cross at a given position.
void DrawDashedLine(GAL &aGal, const SEG &aSeg, double aDashSize)
Draw a dashed line.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D