diff --git a/examples/raw/painting.sky b/examples/raw/painting.sky index e295abd3c6..fcfa3d56b3 100644 --- a/examples/raw/painting.sky +++ b/examples/raw/painting.sky @@ -19,13 +19,13 @@ void main() { context.save(); - context.clipRect(new Rect()..setLTRB(0.0, 0.0, context.width, radius)); + context.clipRect(new Rect.fromLTRB(0.0, 0.0, context.width, radius)); context.translate(mid.x, mid.y); paint.setARGB(128, 255, 0, 255); context.rotateDegrees(45.0); - context.drawRect(new Rect()..setLTRB(-radius, -radius, radius, radius), + context.drawRect(new Rect.fromLTRB(-radius, -radius, radius, radius), paint); // Scale x and y by 0.5. @@ -40,18 +40,25 @@ void main() { context.restore(); + context.translate(0.0, 50.0); var builder = new LayerDrawLooperBuilder() ..addLayerOnTop( - new DrawLooperLayerInfo()..setOffset(150.0, 0.0)..setPaintBits(-1), + new DrawLooperLayerInfo() + ..setOffset(150.0, 0.0)..setPaintBits(-1)..setColorMode(1), (Paint layerPaint) { - // TODO(mpcomplete): This won't do anything until we add support for - // setting the color filter. - layerPaint.setARGB(128, 0, 0, 255); + layerPaint.setARGB(128, 255, 255, 0); + layerPaint.setColorFilter(new ColorFilter(0x770000ff, 5)); }) ..addLayerOnTop( - new DrawLooperLayerInfo()..setOffset(75.0, 75.0)..setPaintBits(0), + new DrawLooperLayerInfo()..setOffset(75.0, 75.0)..setColorMode(1), (Paint layerPaint) { layerPaint.setARGB(128, 255, 0, 0); + }) + ..addLayerOnTop( + new DrawLooperLayerInfo()..setOffset(225.0, 75.0), + (Paint layerPaint) { + // Since this layer uses a DST color mode, this has no effect. + layerPaint.setARGB(128, 255, 0, 0); }); paint.setDrawLooper(builder.build()); context.drawCircle(0.0, 0.0, radius, paint); diff --git a/examples/raw/shadow.dart b/examples/raw/shadow.dart new file mode 100644 index 0000000000..a83602e88d --- /dev/null +++ b/examples/raw/shadow.dart @@ -0,0 +1,34 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:sky'; + +void beginFrame(double timeStamp) { + var size = 100.0; + PictureRecorder canvas = new PictureRecorder(view.width, view.height); + canvas.translate(size + 10.0, size + 10.0); + + Paint paint = new Paint(); + paint.setARGB(255, 0, 255, 0); + var builder = new LayerDrawLooperBuilder() + // Shadow layer. + ..addLayerOnTop( + new DrawLooperLayerInfo()..setOffset(5.0, 5.0)..setColorMode(5), + (Paint layerPaint) { + layerPaint.setARGB(128, 55, 55, 55); + // TODO(mpcomplete): add blur filter + }) + // Main layer. + ..addLayerOnTop(new DrawLooperLayerInfo(), (Paint) {}); + paint.setDrawLooper(builder.build()); + + canvas.drawPaint(new Paint()..setARGB(255, 255, 255, 255)); + canvas.drawRect(new Rect.fromLTRB(-size, -size, size, size), paint); + view.picture = canvas.endRecording(); +} + +void main() { + view.setBeginFrameCallback(beginFrame); + view.scheduleFrame(); +}