comparison doodle/tk/pixel_model.d @ 78:024a5608087f

Meh
author "David Bryant <bagnose@gmail.com>"
date Sun, 15 Aug 2010 15:19:14 +0930
parents 15ca7d5cd1ed
children 535bae7a7305
comparison
equal deleted inserted replaced
77:15ca7d5cd1ed 78:024a5608087f
7 private { 7 private {
8 import doodle.core.misc; 8 import doodle.core.misc;
9 } 9 }
10 10
11 // This class manages the relationship between screen space and model space. 11 // This class manages the relationship between screen space and model space.
12 // Screen is defined as the current window/viewport into the model
12 // It provides convenient high-level operations. 13 // It provides convenient high-level operations.
13 // 14 //
14 // x and y run right and up respectively for screen and model space 15 // x and y run right and up respectively for screen and model space
15 16
16 class ScreenModel { 17 class ScreenModel {
60 Rectangle screenToModel(in Rectangle model) const { return Rectangle(screenToModel(model.position), screenToModel(model.size)); } 61 Rectangle screenToModel(in Rectangle model) const { return Rectangle(screenToModel(model.position), screenToModel(model.size)); }
61 62
62 private { 63 private {
63 static double clampZoom(in double zoom) { return clamp(zoom, 0.1, 10.0); } 64 static double clampZoom(in double zoom) { return clamp(zoom, 0.1, 10.0); }
64 65
65 // Screen units are screens 66 // Screen units are pixels
66 // Model units are millimetres 67 // Model units are millimetres
67 double _zoom; // screens-per-millimetre 68 double _zoom; // pixels-per-millimetre
68 Rectangle _viewBoundsScreen; // bounds of the viewport in screens 69 Rectangle _viewBoundsScreen; // bounds of the viewport in screen space
69 Point _viewCentreModel; // where in the model is the centre of our view 70 Point _viewCentreModel; // where in the model is the centre of our screen
70 Rectangle _canvasBoundsModel; // the bounds of the canvas in millimetres 71 Rectangle _canvasBoundsModel; // the bounds of the canvas in model space
71 } 72 }
72 } 73 }