FixpointShapes - graphical primitives based on fixpoint arithmetics
Features:
Applications that use the library:
Main application areas:
Examples:
ScanLinePoints(1, 1, 34, 16, TSetDCPixel(hDC, clBlack, 5));
The pixel zooming is the feature of the (pixel drawing) functor (the last parameter). The algorithm simply forwards the pixel coordinates to the functor which draws the zoomed pixels.
ScanLinePoints(10, 10, 100, 80, TSpray<TSetDCPixel>(TSetDCPixel(Canvas->Handle), 10, 50));
This sprays random pixels along a line, within the range and with the probability of the TSpray object parameters.
ScanCirclePoints(100, 100, 50, Pen(ptHorz, TSetDCPixel(Canvas->Handle), 5));
This draws a circle with a (horizontally elongated) brush-like pen.
The definition for this pen functor is here. This is a good example of functors, too.
// polygon/line coordinates FIXPOINT p[] = { { 10, 10 }, { 84, 18 }, { 100, 82 }, { 55, 100 }, { 20, 50 }, { 50, 40 }, }; const int pn = sizeof(p) / sizeof(p[0]); TSetDCPixel sdc(Canvas->Handle, clBlack), // create the foreground functor bkdc(Canvas->Handle, clRed); // create the background functor // apply the functors to the polygon points ScanPolygonPoints(p, pn, TDenseVisitor |
First we fill a polygon with a specific filling style (solid red background and black points at even distances from each other).
Then we draw a line around the polygon, with other color and pixel size (line width). The polyline is not closed, as we didn't add the first point at the last position.
FIXPOINT *p = ... Polyline(Canvas->Handle, p, 5); ScanPolylinePointsT(p, 5, TWideDashLine |
First we draw a single line with the given points.
The second call draws a more complex structure: rectangles with given length and width along the line.
The WideDash functor works so that it calculates the perpendicular points when a given length is reached along the line (the starting and ending postion of the rect), and then
uses the ScanPolyline function to draw the actual points.
TPointCollector pc; ScanLinePoints(0, 0, 120, 71, DFWrapper(pc)); // the DFWrapper makes the real functor available by reference (to store the results in the original object) // go through the collected points for (vector |
The same method can be used for the other geomteric functions (ScanPolylinePoints, ScanCirclePoints, ScanEllipsePoints, etc).
Attila NAGY | Last updated: 2018-08-30 |