comparison doodle/gtk/cairo.d @ 81:d92b9f04b1e8

Bed time
author "David Bryant <bagnose@gmail.com>"
date Mon, 16 Aug 2010 00:04:27 +0930
parents b759414d2b72
children
comparison
equal deleted inserted replaced
80:b759414d2b72 81:d92b9f04b1e8
14 // Drawing overrides: 14 // Drawing overrides:
15 15
16 void setLineStyle(LineStyle style) { 16 void setLineStyle(LineStyle style) {
17 switch (style) { 17 switch (style) {
18 case LineStyle.SOLID: 18 case LineStyle.SOLID:
19 _cr.setDash([ 4.0, 4.0 ], 0.0); 19 _cr.setDash([ ], 0.0);
20 break; 20 break;
21 case LineStyle.DASHED: 21 case LineStyle.DASHED:
22 _cr.setDash([ 4.0, 4.0 ], 0.0); 22 _cr.setDash([ 4.0, 4.0 ], 0.0);
23 break; 23 break;
24 case LineStyle.DOTTED: 24 case LineStyle.DOTTED:
25 _cr.setDash([ 4.0, 4.0 ], 0.0); 25 _cr.setDash([ 1.0, 4.0 ], 0.0);
26 break; 26 break;
27 default: 27 default:
28 assert(0); 28 assert(0);
29 } 29 }
30 } 30 }
37 void scale(in double s) { _cr.scale(s, s); } 37 void scale(in double s) { _cr.scale(s, s); }
38 38
39 void pushState() { _cr.save; } 39 void pushState() { _cr.save; }
40 void popState() { _cr.restore; } 40 void popState() { _cr.restore; }
41 41
42 void drawRectangle(in Rectangle rectangle, bool fill) { 42 void drawRectangle(in Rectangle rectangle, bool fill = false) {
43 _cr.rectangle(rectangle.position.x, rectangle.position.y, 43 _cr.rectangle(rectangle.position.x, rectangle.position.y,
44 rectangle.size.x, rectangle.size.y); 44 rectangle.size.x, rectangle.size.y);
45 if (fill) { _cr.fill; } else { _cr.stroke; } 45 if (fill) { _cr.fill; } else { _cr.stroke; }
46 } 46 }
47 47
48 void drawEllipse(in Rectangle rectangle, bool fill) { 48 void drawEllipse(in Rectangle rectangle, bool fill = false) {
49 // NYI 49 // NYI
50 } 50 }
51 51
52 void drawSegment(in Segment segment) { 52 void drawSegment(in Segment segment) {
53 _cr.moveTo(segment.begin.x, segment.begin.y); 53 _cr.moveTo(segment.begin.x, segment.begin.y);
64 void drawVLine(in double x, in double y0, in double y1) { 64 void drawVLine(in double x, in double y0, in double y1) {
65 _cr.moveTo(x, y0); 65 _cr.moveTo(x, y0);
66 _cr.lineTo(x, y1); 66 _cr.lineTo(x, y1);
67 } 67 }
68 68
69 void drawPoly(in Point[] points, bool fill) { 69 void drawPoly(in Point[] points, bool fill = false) {
70 assert(points.length >= 2); 70 assert(points.length >= 2);
71 foreach(i, p; points) { 71 foreach(i, p; points) {
72 if (i == 0) { _cr.moveTo(p.x, p.y); } 72 if (i == 0) { _cr.moveTo(p.x, p.y); }
73 else { _cr.lineTo(p.x, p.y); } 73 else { _cr.lineTo(p.x, p.y); }
74 } 74 }