Created
December 7, 2013 06:55
-
-
Save bp74/7838125 to your computer and use it in GitHub Desktop.
This is a simple test for the blur bitmap filter in StageXL:
https://github.com/bp74/StageXL/blob/master/lib/src/filters/blur_filter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html' as html; | |
import 'package:stagexl/stagexl.dart'; | |
void main() { | |
var stage = new Stage("myStage", html.querySelector("#stage")); | |
var renderLoop = new RenderLoop(); | |
renderLoop.addStage(stage); | |
BitmapData.load("Astronaut.jpg").then((bitmapData) { | |
var targetBitmapData = new BitmapData(bitmapData.width + 40, bitmapData.height + 40, true, Color.Transparent); | |
var filter = new BlurFilter(10, 10); | |
var rectangle = new Rectangle(0, 0, bitmapData.width, bitmapData.height); | |
//------------- | |
var sw = new Stopwatch(); | |
sw.start(); | |
for(int i = 0 ; i < 100; i++) { | |
targetBitmapData.clear(); | |
targetBitmapData.applyFilter(bitmapData, rectangle, new Point(20, 20), filter); | |
} | |
print(sw.elapsedMilliseconds); | |
//------------- | |
var bitmap1 = new Bitmap(bitmapData); | |
bitmap1.x = 20; | |
bitmap1.y = 20; | |
stage.addChild(bitmap1); | |
var bitmap2 = new Bitmap(targetBitmapData); | |
bitmap2.x = 400; | |
bitmap2.y = 0; | |
stage.addChild(bitmap2); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>FilterTest</title> | |
<link rel="stylesheet" href="filtertest.css"> | |
</head> | |
<body> | |
<canvas id="stage" width="940" height="500"></canvas> | |
<script type="application/dart" src="filtertest.dart"></script> | |
<script src="packages/browser/dart.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment