File: GriPath.hh

package info (click to toggle)
gri 2.8.7-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,472 kB
  • ctags: 2,092
  • sloc: cpp: 33,255; lisp: 3,980; perl: 1,037; makefile: 668; sh: 301
file content (34 lines) | stat: -rw-r--r-- 1,305 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// GriPath -- store PostScript path
#if !defined(_GriPath_hh_)
#define _GriPath_hh_
#include "types.hh"
class GriPath
{
public:
	enum type {moveto, lineto};
	GriPath();
	GriPath(unsigned capacity);
	~GriPath();
	void clear();		// Allows reuse without realloc
	void expand();		// Get more space
	void push_back(double xx, double yy, char aa); // Append at end
	unsigned size();		// Return length of path
	void trim();		// remove extraneous moveto commands
	void stroke(units u, double width = -1, bool closepath = false); // Stroke the path
	void stroke_or_fill(char s_or_f, units u, double width = -1, bool closepath = false); // Stroke or fill
	void fill(units u, bool closepath = false);		// Fill path in
	void print();		// Mostly for debugging
	void translate(double dx, double dy); // Only makes sense if units_cm
	void scale(double enlargement); // Only makes sense if units_cm
	void rotate(double degrees); // Rotate anticlockwise
	double get_x(unsigned offset) {return x[offset];} // bug: no checking
	double get_y(unsigned offset) {return y[offset];} // no checking
	rectangle bounding_box(units u);
private:
	unsigned int depth;		// Length of path
	unsigned int capacity;	// Max elements in path; see expand\(\)
	double *x;			// Data
	double *y;			// Data
	type *action;		// 'm' or 'l'
};
#endif