Import dart:ui as ui (instead of as sky)

This commit is contained in:
Adam Barth
2015-10-09 20:55:54 -07:00
parent 65eba90843
commit ecce1eb389
100 changed files with 737 additions and 737 deletions

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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();
}