Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: sky/examples/raw/ink_well.dart

Issue 1172033003: Add a basic InkWell implementation (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rm examples/raw/ink_well.dart Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/sdk/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/raw/ink_well.dart
diff --git a/sky/examples/raw/ink_well.dart b/sky/examples/raw/ink_well.dart
deleted file mode 100644
index b2a104cd45b4e25a69d75843bb55bea94fdc43db..0000000000000000000000000000000000000000
--- a/sky/examples/raw/ink_well.dart
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:sky' as sky;
-import 'package:sky/framework/app.dart';
-import 'package:sky/framework/rendering/box.dart';
-import 'package:sky/framework/rendering/object.dart';
-import 'package:sky/framework/animation/animated_value.dart';
-import 'package:sky/framework/animation/curves.dart';
-
-const double _kInitialSize = 0.0;
-const double _kTargetSize = 100.0;
-const double _kSplashDuration = 500.0;
-const int _kInitialOpacity = 0x80;
-
-class InkSplash {
- final InkWell inkWell;
- final sky.Paint _paint = new sky.Paint();
- final sky.Point position;
- AnimatedValue radius;
-
- InkSplash({ this.position, this.inkWell }) {
- radius = new AnimatedValue(_kInitialSize, onChange: _handleRadiusChange);
- radius.animateTo(_kTargetSize, _kSplashDuration, curve: easeOut);
- }
-
- void _handleRadiusChange() {
- if (radius.value == _kTargetSize)
- inkWell._splashes.remove(this);
- inkWell.markNeedsPaint();
- }
-
- void paint(RenderObjectDisplayList canvas) {
- int opacity = (_kInitialOpacity * (1.0 - (radius.value / _kTargetSize))).floor();
- _paint.color = new sky.Color(opacity << 24);
- canvas.drawCircle(position.x, position.y, radius.value, _paint);
- }
-}
-
-class InkWell extends RenderBox {
- final List<InkSplash> _splashes = new List<InkSplash>();
-
- void handleEvent(sky.Event event) {
- switch (event.type) {
- case 'pointerdown':
- _splashes.add(new InkSplash(position: new sky.Point(event.x, event.y),
- inkWell: this));
- break;
- }
- markNeedsPaint();
- }
-
- void performLayout() {
- size = constraints.constrain(sky.Size.infinite);
- }
-
- void paint(RenderObjectDisplayList canvas) {
- canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, size.width, size.height),
- new sky.Paint()..color = const sky.Color(0xFFCCCCCC));
- for (InkSplash splash in _splashes)
- splash.paint(canvas);
- }
-}
-
-AppView app;
-
-void main() {
- app = new AppView(new InkWell());
-}
« no previous file with comments | « no previous file | sky/sdk/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698