TransformMaskStroke:
PROC [context: Context, path: PathProc, closed:
BOOL] ~ {
TransformPath[context, path, FALSE];
};
TransformPath:
PROC [context: Context, path: PathProc, oddWrap:
BOOL] ~ {
d: REF TransformData ¬ NARROW[ImagerRaster.GetDevice[context].data];
matrix: Transformation ¬ ImagerBackdoor.GetT[context];
in: Outline ¬ ImagerPath.OutlineFromPath[path, oddWrap, matrix];
out: Outline ¬ DoOutline[in, d.action, d.clientData];
Imager.MaskFillOutline[d.clientContext, out];
};
DoOutline:
PROC [in: Outline, action: TransformProc, clientData:
REF
ANY]
RETURNS [out: Outline]
~ {
Path: PathProc ~ {ImagerPath.MapOutline[in, moveTo, lineTo, curveTo, conicTo, arcTo]};
Close:
PROC ~ {
IF trajectory # NIL AND fp # lp THEN Line[fp];
trajectories ¬ CONS[trajectory, trajectories];
trajectory ¬ NIL;
};
Move:
PROC [p:
VEC] ~ {
IF trajectory # NIL THEN Close[];
fp ¬ lp ¬ p;
trajectory ¬ ImagerPath.MoveTo[action[p, clientData]];
};
Line:
PROC [p1:
VEC] ~ {
IF lp # p1
THEN {
lp ¬ p1;
trajectory ¬ ImagerPath.LineTo[trajectory, action[p1, clientData]];
};
};
Curve:
PROC [p1, p2, p3:
VEC] ~ {
lp ¬ p3;
trajectory ¬ ImagerPath.CurveTo[
trajectory, action[p1, clientData], action[p2, clientData], action[p3, clientData]];
};
fp, lp: VEC ¬ [0, 0];
trajectory: ImagerPath.Trajectory ¬ NIL;
trajectories: ImagerPath.TrajectoryList ¬ NIL;
ImagerPath.Transform[path: Path, moveTo: Move, lineTo: Line, curveTo: Curve];
IF trajectory # NIL THEN Close[];
out ¬ NEW[ImagerPath.OutlineRep[in.size]];
out.oddWrap ¬ in.oddWrap;
FOR i:
NAT
IN [0..out.size)
DO
out[i] ¬ trajectories.first;
trajectories ¬ trajectories.rest;
ENDLOOP;
};