Commit 96b04e34 authored by Matt Perry's avatar Matt Perry

Add an API to set the ColorFilter on a Paint object.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1158693005
parent db50ce16
......@@ -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);
......
// 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();
}
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