mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add a basic custom painting facility to Sky
This CL adds just enough custom painting to Sky to make sky/examples/painting/circle.sky draw a circle. Over time, we should be able to elaborate this system into something interesting and to make it actually work in a reasonable way. R=ojan@chromium.org Review URL: https://codereview.chromium.org/1017593005
This commit is contained in:
parent
1f625c9665
commit
64dff80933
24
engine/src/flutter/examples/painting/circle.sky
Normal file
24
engine/src/flutter/examples/painting/circle.sky
Normal file
@ -0,0 +1,24 @@
|
||||
<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();
|
||||
paint.setARGB(128, 0, 255, 0);
|
||||
double radius = math.min(context.width, context.height) / 2.0;
|
||||
context.drawCircle(context.width / 2.0, context.height / 2.0, radius, paint);
|
||||
context.commit();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</sky>
|
||||
Loading…
x
Reference in New Issue
Block a user