Commit 769cef59 authored by Matt Perry's avatar Matt Perry

Flesh out the Painting API a bit.

This exposes most methods from Skia's C canvas API to Dart. For now, SkRect and
SkMatrix are represented simply as an array of floats, which requires a
conversion at the bindings layer. More complex types like SkPath are still TODO.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1144483002
parent a0609d1f
<sky>
<style>
div {
height: 200px;
background-color: lightblue;
}
</style>
<div id="canvas" />
<script>
import 'dart:math' as math;
import 'dart:sky';
void main() {
var element = document.getElementById('canvas');
element.requestPaint((PaintingContext context) {
Paint paint = new Paint();
double radius = math.min(context.width, context.height) / 2.0;
context.save();
context.clipRect([0.0, 0.0, context.width, radius]);
context.translate(context.width / 2.0, context.height / 2.0);
paint.setARGB(128, 255, 0, 255);
context.rotateDegrees(45.0);
context.drawRect([-radius, -radius, radius, radius], paint);
// Scale x and y by 0.5.
var scaleMatrix = [
0.5, 0.0, 0.0,
0.0, 0.5, 0.0,
0.0, 0.0, 1.0
];
context.concat(scaleMatrix);
paint.setARGB(128, 0, 255, 0);
context.drawCircle(0.0, 0.0, radius, paint);
context.restore();
context.drawCircle(0.0, 0.0, radius, paint);
context.commit();
});
}
</script>
</sky>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment