EdgeDims changes and other fixes to core classes.

- Rename EdgeDims constructor to EdgeDims.TRBL().

- Add operator== to Size and Offset so that you can compare Size to
  DebugSize in checked mode.

- Add Size.lerp().

- Add various operators to EdgeDims. (*, /, ~/, %)

- Add EdgeDims.lerp().

- Update style guide. I went there to fix an EdgeDims constructor
  example, and stayed because some recent things came up and I wanted to
  add them before I forgot.
This commit is contained in:
Hixie
2015-10-01 15:11:30 -07:00
parent 4ebf26bfaa
commit ce2c56b35c
6 changed files with 112 additions and 26 deletions

View File

@@ -0,0 +1,14 @@
import 'package:sky/painting.dart';
import 'package:test/test.dart';
void main() {
test("EdgeDims.lerp()", () {
EdgeDims a = new EdgeDims.all(10.0);
EdgeDims b = new EdgeDims.all(20.0);
expect(EdgeDims.lerp(a, b, 0.25), equals(a * 1.25));
expect(EdgeDims.lerp(a, b, 0.25), equals(b * 0.625));
expect(EdgeDims.lerp(a, b, 0.25), equals(a + const EdgeDims.all(2.5)));
expect(EdgeDims.lerp(a, b, 0.25), equals(b - const EdgeDims.all(7.5)));
});
}

View File

@@ -0,0 +1,18 @@
import 'package:sky/rendering.dart';
import 'package:test/test.dart';
import 'rendering_tester.dart';
void main() {
test('Stack can layout with top, right, bottom, left 0.0', () {
RenderBox box = new RenderConstrainedBox(
additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)));
layout(box, constraints: const BoxConstraints());
expect(box.size.width, equals(100.0));
expect(box.size.height, equals(100.0));
expect(box.size, equals(const Size(100.0, 100.0)));
expect(box.size.runtimeType.toString(), equals('_DebugSize'));
});
}