comparison doodle/tk/geometry.d @ 62:6c3993f4c3eb

Checkpoint
author daveb
date Thu, 12 Aug 2010 11:48:55 +0930
parents 0eaf39fda206
children 43cc2135ced0
comparison
equal deleted inserted replaced
61:08ffc44fc21a 62:6c3993f4c3eb
41 41
42 Vector opSub(in Point p) const { 42 Vector opSub(in Point p) const {
43 return Vector(_x - p._x, _y - p._y); 43 return Vector(_x - p._x, _y - p._y);
44 } 44 }
45 45
46 string toString() const { 46 string toString() {
47 return std.string.format("(%f, %f)", _x, _y); 47 return std.string.format("(%f, %f)", _x, _y);
48 } 48 }
49 49
50 double x() const { return _x; } 50 double x() const { return _x; }
51 double y() const { return _y; } 51 double y() const { return _y; }
99 99
100 double length() const { 100 double length() const {
101 return sqrt(_x * _x + _y * _y); 101 return sqrt(_x * _x + _y * _y);
102 } 102 }
103 103
104 string toString() const { 104 string toString() {
105 return std.string.format("[%f, %f]", _x, _y); 105 return std.string.format("[%f, %f]", _x, _y);
106 } 106 }
107 107
108 double x() const { return _x; } 108 double x() const { return _x; }
109 double y() const { return _y; } 109 double y() const { return _y; }
210 210
211 // 211 //
212 212
213 Point centre() const { return _position + _size / 2.0; } 213 Point centre() const { return _position + _size / 2.0; }
214 214
215 string toString() const { 215 string toString() {
216 return std.string.format("{%s, %s}", _position, _size); 216 return std.string.format("{%s, %s}", _position, _size);
217 } 217 }
218 218
219 private { 219 private {
220 this(double x, double y, double w, double h) { 220 this(double x, double y, double w, double h) {
325 } 325 }
326 326
327 Point point() const { return _point; } 327 Point point() const { return _point; }
328 Vector gradient() const { return _gradient; } 328 Vector gradient() const { return _gradient; }
329 329
330 string toString() const { 330 string toString() {
331 return std.string.format("{%s %s}", _point, _gradient); 331 return std.string.format("{%s %s}", _point, _gradient);
332 } 332 }
333 333
334 private { 334 private {
335 Point _point; // Arbitrary point along line 335 Point _point; // Arbitrary point along line
370 } 370 }
371 371
372 Point begin() const { return _begin; } 372 Point begin() const { return _begin; }
373 Point end() const { return _end; } 373 Point end() const { return _end; }
374 374
375 string toString() const { 375 string toString() {
376 return std.string.format("{%s %s}", _begin, _end); 376 return std.string.format("{%s %s}", _begin, _end);
377 } 377 }
378 378
379 private { 379 private {
380 Point _begin, _end; 380 Point _begin, _end;