mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add Sky framework support for drawing images
R=abarth@chromium.org, abarth Review URL: https://codereview.chromium.org/1151753009
This commit is contained in:
parent
04169c4ce3
commit
205bd1449a
29
examples/raw/spinning_image.dart
Normal file
29
examples/raw/spinning_image.dart
Normal file
@ -0,0 +1,29 @@
|
||||
// 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';
|
||||
|
||||
double timeBase = null;
|
||||
|
||||
Image image;
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
if (timeBase == null) timeBase = timeStamp;
|
||||
double delta = timeStamp - timeBase;
|
||||
PictureRecorder canvas = new PictureRecorder(view.width, view.height);
|
||||
canvas.translate(view.width / 2.0, view.height / 2.0);
|
||||
canvas.rotateDegrees(delta / 10);
|
||||
canvas.scale(0.2, 0.2);
|
||||
Paint paint = new Paint()..setARGB(255, 0, 255, 0);
|
||||
canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint);
|
||||
view.picture = canvas.endRecording();
|
||||
view.scheduleFrame();
|
||||
}
|
||||
|
||||
void main() {
|
||||
image = new Image();
|
||||
image.src = "https://www.dartlang.org/logos/dart-logo.png";
|
||||
view.setBeginFrameCallback(beginFrame);
|
||||
view.scheduleFrame();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user