xref: /haiku/src/libs/icon/transformer/PathSource.cpp (revision 1564b19c80637a2ba13949db0056215699b7b418)
1 /*
2  * Copyright 2006, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 
9 #include "PathSource.h"
10 
11 #include "PathContainer.h"
12 #include "VectorPath.h"
13 
14 // constructor
15 PathSource::PathSource(PathContainer* paths)
16 	: VertexSource(),
17 	  fPaths(paths),
18 	  fAGGPath(),
19 	  fAGGCurvedPath(fAGGPath)
20 {
21 }
22 
23 // destructor
24 PathSource::~PathSource()
25 {
26 }
27 
28 // rewind
29 void
30 PathSource::rewind(unsigned path_id)
31 {
32 	fAGGCurvedPath.rewind(path_id);
33 }
34 
35 // vertex
36 unsigned
37 PathSource::vertex(double* x, double* y)
38 {
39 	return fAGGCurvedPath.vertex(x, y);
40 }
41 
42 // WantsOpenPaths
43 bool
44 PathSource::WantsOpenPaths() const
45 {
46 	return false;
47 }
48 
49 // ApproximationScale
50 double
51 PathSource::ApproximationScale() const
52 {
53 	return 1.0;
54 }
55 
56 // #pragma mark -
57 
58 // Update
59 void
60 PathSource::Update(bool leavePathsOpen, double approximationScale)
61 {
62 	fAGGPath.remove_all();
63 
64 	int32 count = fPaths->CountPaths();
65 	for (int32 i = 0; i < count; i++) {
66 		fPaths->PathAtFast(i)->GetAGGPathStorage(fAGGPath);
67 		if (!leavePathsOpen)
68 			fAGGPath.close_polygon();
69 	}
70 
71 	fAGGCurvedPath.approximation_scale(approximationScale);
72 }
73 
74