Transpiled version (10106L) is out of date.
1 | sclass ScaledDiagram { |
2 | settable int w = 600; |
3 | settable int h = 400; |
4 | settable int horizontalMargin = 10; |
5 | settable int verticalMargin = 10; |
6 | |
7 | settable DoubleRange horizontalRange; |
8 | settable DoubleRange verticalRange; |
9 | |
10 | // Ranges in pixels that we can paint in (image size minus margins) |
11 | DoubleRange xRange() { ret doubleRange(horizontalMargin, w-horizontalMargin); } |
12 | DoubleRange yRange() { ret doubleRange(h-verticalMargin, verticalMargin); } |
13 | |
14 | double xToScreen(double x) { ret transformBetweenDoubleRanges(x, horizontalRange(), xRange()); } |
15 | double yToScreen(double y) { ret transformBetweenDoubleRanges(y, verticalRange(), yRange()); } |
16 | |
17 | int xToScreen_int(double x) { ret iround(xToScreen(x)); } |
18 | int yToScreen_int(double y) { ret iround(yToScreen(y)); } |
19 | |
20 | double xFromScreen(double x) { ret transformBetweenDoubleRanges(x, xRange(), horizontalRange()); } |
21 | double yFromScreen(double y) { ret transformBetweenDoubleRanges(y, yRange(), verticalRange()); } |
22 | |
23 | public int getWidth() { ret w; } |
24 | public int getHeight() { ret h; } |
25 | |
26 | bool hasScale() { ret horizontalRange != null && verticalRange != null; } |
27 | } |
Began life as a copy of #1036145
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036167 |
Snippet name: | ScaledDiagram |
Eternal ID of this version: | #1036167/8 |
Text MD5: | c699daae33bd5cd0fe3da259fb5b543d |
Author: | stefan |
Category: | javax / gazelle 22 |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-03-12 18:06:34 |
Source code size: | 1162 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 174 / 253 |
Version history: | 7 change(s) |
Referenced in: | [show references] |