• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 15th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. // Draw an ellipse inside a rectangle using Bézier curves. Specify a square to draw a circle
2. void DrawEllipse(const IJawsMakoPtr jawsMako, IDOMFixedPagePtr& fixedPage, const FRect rect,
3.     const double strokeThickness, const IDOMBrushPtr solidBrush)
4. {
5.     // We can approximate a circle using four béziers. This is the parameter that is
6.     // used inside Jaws for this purpose
7.     double l = ((0.7071067812 - 0.5) * 8.0 / 3.0);
8.
9.     // And so we will offset the bézier control points by half that amount as the entire
10.     // circle is one unit in diameter.
11.     double c = l / 2.0;
12.
13.     // Create the geometry
14.     IDOMPathGeometryPtr geometry = createInstance<IDOMPathGeometry>(jawsMako);
15.
16.     // Scale to required size. As what we are scaling is 1x1, the scaling factor is simply the rect dimensions
17.     geometry->setRenderTransform(FMatrix(rect.dX , 0, 0, rect.dY, rect.x, rect.y));
18.
19.     // And a figure. We start at the top and head clockwise. But remember
20.     // we are upside down compared to PDF, so the direction and start point changes.
21.     IDOMPathFigure::Data params;
22.     params.startPoint = FPoint(0.5, 0.0);
23.     params.isClosed = true;
24.     params.isFilled = true;
25.     IDOMPathFigurePtr figure = createInstance<IDOMPathFigure>(jawsMako);
26.     figure->init(&params);
27.
28.     // And finally the bézier segment
29.     IDOMPolyBezierSegmentPtr segment = createInstance<IDOMPolyBezierSegment>(jawsMako);
30.
31.     // With the points as follows
35.
39.
43.
47.
50.
51.     // And now draw a path using the marker brush
52.     IDOMPathNodePtr path;
53.     if (strokeThickness) {
54.         path = IDOMPathNode::createStroked(jawsMako, geometry, solidBrush);
55.         path->setStrokeThickness(strokeThickness);
56.     }
57.     else
58.         path = IDOMPathNode::createFilled(jawsMako, geometry, solidBrush);
59.
60.     // Finally add to the fixed page
61.     fixedPage->appendChild(path);
62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top