Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very simple hack to work around scaling problem #5

Merged
merged 1 commit into from
Jun 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/src/visualisation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ class Visualisation {
});
}

void render_SCALING_HACK(num width, num height) {
_applyTransforms();

int w = (xRange.max - xRange.min).ceil() + 1;
int h = (yRange.max - yRange.min).ceil() + 1;
Image image = new Image(width, height);

for (int i = 0; i < xs.length; i++) {
image.setPixel(
(((xs[i] - xRange.min) / w) * width).floor(),
(((ys[i] - yRange.min) / h) * height).floor(), colors[i]);
}

// if (width != -1) {
// image = copyResize(image, width, height, NEAREST);
// }
new io.File(_imagePrefix + new DateTime.now().toString() + '.png')
.create(recursive: true)
.then((io.File file) {
file.writeAsBytesSync(encodePng(image));
});
}

/// Applies the transforms to the stored data points.
/// It modifies the data point values, so no more data should be added after
/// calling this method.
Expand Down