mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Also, introduce Colors and Typography to hold the material colors and the typography declarations. Previously we expected clients of these libraries to import them into a namespace, but that doesn't play nice with re-exporting them from material.dart.
84 lines
1.7 KiB
Dart
84 lines
1.7 KiB
Dart
import 'dart:sky';
|
|
|
|
import 'package:sky/material.dart';
|
|
import 'package:sky/rendering.dart';
|
|
import 'package:sky/services.dart';
|
|
import 'package:sky/widgets.dart';
|
|
import 'package:skysprites/skysprites.dart';
|
|
|
|
AssetBundle _initBundle() {
|
|
if (rootBundle != null)
|
|
return rootBundle;
|
|
return new NetworkAssetBundle(Uri.base);
|
|
}
|
|
|
|
final AssetBundle _bundle = _initBundle();
|
|
|
|
ImageMap _images;
|
|
SpriteSheet _spriteSheet;
|
|
TestDrawAtlasApp _app;
|
|
|
|
main() async {
|
|
_images = new ImageMap(_bundle);
|
|
|
|
await _images.load([
|
|
'assets/sprites.png'
|
|
]);
|
|
|
|
String json = await _bundle.loadString('assets/sprites.json');
|
|
_spriteSheet = new SpriteSheet(_images['assets/sprites.png'], json);
|
|
|
|
_app = new TestDrawAtlasApp();
|
|
runApp(_app);
|
|
}
|
|
|
|
class TestDrawAtlasApp extends App {
|
|
|
|
Widget build() {
|
|
ThemeData theme = new ThemeData(
|
|
brightness: ThemeBrightness.light,
|
|
primarySwatch: Colors.purple
|
|
);
|
|
|
|
return new Theme(
|
|
data: theme,
|
|
child: new Title(
|
|
title: 'Test drawAtlas',
|
|
child: new SpriteWidget(
|
|
new TestDrawAtlas(),
|
|
SpriteBoxTransformMode.fixedWidth
|
|
)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
class TestDrawAtlas extends NodeWithSize {
|
|
TestDrawAtlas() : super(new Size(1024.0, 1024.0)) {
|
|
}
|
|
|
|
void paint(PaintingCanvas canvas) {
|
|
List<RSTransform> transforms = [
|
|
new RSTransform(1.0, 0.0, 100.0, 100.0)
|
|
];
|
|
List<Rect> rects = [
|
|
_spriteSheet["ship.png"].frame
|
|
];
|
|
List<Color> colors = [
|
|
new Color(0xffffffff)
|
|
];
|
|
|
|
canvas.drawAtlas(
|
|
_spriteSheet.image,
|
|
transforms,
|
|
rects,
|
|
colors,
|
|
TransferMode.src,
|
|
null,
|
|
new Paint()
|
|
..filterQuality = FilterQuality.low
|
|
..isAntiAlias = false
|
|
);
|
|
}
|
|
}
|