libroot_debug: Merge guarded heap into libroot_debug.
[haiku.git] / src / tests / servers / app / painter / ShapeConverter.cpp
blobaa7e62620044f0323c58b62b9f59bd7bee1fb9f6
1 /*
2 * Copyright 2005, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Simple BShape to agg::path_storage converter, implemented as BShapeIterator.
7 */
10 #include "ShapeConverter.h"
12 // constructor
13 ShapeConverter::ShapeConverter()
14 : BShapeIterator(),
15 Transformable(),
16 fPath(NULL)
20 // constructor
21 ShapeConverter::ShapeConverter(agg::path_storage* path)
22 : BShapeIterator(),
23 Transformable(),
24 fPath(path)
28 // SetPath
29 void
30 ShapeConverter::SetPath(agg::path_storage* path)
32 fPath = path;
35 // IterateMoveTo
36 status_t
37 ShapeConverter::IterateMoveTo(BPoint* point)
39 double x = point->x;
40 double y = point->y;
41 Transform(&x, &y);
43 fPath->move_to(x, y);
45 return B_OK;
48 // IterateLineTo
49 status_t
50 ShapeConverter::IterateLineTo(int32 lineCount, BPoint* linePts)
52 while (lineCount--) {
54 double x = linePts->x;
55 double y = linePts->y;
56 Transform(&x, &y);
58 fPath->line_to(x, y);
60 linePts++;
62 return B_OK;
65 // IterateBezierTo
66 status_t
67 ShapeConverter::IterateBezierTo(int32 bezierCount, BPoint* bezierPts)
69 bezierCount /= 3;
70 while (bezierCount--) {
72 double x1 = bezierPts[0].x;
73 double y1 = bezierPts[0].y;
75 double x2 = bezierPts[1].x;
76 double y2 = bezierPts[1].y;
78 double x3 = bezierPts[2].x;
79 double y3 = bezierPts[2].y;
81 Transform(&x1, &y1);
82 Transform(&x2, &y2);
83 Transform(&x3, &y3);
85 fPath->curve4(x1, y1, x2, y2, x3, y3);
87 bezierPts += 3;
89 return B_OK;
92 // IterateClose
93 status_t
94 ShapeConverter::IterateClose()
96 fPath->close_polygon();
97 return B_OK;