Import dart:ui as ui (instead of as sky)
This commit is contained in:
@@ -49,7 +49,7 @@ class ExplosionBig extends Explosion {
|
||||
|
||||
// Add ring
|
||||
Sprite sprtRing = new Sprite(sheet["explosion_ring.png"]);
|
||||
sprtRing.transferMode = sky.TransferMode.plus;
|
||||
sprtRing.transferMode = ui.TransferMode.plus;
|
||||
addChild(sprtRing);
|
||||
|
||||
Action scale = new ActionTween( (a) => sprtRing.scale = a, 0.2, 1.0, 0.75);
|
||||
@@ -63,7 +63,7 @@ class ExplosionBig extends Explosion {
|
||||
Sprite sprtFlare = new Sprite(sheet["explosion_flare.png"]);
|
||||
sprtFlare.pivot = new Point(0.3, 1.0);
|
||||
sprtFlare.scaleX = 0.3;
|
||||
sprtFlare.transferMode = sky.TransferMode.plus;
|
||||
sprtFlare.transferMode = ui.TransferMode.plus;
|
||||
sprtFlare.rotation = randomDouble() * 360.0;
|
||||
addChild(sprtFlare);
|
||||
|
||||
@@ -86,7 +86,7 @@ class ExplosionMini extends Explosion {
|
||||
Sprite star = new Sprite(sheet["star_0.png"]);
|
||||
star.scale = 0.5;
|
||||
star.colorOverlay = new Color(0xff95f4fb);
|
||||
star.transferMode = sky.TransferMode.plus;
|
||||
star.transferMode = ui.TransferMode.plus;
|
||||
addChild(star);
|
||||
|
||||
double rotationStart = randomDouble() * 90.0;
|
||||
|
||||
@@ -2,7 +2,7 @@ library game;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:skysprites/skysprites.dart';
|
||||
|
||||
@@ -26,7 +26,7 @@ class GameDemoNode extends NodeWithSize {
|
||||
addChild(_starField);
|
||||
|
||||
// Add nebula
|
||||
_nebula = new RepeatedImage(_images["assets/nebula.png"], sky.TransferMode.plus);
|
||||
_nebula = new RepeatedImage(_images["assets/nebula.png"], ui.TransferMode.plus);
|
||||
addChild(_nebula);
|
||||
|
||||
// Setup game screen, it will always be anchored to the bottom of the screen
|
||||
|
||||
@@ -16,7 +16,7 @@ abstract class GameObject extends Node {
|
||||
Paint _paintDebug = new Paint()
|
||||
..color=new Color(0xffff0000)
|
||||
..strokeWidth = 1.0
|
||||
..setStyle(sky.PaintingStyle.stroke);
|
||||
..setStyle(ui.PaintingStyle.stroke);
|
||||
|
||||
bool collidingWith(GameObject obj) {
|
||||
return (GameMath.distanceBetweenPoints(position, obj.position)
|
||||
@@ -111,7 +111,7 @@ class Ship extends GameObject {
|
||||
|
||||
_sprtShield = new Sprite(f.sheet["shield.png"]);
|
||||
_sprtShield.scale = 0.35;
|
||||
_sprtShield.transferMode = sky.TransferMode.plus;
|
||||
_sprtShield.transferMode = ui.TransferMode.plus;
|
||||
addChild(_sprtShield);
|
||||
|
||||
radius = 20.0;
|
||||
@@ -188,7 +188,7 @@ class Laser extends GameObject {
|
||||
Sprite sprt = new Sprite(f.sheet["explosion_particle.png"]);
|
||||
sprt.scale = 0.5;
|
||||
sprt.colorOverlay = laserColor;
|
||||
sprt.transferMode = sky.TransferMode.plus;
|
||||
sprt.transferMode = ui.TransferMode.plus;
|
||||
addChild(sprt);
|
||||
sprites.add(sprt);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class PowerBar extends NodeWithSize {
|
||||
Paint _paintOutline = new Paint()
|
||||
..color = new Color(0xffffffff)
|
||||
..strokeWidth = 1.0
|
||||
..setStyle(sky.PaintingStyle.stroke);
|
||||
..setStyle(ui.PaintingStyle.stroke);
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
applyTransformForPivot(canvas);
|
||||
|
||||
@@ -4,7 +4,7 @@ class RepeatedImage extends Node {
|
||||
Sprite _sprt0;
|
||||
Sprite _sprt1;
|
||||
|
||||
RepeatedImage(sky.Image image, [sky.TransferMode mode = null]) {
|
||||
RepeatedImage(ui.Image image, [ui.TransferMode mode = null]) {
|
||||
_sprt0 = new Sprite.fromImage(image);
|
||||
_sprt0.size = new Size(1024.0, 1024.0);
|
||||
_sprt0.pivot = Point.origin;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
part of game;
|
||||
|
||||
class StarField extends NodeWithSize {
|
||||
sky.Image _image;
|
||||
ui.Image _image;
|
||||
SpriteSheet _spriteSheet;
|
||||
int _numStars;
|
||||
bool _autoScroll;
|
||||
@@ -15,9 +15,9 @@ class StarField extends NodeWithSize {
|
||||
Size _paddedSize = Size.zero;
|
||||
|
||||
Paint _paint = new Paint()
|
||||
..filterQuality = sky.FilterQuality.low
|
||||
..filterQuality = ui.FilterQuality.low
|
||||
..isAntiAlias = false
|
||||
..transferMode = sky.TransferMode.plus;
|
||||
..transferMode = ui.TransferMode.plus;
|
||||
|
||||
StarField(this._spriteSheet, this._numStars, [this._autoScroll = false]) : super(Size.zero) {
|
||||
_image = _spriteSheet.image;
|
||||
@@ -48,9 +48,9 @@ class StarField extends NodeWithSize {
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
// Create a transform for each star
|
||||
List<sky.RSTransform> transforms = [];
|
||||
List<ui.RSTransform> transforms = [];
|
||||
for (int i = 0; i < _numStars; i++) {
|
||||
sky.RSTransform transform = new sky.RSTransform(
|
||||
ui.RSTransform transform = new ui.RSTransform(
|
||||
_starScales[i],
|
||||
0.0,
|
||||
_starPositions[i].x - _padding,
|
||||
@@ -60,7 +60,7 @@ class StarField extends NodeWithSize {
|
||||
}
|
||||
|
||||
// Draw the stars
|
||||
canvas.drawAtlas(_image, transforms, _rects, _colors, sky.TransferMode.modulate, null, _paint);
|
||||
canvas.drawAtlas(_image, transforms, _rects, _colors, ui.TransferMode.modulate, null, _paint);
|
||||
}
|
||||
|
||||
void move(double dx, double dy) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -202,7 +202,7 @@ class TestPerformanceAtlas extends PerformanceTest {
|
||||
double rotation = 0.0;
|
||||
List<Rect> rects = [];
|
||||
Paint cachedPaint = new Paint()
|
||||
..filterQuality = sky.FilterQuality.low
|
||||
..filterQuality = ui.FilterQuality.low
|
||||
..isAntiAlias = false;
|
||||
|
||||
TestPerformanceAtlas() {
|
||||
@@ -216,7 +216,7 @@ class TestPerformanceAtlas extends PerformanceTest {
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
// Setup transforms
|
||||
List<sky.RSTransform> transforms = [];
|
||||
List<ui.RSTransform> transforms = [];
|
||||
|
||||
for (int x = 0; x < grid; x++) {
|
||||
for (int y = 0; y < grid; y++) {
|
||||
@@ -238,12 +238,12 @@ class TestPerformanceAtlas extends PerformanceTest {
|
||||
rotation += 1.0;
|
||||
}
|
||||
|
||||
sky.RSTransform createTransform(double x, double y, double ax, double ay, double rot, double scale) {
|
||||
ui.RSTransform createTransform(double x, double y, double ax, double ay, double rot, double scale) {
|
||||
double scos = math.cos(convertDegrees2Radians(rot)) * scale;
|
||||
double ssin = math.sin(convertDegrees2Radians(rot)) * scale;
|
||||
double tx = x + -scos * ax + ssin * ay;
|
||||
double ty = y + -ssin * ax - scos * ay;
|
||||
return new sky.RSTransform(scos, ssin, tx, ty);
|
||||
return new ui.RSTransform(scos, ssin, tx, ty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ class TestPerformanceAtlas2 extends PerformanceTest {
|
||||
double rotation = 0.0;
|
||||
List<Rect> rects = [];
|
||||
Paint cachedPaint = new Paint()
|
||||
..filterQuality = sky.FilterQuality.low
|
||||
..filterQuality = ui.FilterQuality.low
|
||||
..isAntiAlias = false;
|
||||
|
||||
TestPerformanceAtlas2() {
|
||||
@@ -269,7 +269,7 @@ class TestPerformanceAtlas2 extends PerformanceTest {
|
||||
|
||||
void paint(PaintingCanvas canvas) {
|
||||
// Setup transforms
|
||||
List<sky.RSTransform> transforms = [];
|
||||
List<ui.RSTransform> transforms = [];
|
||||
|
||||
for (int x = 12; x < grid - 12; x++) {
|
||||
for (int y = 0; y < grid; y++) {
|
||||
@@ -291,11 +291,11 @@ class TestPerformanceAtlas2 extends PerformanceTest {
|
||||
rotation += 1.0;
|
||||
}
|
||||
|
||||
sky.RSTransform createTransform(double x, double y, double ax, double ay, double rot, double scale) {
|
||||
ui.RSTransform createTransform(double x, double y, double ax, double ay, double rot, double scale) {
|
||||
double scos = math.cos(convertDegrees2Radians(rot)) * scale;
|
||||
double ssin = math.sin(convertDegrees2Radians(rot)) * scale;
|
||||
double tx = x + -scos * ax + ssin * ay;
|
||||
double ty = y + -ssin * ax - scos * ay;
|
||||
return new sky.RSTransform(scos, ssin, tx, ty);
|
||||
return new ui.RSTransform(scos, ssin, tx, ty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -85,7 +85,7 @@ class MineDiggerState extends State<MineDigger> {
|
||||
}
|
||||
|
||||
PointerEventListener _pointerDownHandlerFor(int posX, int posY) {
|
||||
return (sky.PointerEvent event) {
|
||||
return (ui.PointerEvent event) {
|
||||
if (event.buttons == 1) {
|
||||
probe(posX, posY);
|
||||
} else if (event.buttons == 2) {
|
||||
@@ -190,7 +190,7 @@ class MineDiggerState extends State<MineDigger> {
|
||||
);
|
||||
}
|
||||
|
||||
void handleToolbarPointerDown(sky.PointerEvent event) {
|
||||
void handleToolbarPointerDown(ui.PointerEvent event) {
|
||||
setState(() {
|
||||
resetGame();
|
||||
});
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
void drawText(sky.Canvas canvas, String lh) {
|
||||
sky.Paint paint = new sky.Paint();
|
||||
void drawText(ui.Canvas canvas, String lh) {
|
||||
ui.Paint paint = new ui.Paint();
|
||||
|
||||
// offset down
|
||||
canvas.translate(0.0, 100.0);
|
||||
|
||||
// set up the text
|
||||
sky.Document document = new sky.Document();
|
||||
sky.Text arabic = document.createText("مرحبا");
|
||||
sky.Text english = document.createText(" Hello");
|
||||
sky.Element block = document.createElement('div');
|
||||
ui.Document document = new ui.Document();
|
||||
ui.Text arabic = document.createText("مرحبا");
|
||||
ui.Text english = document.createText(" Hello");
|
||||
ui.Element block = document.createElement('div');
|
||||
block.style['display'] = 'paragraph';
|
||||
block.style['font-family'] = 'monospace';
|
||||
block.style['font-size'] = '50px';
|
||||
@@ -23,21 +23,21 @@ void drawText(sky.Canvas canvas, String lh) {
|
||||
block.style['color'] = '#0000A0';
|
||||
block.appendChild(arabic);
|
||||
block.appendChild(english);
|
||||
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
|
||||
ui.LayoutRoot layoutRoot = new ui.LayoutRoot();
|
||||
layoutRoot.rootElement = block;
|
||||
layoutRoot.maxWidth = sky.view.width - 20.0; // you need to set a width for this to paint
|
||||
layoutRoot.maxWidth = ui.view.width - 20.0; // you need to set a width for this to paint
|
||||
layoutRoot.layout();
|
||||
|
||||
// draw a line at the text's baseline
|
||||
sky.Path path = new sky.Path();
|
||||
ui.Path path = new ui.Path();
|
||||
path.moveTo(0.0, 0.0);
|
||||
path.lineTo(block.maxContentWidth, 0.0);
|
||||
path.moveTo(0.0, block.alphabeticBaseline);
|
||||
path.lineTo(block.maxContentWidth, block.alphabeticBaseline);
|
||||
path.moveTo(0.0, block.height);
|
||||
path.lineTo(block.maxContentWidth, block.height);
|
||||
paint.color = const sky.Color(0xFFFF9000);
|
||||
paint.setStyle(sky.PaintingStyle.stroke);
|
||||
paint.color = const ui.Color(0xFFFF9000);
|
||||
paint.setStyle(ui.PaintingStyle.stroke);
|
||||
paint.strokeWidth = 3.0;
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
@@ -45,14 +45,14 @@ void drawText(sky.Canvas canvas, String lh) {
|
||||
layoutRoot.paint(canvas);
|
||||
}
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
|
||||
sky.Paint paint = new sky.Paint();
|
||||
paint.color = const sky.Color(0xFFFFFFFF);
|
||||
paint.setStyle(sky.PaintingStyle.fill);
|
||||
canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, sky.view.width, sky.view.height), paint);
|
||||
ui.Paint paint = new ui.Paint();
|
||||
paint.color = const ui.Color(0xFFFFFFFF);
|
||||
paint.setStyle(ui.PaintingStyle.fill);
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(0.0, 0.0, ui.view.width, ui.view.height), paint);
|
||||
|
||||
canvas.translate(10.0, 0.0);
|
||||
drawText(canvas, '1.0');
|
||||
@@ -61,29 +61,29 @@ sky.Picture paint(sky.Rect paintBounds) {
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
}
|
||||
|
||||
void main() {
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -2,56 +2,56 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
sky.Color color;
|
||||
ui.Color color;
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
sky.Size size = paintBounds.size;
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
ui.Size size = paintBounds.size;
|
||||
|
||||
double radius = size.shortestSide * 0.45;
|
||||
sky.Paint paint = new sky.Paint()
|
||||
ui.Paint paint = new ui.Paint()
|
||||
..color = color;
|
||||
canvas.drawCircle(size.center(sky.Point.origin), radius, paint);
|
||||
canvas.drawCircle(size.center(ui.Point.origin), radius, paint);
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
}
|
||||
|
||||
bool handleEvent(sky.Event event) {
|
||||
bool handleEvent(ui.Event event) {
|
||||
if (event.type == 'pointerdown') {
|
||||
color = new sky.Color.fromARGB(255, 0, 0, 255);
|
||||
sky.view.scheduleFrame();
|
||||
color = new ui.Color.fromARGB(255, 0, 0, 255);
|
||||
ui.view.scheduleFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.type == 'pointerup') {
|
||||
color = new sky.Color.fromARGB(255, 0, 255, 0);
|
||||
sky.view.scheduleFrame();
|
||||
color = new ui.Color.fromARGB(255, 0, 255, 0);
|
||||
ui.view.scheduleFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ bool handleEvent(sky.Event event) {
|
||||
|
||||
void main() {
|
||||
print('Hello, world');
|
||||
color = new sky.Color.fromARGB(255, 0, 255, 0);
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.setEventCallback(handleEvent);
|
||||
sky.view.scheduleFrame();
|
||||
color = new ui.Color.fromARGB(255, 0, 255, 0);
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.setEventCallback(handleEvent);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
const kMaxIterations = 100;
|
||||
@@ -14,9 +14,9 @@ void report(String s) {
|
||||
// print("$s\n");
|
||||
}
|
||||
|
||||
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
|
||||
sky.Document document = new sky.Document();
|
||||
sky.Element root;
|
||||
ui.LayoutRoot layoutRoot = new ui.LayoutRoot();
|
||||
ui.Document document = new ui.Document();
|
||||
ui.Element root;
|
||||
math.Random random = new math.Random();
|
||||
|
||||
bool pickThis(double odds) {
|
||||
@@ -29,19 +29,19 @@ String generateCharacter(int min, int max) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String colorToCSSString(sky.Color color) {
|
||||
String colorToCSSString(ui.Color color) {
|
||||
return 'rgba(${color.red}, ${color.green}, ${color.blue}, ${color.alpha / 255.0})';
|
||||
}
|
||||
|
||||
void mutate(sky.Canvas canvas) {
|
||||
void mutate(ui.Canvas canvas) {
|
||||
// mutate the DOM randomly
|
||||
int iterationsLeft = kMaxIterations;
|
||||
sky.Node node = root;
|
||||
sky.Node other = null;
|
||||
ui.Node node = root;
|
||||
ui.Node other = null;
|
||||
while (node != null && iterationsLeft > 0) {
|
||||
iterationsLeft -= 1;
|
||||
if (node is sky.Element && pickThis(0.4)) {
|
||||
node = (node as sky.Element).firstChild;
|
||||
if (node is ui.Element && pickThis(0.4)) {
|
||||
node = (node as ui.Element).firstChild;
|
||||
} else if (node.nextSibling != null && pickThis(0.5)) {
|
||||
node = node.nextSibling;
|
||||
} else if (other == null && node != root && pickThis(0.1)) {
|
||||
@@ -57,7 +57,7 @@ void mutate(sky.Canvas canvas) {
|
||||
} else if (node != root && pickThis(0.001)) {
|
||||
report("remove()");
|
||||
node.remove();
|
||||
} else if (node is sky.Element) {
|
||||
} else if (node is ui.Element) {
|
||||
if (pickThis(0.1)) {
|
||||
report("appending a new text node (ASCII)");
|
||||
node.appendChild(document.createText(generateCharacter(0x20, 0x7F)));
|
||||
@@ -80,7 +80,7 @@ void mutate(sky.Canvas canvas) {
|
||||
break;
|
||||
} else if (pickThis(0.1)) {
|
||||
report("styling: color");
|
||||
node.style['color'] = colorToCSSString(new sky.Color(random.nextInt(0xFFFFFFFF) | 0xC0808080));
|
||||
node.style['color'] = colorToCSSString(new ui.Color(random.nextInt(0xFFFFFFFF) | 0xC0808080));
|
||||
break;
|
||||
} else if (pickThis(0.1)) {
|
||||
report("styling: font-size");
|
||||
@@ -148,12 +148,12 @@ void mutate(sky.Canvas canvas) {
|
||||
break;
|
||||
} else if (pickThis(0.1)) {
|
||||
report("styling: text-decoration-color");
|
||||
node.style['text-decoration-color'] = colorToCSSString(new sky.Color(random.nextInt(0xFFFFFFFF)));
|
||||
node.style['text-decoration-color'] = colorToCSSString(new ui.Color(random.nextInt(0xFFFFFFFF)));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
assert(node is sky.Text);
|
||||
final sky.Text text = node;
|
||||
assert(node is ui.Text);
|
||||
final ui.Text text = node;
|
||||
if (pickThis(0.1)) {
|
||||
report("appending a new text node (ASCII)");
|
||||
text.appendData(generateCharacter(0x20, 0x7F));
|
||||
@@ -182,8 +182,8 @@ void mutate(sky.Canvas canvas) {
|
||||
node = root;
|
||||
int count = 1;
|
||||
while (node != null) {
|
||||
if (node is sky.Element && node.firstChild != null) {
|
||||
node = (node as sky.Element).firstChild;
|
||||
if (node is ui.Element && node.firstChild != null) {
|
||||
node = (node as ui.Element).firstChild;
|
||||
count += 1;
|
||||
} else {
|
||||
while (node != null && node.nextSibling == null)
|
||||
@@ -202,40 +202,40 @@ void mutate(sky.Canvas canvas) {
|
||||
|
||||
// draw the result
|
||||
report("recording...");
|
||||
layoutRoot.maxWidth = sky.view.width;
|
||||
layoutRoot.maxWidth = ui.view.width;
|
||||
layoutRoot.layout();
|
||||
layoutRoot.paint(canvas);
|
||||
report("painting...");
|
||||
}
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
mutate(canvas);
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
sky.view.scheduleFrame();
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -243,6 +243,6 @@ void main() {
|
||||
root.style['display'] = 'paragraph';
|
||||
root.style['color'] = '#FFFFFF';
|
||||
layoutRoot.rootElement = root;
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -2,34 +2,34 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
sky.Size size = paintBounds.size;
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
ui.Size size = paintBounds.size;
|
||||
|
||||
sky.Paint paint = new sky.Paint();
|
||||
sky.Point mid = size.center(sky.Point.origin);
|
||||
ui.Paint paint = new ui.Paint();
|
||||
ui.Point mid = size.center(ui.Point.origin);
|
||||
double radius = size.shortestSide / 2.0;
|
||||
canvas.drawPaint(new sky.Paint()..color = const sky.Color(0xFFFFFFFF));
|
||||
canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF));
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(-mid.x/2.0, sky.view.height*2.0);
|
||||
canvas.translate(-mid.x/2.0, ui.view.height*2.0);
|
||||
canvas.clipRect(
|
||||
new sky.Rect.fromLTRB(0.0, -sky.view.height, sky.view.width, radius));
|
||||
new ui.Rect.fromLTRB(0.0, -ui.view.height, ui.view.width, radius));
|
||||
|
||||
canvas.translate(mid.x, mid.y);
|
||||
paint.color = const sky.Color.fromARGB(128, 255, 0, 255);
|
||||
paint.color = const ui.Color.fromARGB(128, 255, 0, 255);
|
||||
canvas.rotate(math.PI/4.0);
|
||||
|
||||
sky.Gradient yellowBlue = new sky.Gradient.linear(
|
||||
[new sky.Point(-radius, -radius), new sky.Point(0.0, 0.0)],
|
||||
[const sky.Color(0xFFFFFF00), const sky.Color(0xFF0000FF)]);
|
||||
canvas.drawRect(new sky.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||
new sky.Paint()..setShader(yellowBlue));
|
||||
ui.Gradient yellowBlue = new ui.Gradient.linear(
|
||||
[new ui.Point(-radius, -radius), new ui.Point(0.0, 0.0)],
|
||||
[const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)]);
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius),
|
||||
new ui.Paint()..setShader(yellowBlue));
|
||||
|
||||
// Scale x and y by 0.5.
|
||||
var scaleMatrix = new Float64List.fromList([
|
||||
@@ -39,70 +39,70 @@ sky.Picture paint(sky.Rect paintBounds) {
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
]);
|
||||
canvas.concat(scaleMatrix);
|
||||
paint.color = const sky.Color.fromARGB(128, 0, 255, 0);
|
||||
canvas.drawCircle(sky.Point.origin, radius, paint);
|
||||
paint.color = const ui.Color.fromARGB(128, 0, 255, 0);
|
||||
canvas.drawCircle(ui.Point.origin, radius, paint);
|
||||
|
||||
canvas.restore();
|
||||
|
||||
canvas.translate(0.0, 50.0);
|
||||
var builder = new sky.LayerDrawLooperBuilder()
|
||||
var builder = new ui.LayerDrawLooperBuilder()
|
||||
..addLayerOnTop(
|
||||
new sky.DrawLooperLayerInfo()
|
||||
..setOffset(const sky.Offset(150.0, 0.0))
|
||||
..setColorMode(sky.TransferMode.src)
|
||||
..setPaintBits(sky.PaintBits.all),
|
||||
new sky.Paint()
|
||||
..color = const sky.Color.fromARGB(128, 255, 255, 0)
|
||||
..colorFilter = new sky.ColorFilter.mode(
|
||||
const sky.Color.fromARGB(128, 0, 0, 255), sky.TransferMode.srcIn)
|
||||
..maskFilter = new sky.MaskFilter.blur(
|
||||
sky.BlurStyle.normal, 3.0, highQuality: true))
|
||||
new ui.DrawLooperLayerInfo()
|
||||
..setOffset(const ui.Offset(150.0, 0.0))
|
||||
..setColorMode(ui.TransferMode.src)
|
||||
..setPaintBits(ui.PaintBits.all),
|
||||
new ui.Paint()
|
||||
..color = const ui.Color.fromARGB(128, 255, 255, 0)
|
||||
..colorFilter = new ui.ColorFilter.mode(
|
||||
const ui.Color.fromARGB(128, 0, 0, 255), ui.TransferMode.srcIn)
|
||||
..maskFilter = new ui.MaskFilter.blur(
|
||||
ui.BlurStyle.normal, 3.0, highQuality: true))
|
||||
..addLayerOnTop(
|
||||
new sky.DrawLooperLayerInfo()
|
||||
..setOffset(const sky.Offset(75.0, 75.0))
|
||||
..setColorMode(sky.TransferMode.src)
|
||||
..setPaintBits(sky.PaintBits.shader),
|
||||
new sky.Paint()
|
||||
..shader = new sky.Gradient.radial(
|
||||
new sky.Point(0.0, 0.0), radius/3.0,
|
||||
[const sky.Color(0xFFFFFF00), const sky.Color(0xFFFF0000)],
|
||||
null, sky.TileMode.mirror)
|
||||
// Since we're don't set sky.PaintBits.maskFilter, this has no effect.
|
||||
..maskFilter = new sky.MaskFilter.blur(
|
||||
sky.BlurStyle.normal, 50.0, highQuality: true))
|
||||
new ui.DrawLooperLayerInfo()
|
||||
..setOffset(const ui.Offset(75.0, 75.0))
|
||||
..setColorMode(ui.TransferMode.src)
|
||||
..setPaintBits(ui.PaintBits.shader),
|
||||
new ui.Paint()
|
||||
..shader = new ui.Gradient.radial(
|
||||
new ui.Point(0.0, 0.0), radius/3.0,
|
||||
[const ui.Color(0xFFFFFF00), const ui.Color(0xFFFF0000)],
|
||||
null, ui.TileMode.mirror)
|
||||
// Since we're don't set ui.PaintBits.maskFilter, this has no effect.
|
||||
..maskFilter = new ui.MaskFilter.blur(
|
||||
ui.BlurStyle.normal, 50.0, highQuality: true))
|
||||
..addLayerOnTop(
|
||||
new sky.DrawLooperLayerInfo()..setOffset(const sky.Offset(225.0, 75.0)),
|
||||
new ui.DrawLooperLayerInfo()..setOffset(const ui.Offset(225.0, 75.0)),
|
||||
// Since this layer uses a DST color mode, this has no effect.
|
||||
new sky.Paint()..color = const sky.Color.fromARGB(128, 255, 0, 0));
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(128, 255, 0, 0));
|
||||
paint.drawLooper = builder.build();
|
||||
canvas.drawCircle(sky.Point.origin, radius, paint);
|
||||
canvas.drawCircle(ui.Point.origin, radius, paint);
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float32List deviceTransform = new Float32List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
}
|
||||
|
||||
void main() {
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -2,63 +2,63 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Picture paint(ui.Rect paintBounds) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
|
||||
double size = 100.0;
|
||||
canvas.translate(size + 10.0, size + 10.0);
|
||||
|
||||
sky.Paint paint = new sky.Paint();
|
||||
paint.color = const sky.Color.fromARGB(255, 0, 255, 0);
|
||||
var builder = new sky.LayerDrawLooperBuilder()
|
||||
ui.Paint paint = new ui.Paint();
|
||||
paint.color = const ui.Color.fromARGB(255, 0, 255, 0);
|
||||
var builder = new ui.LayerDrawLooperBuilder()
|
||||
// Shadow layer.
|
||||
..addLayerOnTop(
|
||||
new sky.DrawLooperLayerInfo()
|
||||
..setPaintBits(sky.PaintBits.all)
|
||||
..setOffset(const sky.Offset(5.0, 5.0))
|
||||
..setColorMode(sky.TransferMode.src),
|
||||
new sky.Paint()
|
||||
..color = const sky.Color.fromARGB(128, 55, 55, 55)
|
||||
..maskFilter = new sky.MaskFilter.blur(sky.BlurStyle.normal, 5.0)
|
||||
new ui.DrawLooperLayerInfo()
|
||||
..setPaintBits(ui.PaintBits.all)
|
||||
..setOffset(const ui.Offset(5.0, 5.0))
|
||||
..setColorMode(ui.TransferMode.src),
|
||||
new ui.Paint()
|
||||
..color = const ui.Color.fromARGB(128, 55, 55, 55)
|
||||
..maskFilter = new ui.MaskFilter.blur(ui.BlurStyle.normal, 5.0)
|
||||
)
|
||||
// Main layer.
|
||||
..addLayerOnTop(new sky.DrawLooperLayerInfo(), new sky.Paint());
|
||||
..addLayerOnTop(new ui.DrawLooperLayerInfo(), new ui.Paint());
|
||||
paint.drawLooper = builder.build();
|
||||
|
||||
canvas.drawPaint(
|
||||
new sky.Paint()..color = const sky.Color.fromARGB(255, 255, 255, 255));
|
||||
canvas.drawRect(new sky.Rect.fromLTRB(-size, -size, size, size), paint);
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 255, 255, 255));
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-size, -size, size, size), paint);
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
}
|
||||
|
||||
void main() {
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
double timeBase = null;
|
||||
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
|
||||
ui.LayoutRoot layoutRoot = new ui.LayoutRoot();
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds, double delta) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Picture paint(ui.Rect paintBounds, double delta) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
|
||||
canvas.translate(sky.view.width / 2.0, sky.view.height / 2.0);
|
||||
canvas.translate(ui.view.width / 2.0, ui.view.height / 2.0);
|
||||
canvas.rotate(math.PI * delta / 1800);
|
||||
canvas.drawRect(new sky.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0));
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
|
||||
double sin = math.sin(delta / 200);
|
||||
layoutRoot.maxWidth = 150.0 + (50 * sin);
|
||||
@@ -28,17 +28,17 @@ sky.Picture paint(sky.Rect paintBounds, double delta) {
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
@@ -47,15 +47,15 @@ void beginFrame(double timeStamp) {
|
||||
if (timeBase == null)
|
||||
timeBase = timeStamp;
|
||||
double delta = timeStamp - timeBase;
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds, delta);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
sky.view.scheduleFrame();
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds, delta);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
void main() {
|
||||
var document = new sky.Document();
|
||||
var document = new ui.Document();
|
||||
var arabic = document.createText("هذا هو قليلا طويلة من النص الذي يجب التفاف .");
|
||||
var more = document.createText(" و أكثر قليلا لجعله أطول. ");
|
||||
var block = document.createElement('p');
|
||||
@@ -68,6 +68,6 @@ void main() {
|
||||
|
||||
layoutRoot.rootElement = block;
|
||||
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -3,29 +3,29 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
double timeBase = null;
|
||||
|
||||
sky.Image image = null;
|
||||
ui.Image image = null;
|
||||
String url1 = "https://raw.githubusercontent.com/dart-lang/logos/master/logos_and_wordmarks/dart-logo.png";
|
||||
String url2 = "http://i2.kym-cdn.com/photos/images/facebook/000/581/296/c09.jpg";
|
||||
|
||||
sky.Picture paint(sky.Rect paintBounds, double delta) {
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Picture paint(ui.Rect paintBounds, double delta) {
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
|
||||
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
||||
canvas.rotate(math.PI * delta / 1800);
|
||||
canvas.scale(0.2, 0.2);
|
||||
sky.Paint paint = new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0);
|
||||
ui.Paint paint = new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0);
|
||||
|
||||
// Draw image
|
||||
if (image != null)
|
||||
canvas.drawImage(image, new sky.Point(-image.width / 2.0, -image.height / 2.0), paint);
|
||||
canvas.drawImage(image, new ui.Point(-image.width / 2.0, -image.height / 2.0), paint);
|
||||
|
||||
// Draw cut out of image
|
||||
canvas.rotate(math.PI * delta / 1800);
|
||||
@@ -33,25 +33,25 @@ sky.Picture paint(sky.Rect paintBounds, double delta) {
|
||||
var w = image.width.toDouble();
|
||||
var h = image.width.toDouble();
|
||||
canvas.drawImageRect(image,
|
||||
new sky.Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
|
||||
new sky.Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
|
||||
new ui.Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
|
||||
new ui.Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
|
||||
paint);
|
||||
}
|
||||
|
||||
return recorder.endRecording();
|
||||
}
|
||||
|
||||
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) {
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
return sceneBuilder.build();
|
||||
}
|
||||
@@ -60,11 +60,11 @@ void beginFrame(double timeStamp) {
|
||||
if (timeBase == null)
|
||||
timeBase = timeStamp;
|
||||
double delta = timeStamp - timeBase;
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.Picture picture = paint(paintBounds, delta);
|
||||
sky.Scene scene = composite(picture, paintBounds);
|
||||
sky.view.scene = scene;
|
||||
sky.view.scheduleFrame();
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.Picture picture = paint(paintBounds, delta);
|
||||
ui.Scene scene = composite(picture, paintBounds);
|
||||
ui.view.scene = scene;
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ void handleImageLoad(result) {
|
||||
if (result != image) {
|
||||
print("${result.width}x${result.width} image loaded!");
|
||||
image = result;
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.scheduleFrame();
|
||||
} else {
|
||||
print("Existing image was loaded again");
|
||||
}
|
||||
}
|
||||
|
||||
bool handleEvent(sky.Event event) {
|
||||
bool handleEvent(ui.Event event) {
|
||||
if (event.type == "pointerdown") {
|
||||
return true;
|
||||
}
|
||||
@@ -93,6 +93,6 @@ bool handleEvent(sky.Event event) {
|
||||
|
||||
void main() {
|
||||
imageCache.load(url1).first.then(handleImageLoad);
|
||||
sky.view.setEventCallback(handleEvent);
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
ui.view.setEventCallback(handleEvent);
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
}
|
||||
|
||||
@@ -3,46 +3,46 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:typed_data';
|
||||
|
||||
double timeBase = null;
|
||||
|
||||
void beginFrame(double timeStamp) {
|
||||
sky.tracing.begin('beginFrame');
|
||||
ui.tracing.begin('beginFrame');
|
||||
if (timeBase == null)
|
||||
timeBase = timeStamp;
|
||||
double delta = timeStamp - timeBase;
|
||||
|
||||
// paint
|
||||
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
|
||||
sky.PictureRecorder recorder = new sky.PictureRecorder();
|
||||
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
|
||||
ui.Rect paintBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width, ui.view.height);
|
||||
ui.PictureRecorder recorder = new ui.PictureRecorder();
|
||||
ui.Canvas canvas = new ui.Canvas(recorder, paintBounds);
|
||||
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
|
||||
canvas.rotate(math.PI * delta / 1800);
|
||||
canvas.drawRect(new sky.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0));
|
||||
sky.Picture picture = recorder.endRecording();
|
||||
canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
|
||||
new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0));
|
||||
ui.Picture picture = recorder.endRecording();
|
||||
|
||||
// composite
|
||||
final double devicePixelRatio = sky.view.devicePixelRatio;
|
||||
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
|
||||
final double devicePixelRatio = ui.view.devicePixelRatio;
|
||||
ui.Rect sceneBounds = new ui.Rect.fromLTWH(0.0, 0.0, ui.view.width * devicePixelRatio, ui.view.height * devicePixelRatio);
|
||||
Float64List deviceTransform = new Float64List(16)
|
||||
..[0] = devicePixelRatio
|
||||
..[5] = devicePixelRatio
|
||||
..[10] = 1.0
|
||||
..[15] = 1.0;
|
||||
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
|
||||
ui.SceneBuilder sceneBuilder = new ui.SceneBuilder(sceneBounds)
|
||||
..pushTransform(deviceTransform)
|
||||
..addPicture(sky.Offset.zero, picture, paintBounds)
|
||||
..addPicture(ui.Offset.zero, picture, paintBounds)
|
||||
..pop();
|
||||
sky.view.scene = sceneBuilder.build();
|
||||
ui.view.scene = sceneBuilder.build();
|
||||
|
||||
sky.tracing.end('beginFrame');
|
||||
sky.view.scheduleFrame();
|
||||
ui.tracing.end('beginFrame');
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
void main() {
|
||||
sky.view.setFrameCallback(beginFrame);
|
||||
sky.view.scheduleFrame();
|
||||
ui.view.setFrameCallback(beginFrame);
|
||||
ui.view.scheduleFrame();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -50,7 +50,7 @@ RenderBox getBox(double lh) {
|
||||
path.lineTo(w, h);
|
||||
Paint paint = new Paint();
|
||||
paint.color = const Color(0xFFFF9000);
|
||||
paint.setStyle(sky.PaintingStyle.stroke);
|
||||
paint.setStyle(ui.PaintingStyle.stroke);
|
||||
paint.strokeWidth = 3.0;
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -15,7 +15,7 @@ void main() {
|
||||
additionalConstraints: new BoxConstraints.tightFor(height: 100.0),
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: new sky.Color(0xFFFFFF00)
|
||||
backgroundColor: new ui.Color(0xFFFFFF00)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -27,12 +27,12 @@ void main() {
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
top: new BorderSide(color: new sky.Color(0xFFF00000), width: 5.0),
|
||||
right: new BorderSide(color: new sky.Color(0xFFFF9000), width: 10.0),
|
||||
bottom: new BorderSide(color: new sky.Color(0xFFFFF000), width: 15.0),
|
||||
left: new BorderSide(color: new sky.Color(0xFF00FF00), width: 20.0)
|
||||
top: new BorderSide(color: new ui.Color(0xFFF00000), width: 5.0),
|
||||
right: new BorderSide(color: new ui.Color(0xFFFF9000), width: 10.0),
|
||||
bottom: new BorderSide(color: new ui.Color(0xFFFFF000), width: 15.0),
|
||||
left: new BorderSide(color: new ui.Color(0xFF00FF00), width: 20.0)
|
||||
),
|
||||
backgroundColor: new sky.Color(0xFFDDDDDD)
|
||||
backgroundColor: new ui.Color(0xFFDDDDDD)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -43,7 +43,7 @@ void main() {
|
||||
additionalConstraints: new BoxConstraints.tightFor(height: 100.0),
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: new sky.Color(0xFFFFFF00)
|
||||
backgroundColor: new ui.Color(0xFFFFFF00)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
additionalConstraints: new BoxConstraints.tightFor(height: 100.0),
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: new sky.Color(0xFFFFFF00)
|
||||
backgroundColor: new ui.Color(0xFFFFFF00)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
additionalConstraints: new BoxConstraints.tightFor(height: 100.0),
|
||||
child: new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(
|
||||
backgroundColor: new sky.Color(0xFFFFFF00)
|
||||
backgroundColor: new ui.Color(0xFFFFFF00)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'solid_color_box.dart';
|
||||
@@ -11,24 +11,24 @@ RenderBox buildFlexExample() {
|
||||
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical);
|
||||
|
||||
RenderDecoratedBox root = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)),
|
||||
decoration: new BoxDecoration(backgroundColor: const ui.Color(0xFF000000)),
|
||||
child: flexRoot
|
||||
);
|
||||
|
||||
void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int flex: 0 }) {
|
||||
void addFlexChildSolidColor(RenderFlex parent, ui.Color backgroundColor, { int flex: 0 }) {
|
||||
RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
|
||||
parent.add(child);
|
||||
child.parentData.flex = flex;
|
||||
}
|
||||
|
||||
// Yellow bar at top
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFFFF00), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFFFFFF00), flex: 1);
|
||||
|
||||
// Turquoise box
|
||||
flexRoot.add(new RenderSolidColorBox(const sky.Color(0x7700FFFF), desiredSize: new sky.Size(100.0, 100.0)));
|
||||
flexRoot.add(new RenderSolidColorBox(const ui.Color(0x7700FFFF), desiredSize: new ui.Size(100.0, 100.0)));
|
||||
|
||||
var renderDecoratedBlock = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFFFF))
|
||||
decoration: new BoxDecoration(backgroundColor: const ui.Color(0xFFFFFFFF))
|
||||
);
|
||||
|
||||
flexRoot.add(new RenderPadding(padding: const EdgeDims.all(10.0), child: renderDecoratedBlock));
|
||||
@@ -36,11 +36,11 @@ RenderBox buildFlexExample() {
|
||||
var row = new RenderFlex(direction: FlexDirection.horizontal);
|
||||
|
||||
// Purple and blue cells
|
||||
addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1);
|
||||
addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2);
|
||||
addFlexChildSolidColor(row, const ui.Color(0x77FF00FF), flex: 1);
|
||||
addFlexChildSolidColor(row, const ui.Color(0xFF0000FF), flex: 2);
|
||||
|
||||
var decoratedRow = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)),
|
||||
decoration: new BoxDecoration(backgroundColor: const ui.Color(0xFF333333)),
|
||||
child: row
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -19,7 +19,7 @@ class Touch {
|
||||
class RenderImageGrow extends RenderImage {
|
||||
final Size _startingSize;
|
||||
|
||||
RenderImageGrow(sky.Image image, Size size)
|
||||
RenderImageGrow(ui.Image image, Size size)
|
||||
: _startingSize = size, super(image: image, width: size.width, height: size.height);
|
||||
|
||||
double _growth = 0.0;
|
||||
@@ -35,7 +35,7 @@ RenderImageGrow image;
|
||||
|
||||
Map<int, Touch> touches = new Map();
|
||||
void handleEvent(event) {
|
||||
if (event is sky.PointerEvent) {
|
||||
if (event is ui.PointerEvent) {
|
||||
if (event.type == 'pointermove')
|
||||
image.growth = math.max(0.0, image.growth + event.x - touches[event.pointer].x);
|
||||
touches[event.pointer] = new Touch(event.x, event.y);
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
|
||||
// Resizeable image
|
||||
image = new RenderImageGrow(null, new Size(100.0, null));
|
||||
imageCache.load("https://www.dartlang.org/logos/dart-logo.png").first.then((sky.Image dartLogo) {
|
||||
imageCache.load("https://www.dartlang.org/logos/dart-logo.png").first.then((ui.Image dartLogo) {
|
||||
image.image = dartLogo;
|
||||
});
|
||||
|
||||
@@ -99,5 +99,5 @@ Pancetta meatball tongue tenderloin rump tail jowl boudin.""";
|
||||
|
||||
updateTaskDescription('Interactive Flex', topColor);
|
||||
new FlutterBinding(root: root);
|
||||
sky.view.setEventCallback(handleEvent);
|
||||
ui.view.setEventCallback(handleEvent);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -528,7 +528,7 @@ class RenderSolidColor extends RenderDecoratedSector {
|
||||
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
|
||||
}
|
||||
|
||||
void handleEvent(sky.Event event, HitTestEntry entry) {
|
||||
void handleEvent(ui.Event event, HitTestEntry entry) {
|
||||
if (event.type == 'pointerdown')
|
||||
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
|
||||
else if (event.type == 'pointerup')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -42,7 +42,7 @@ class RenderSolidColorBox extends RenderDecoratedBox {
|
||||
size = constraints.constrain(desiredSize);
|
||||
}
|
||||
|
||||
void handleEvent(sky.Event event, BoxHitTestEntry entry) {
|
||||
void handleEvent(ui.Event event, BoxHitTestEntry entry) {
|
||||
if (event.type == 'pointerdown')
|
||||
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));
|
||||
else if (event.type == 'pointerup')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -15,15 +15,15 @@ RenderTransform transformBox;
|
||||
void main() {
|
||||
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical);
|
||||
|
||||
void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int flex: 0 }) {
|
||||
void addFlexChildSolidColor(RenderFlex parent, ui.Color backgroundColor, { int flex: 0 }) {
|
||||
RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
|
||||
parent.add(child);
|
||||
child.parentData.flex = flex;
|
||||
}
|
||||
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFFFF00), flex: 2);
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFF00FFFF), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFFFF00FF), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFFFFFF00), flex: 2);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFF00FFFF), flex: 1);
|
||||
|
||||
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity());
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -24,7 +24,7 @@ class Dot {
|
||||
|
||||
Dot({ Color color }) : _paint = new Paint()..color = color;
|
||||
|
||||
void update(sky.PointerEvent event) {
|
||||
void update(ui.PointerEvent event) {
|
||||
position = new Point(event.x, event.y);
|
||||
radius = 5 + (95 * event.pressure);
|
||||
}
|
||||
@@ -39,8 +39,8 @@ class RenderTouchDemo extends RenderBox {
|
||||
|
||||
RenderTouchDemo();
|
||||
|
||||
void handleEvent(sky.Event event, BoxHitTestEntry entry) {
|
||||
if (event is sky.PointerEvent) {
|
||||
void handleEvent(ui.Event event, BoxHitTestEntry entry) {
|
||||
if (event is ui.PointerEvent) {
|
||||
switch (event.type) {
|
||||
case 'pointerdown':
|
||||
Color color = kColors[event.pointer.remainder(kColors.length)];
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
void main() {
|
||||
RenderDecoratedBox green = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00))
|
||||
decoration: new BoxDecoration(backgroundColor: const ui.Color(0xFF00FF00))
|
||||
);
|
||||
RenderConstrainedBox box = new RenderConstrainedBox(
|
||||
additionalConstraints: new BoxConstraints.tight(const sky.Size(200.0, 200.0)),
|
||||
additionalConstraints: new BoxConstraints.tight(const ui.Size(200.0, 200.0)),
|
||||
child: green
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ library stocks;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -25,7 +25,7 @@ class StockArrow extends StatelessComponent {
|
||||
// TODO(jackson): This should change colors with the theme
|
||||
Color color = _colorForPercentChange(percentChange);
|
||||
const double kSize = 40.0;
|
||||
var arrow = new CustomPaint(callback: (sky.Canvas canvas, Size size) {
|
||||
var arrow = new CustomPaint(callback: (ui.Canvas canvas, Size size) {
|
||||
Paint paint = new Paint()..color = color;
|
||||
paint.strokeWidth = 1.0;
|
||||
const double padding = 2.0;
|
||||
@@ -49,11 +49,11 @@ class StockArrow extends StatelessComponent {
|
||||
path.lineTo(centerX + w, arrowY + h);
|
||||
path.lineTo(centerX - w, arrowY + h);
|
||||
path.close();
|
||||
paint.setStyle(sky.PaintingStyle.fill);
|
||||
paint.setStyle(ui.PaintingStyle.fill);
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
// Draw a circle that circumscribes the arrow.
|
||||
paint.setStyle(sky.PaintingStyle.stroke);
|
||||
paint.setStyle(ui.PaintingStyle.stroke);
|
||||
canvas.drawCircle(new Point(centerX, centerY), r, paint);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ Future showStockMenu(NavigatorState navigator, { bool autorefresh, ValueChanged
|
||||
switch (await showMenu(
|
||||
navigator: navigator,
|
||||
position: new MenuPosition(
|
||||
right: sky.view.paddingRight + _kMenuMargin,
|
||||
top: sky.view.paddingTop + _kMenuMargin
|
||||
right: ui.view.paddingRight + _kMenuMargin,
|
||||
top: ui.view.paddingTop + _kMenuMargin
|
||||
),
|
||||
builder: (NavigatorState navigator) {
|
||||
return <PopupMenuItem>[
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
@@ -299,7 +299,7 @@ class CardCollectionState extends State<CardCollection> {
|
||||
});
|
||||
}
|
||||
|
||||
sky.Shader _createShader(Rect bounds) {
|
||||
ui.Shader _createShader(Rect bounds) {
|
||||
return new LinearGradient(
|
||||
begin: Point.origin,
|
||||
end: new Point(0.0, bounds.height),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
@@ -31,14 +31,14 @@ class Marker extends StatelessComponent {
|
||||
final double size;
|
||||
final MarkerType type;
|
||||
|
||||
void paintMarker(sky.Canvas canvas, _) {
|
||||
void paintMarker(ui.Canvas canvas, _) {
|
||||
Paint paint = new Paint()..color = const Color(0x8000FF00);
|
||||
paint.setStyle(sky.PaintingStyle.fill);
|
||||
paint.setStyle(ui.PaintingStyle.fill);
|
||||
double r = size / 2.0;
|
||||
canvas.drawCircle(new Point(r, r), r, paint);
|
||||
|
||||
paint.color = const Color(0xFFFFFFFF);
|
||||
paint.setStyle(sky.PaintingStyle.stroke);
|
||||
paint.setStyle(ui.PaintingStyle.stroke);
|
||||
paint.strokeWidth = 1.0;
|
||||
if (type == MarkerType.topLeft) {
|
||||
canvas.drawLine(new Point(r, r), new Point(r + r - 1.0, r), paint);
|
||||
@@ -103,7 +103,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
|
||||
});
|
||||
}
|
||||
|
||||
void handlePointerDown(GlobalKey target, sky.PointerEvent event) {
|
||||
void handlePointerDown(GlobalKey target, ui.PointerEvent event) {
|
||||
setState(() {
|
||||
markers[MarkerType.touch] = new Point(event.x, event.y);
|
||||
final RenderBox box = target.currentContext.findRenderObject();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:ui' as sky;
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,7 +11,7 @@ import 'package:flutter/rendering.dart';
|
||||
import '../rendering/solid_color_box.dart';
|
||||
|
||||
// Solid colour, RenderObject version
|
||||
void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int flex: 0 }) {
|
||||
void addFlexChildSolidColor(RenderFlex parent, ui.Color backgroundColor, { int flex: 0 }) {
|
||||
RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor);
|
||||
parent.add(child);
|
||||
child.parentData.flex = flex;
|
||||
@@ -81,9 +81,9 @@ void main() {
|
||||
new RenderBoxToWidgetAdapter(proxy, builder); // adds itself to proxy
|
||||
|
||||
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical);
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFFFF00FF), flex: 1);
|
||||
flexRoot.add(proxy);
|
||||
addFlexChildSolidColor(flexRoot, const sky.Color(0xFF0000FF), flex: 1);
|
||||
addFlexChildSolidColor(flexRoot, const ui.Color(0xFF0000FF), flex: 1);
|
||||
|
||||
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity());
|
||||
RenderPadding root = new RenderPadding(padding: new EdgeDims.all(80.0), child: transformBox);
|
||||
|
||||
Reference in New Issue
Block a user