| OLD | NEW |
| 1 <sky> | 1 <sky> |
| 2 <style> | 2 <style> |
| 3 div { | 3 div { |
| 4 height: 200px; | 4 height: 200px; |
| 5 background-color: lightblue; | 5 background-color: lightblue; |
| 6 } | 6 } |
| 7 </style> | 7 </style> |
| 8 <div id="canvas" /> | 8 <div id="canvas" /> |
| 9 <script> | 9 <script> |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| 11 import 'dart:sky'; | 11 import 'dart:sky'; |
| 12 | 12 |
| 13 void main() { | 13 void main() { |
| 14 var element = document.getElementById('canvas'); | 14 var element = document.getElementById('canvas'); |
| 15 element.requestPaint((PaintingContext context) { | 15 element.requestPaint((PaintingContext context) { |
| 16 Paint paint = new Paint(); | 16 Paint paint = new Paint(); |
| 17 Point mid = new Point(context.width / 2.0, context.height / 2.0); | 17 Point mid = new Point(context.width / 2.0, context.height / 2.0); |
| 18 double radius = math.min(mid.x, mid.y); | 18 double radius = math.min(mid.x, mid.y); |
| 19 | 19 |
| 20 context.save(); | 20 context.save(); |
| 21 | 21 |
| 22 context.clipRect(new Rect.fromLTRB(0.0, 0.0, context.width, radius)); | 22 context.clipRect(new Rect.fromLTRB(0.0, 0.0, context.width, radius)); |
| 23 | 23 |
| 24 context.translate(mid.x, mid.y); | 24 context.translate(mid.x, mid.y); |
| 25 paint.color = const Color.fromARGB(128, 255, 0, 255); | 25 paint.setARGB(128, 255, 0, 255); |
| 26 context.rotateDegrees(45.0); | 26 context.rotateDegrees(45.0); |
| 27 | 27 |
| 28 context.drawRect(new Rect.fromLTRB(-radius, -radius, radius, radius), | 28 context.drawRect(new Rect.fromLTRB(-radius, -radius, radius, radius), |
| 29 paint); | 29 paint); |
| 30 | 30 |
| 31 // Scale x and y by 0.5. | 31 // Scale x and y by 0.5. |
| 32 var scaleMatrix = [ | 32 var scaleMatrix = [ |
| 33 0.5, 0.0, 0.0, | 33 0.5, 0.0, 0.0, |
| 34 0.0, 0.5, 0.0, | 34 0.0, 0.5, 0.0, |
| 35 0.0, 0.0, 1.0 | 35 0.0, 0.0, 1.0 |
| 36 ]; | 36 ]; |
| 37 context.concat(scaleMatrix); | 37 context.concat(scaleMatrix); |
| 38 paint.color = const Color.fromARGB(128, 0, 255, 0); | 38 paint.setARGB(128, 0, 255, 0); |
| 39 context.drawCircle(0.0, 0.0, radius, paint); | 39 context.drawCircle(0.0, 0.0, radius, paint); |
| 40 | 40 |
| 41 context.restore(); | 41 context.restore(); |
| 42 | 42 |
| 43 context.translate(0.0, 50.0); | 43 context.translate(0.0, 50.0); |
| 44 var builder = new LayerDrawLooperBuilder() | 44 var builder = new LayerDrawLooperBuilder() |
| 45 ..addLayerOnTop( | 45 ..addLayerOnTop( |
| 46 new DrawLooperLayerInfo() | 46 new DrawLooperLayerInfo() |
| 47 ..setOffset(150.0, 0.0)..setPaintBits(-1)..setColorMode(1), | 47 ..setOffset(150.0, 0.0)..setPaintBits(-1)..setColorMode(1), |
| 48 (Paint layerPaint) { | 48 (Paint layerPaint) { |
| 49 layerPaint.color = const Color.fromARGB(128, 255, 255, 0); | 49 layerPaint.setARGB(128, 255, 255, 0); |
| 50 layerPaint.setColorFilter(new ColorFilter(0x770000ff, 5)); | 50 layerPaint.setColorFilter(new ColorFilter(0x770000ff, 5)); |
| 51 }) | 51 }) |
| 52 ..addLayerOnTop( | 52 ..addLayerOnTop( |
| 53 new DrawLooperLayerInfo()..setOffset(75.0, 75.0)..setColorMode(1), | 53 new DrawLooperLayerInfo()..setOffset(75.0, 75.0)..setColorMode(1), |
| 54 (Paint layerPaint) { | 54 (Paint layerPaint) { |
| 55 layerPaint.color = const Color.fromARGB(128, 255, 0, 0); | 55 layerPaint.setARGB(128, 255, 0, 0); |
| 56 }) | 56 }) |
| 57 ..addLayerOnTop( | 57 ..addLayerOnTop( |
| 58 new DrawLooperLayerInfo()..setOffset(225.0, 75.0), | 58 new DrawLooperLayerInfo()..setOffset(225.0, 75.0), |
| 59 (Paint layerPaint) { | 59 (Paint layerPaint) { |
| 60 // Since this layer uses a DST color mode, this has no effect. | 60 // Since this layer uses a DST color mode, this has no effect. |
| 61 layerPaint.color = const Color.fromARGB(128, 255, 0, 0); | 61 layerPaint.setARGB(128, 255, 0, 0); |
| 62 }); | 62 }); |
| 63 paint.setDrawLooper(builder.build()); | 63 paint.setDrawLooper(builder.build()); |
| 64 context.drawCircle(0.0, 0.0, radius, paint); | 64 context.drawCircle(0.0, 0.0, radius, paint); |
| 65 | 65 |
| 66 context.commit(); | 66 context.commit(); |
| 67 }); | 67 }); |
| 68 } | 68 } |
| 69 </script> | 69 </script> |
| 70 </sky> | 70 </sky> |
| OLD | NEW |