Commit a0609d1f authored by Eric Seidel's avatar Eric Seidel

Make it possible to custom-paint without an Element.

This adds a new abstract 'Canvas' which is similar to SkCanvas.
PaintContext implements Canvas while still having its
own commit() method to cause the paint actions to apply to
the Element for the next frame.
This adds a new PictureRecorder which also implements Canvas
and has an endRecording() method which returns a Picture
(another new interface) which can be held from Dart.

There is also now a rootPicture setter on Document which takes
a Picture and will then make the Document draw that Picture
until changed.

This piggybacks on the existing custom painting system
which adds the painting at background-and-borders paint
time so technically if you both set rootPicture as well as
construct a DOM you will draw the DOM on top of your picture. :)

R=mpcomplete@chromium.org

Review URL: https://codereview.chromium.org/1122423009
parent 3a138caa
<script>
import "dart:math";
import 'dart:sky';
void main() {
double width = window.innerWidth.toDouble();
double height = window.innerHeight.toDouble();
PictureRecorder recorder = new PictureRecorder(width, height);
double radius = min(width, height) * 0.45;
Paint paint = new Paint()..setARGB(255, 0, 255, 0);
recorder.drawCircle(width / 2, height / 2, radius, paint);
document.rootPicture = recorder.endRecording();
}
</script>
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