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

Side by Side Diff: samples/stm32f746g-discovery/turtle-graphics/turtle.dart

Issue 1996533003: Change framebuffer.clear to use background color (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Review feedback Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « samples/stm32f746g-discovery/touch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 // 4 //
5 // This sample was inspired by the Dart Hilbert curve sample: 5 // This sample was inspired by the Dart Hilbert curve sample:
6 // https://github.com/daftspaniel/dart-Hilbertcurve/blob/master/web/turtle.dart 6 // https://github.com/daftspaniel/dart-Hilbertcurve/blob/master/web/turtle.dart
7 7
8 library turtle; 8 library turtle;
9 9
10 import "dart:math"; 10 import "dart:math";
11 11
12 import 'package:stm32/lcd.dart'; 12 import 'package:stm32/lcd.dart';
13 13
14 class Turtle { 14 class Turtle {
15 FrameBuffer _display; 15 FrameBuffer _display;
16 int _x; 16 int _x;
17 int _y; 17 int _y;
18 int _direction = 90; 18 int _direction = 90;
19 Color penColor = Color.red; 19 Color penColor = Color.red;
20 20
21 /// Create a new Turtle, and set initial location. 21 /// Create a new Turtle, and set initial location.
22 Turtle(this._display, {xPosition: 0, yPosition: 0}) { 22 Turtle(this._display, {xPosition: 0, yPosition: 0}) {
23 _display.backgroundColor = Color.black;
23 _display.clear(); 24 _display.clear();
24 _x = xPosition; 25 _x = xPosition;
25 _y = yPosition; 26 _y = yPosition;
26 } 27 }
27 28
28 /// Move forward [distance] pixels in the current direction with the pen down. 29 /// Move forward [distance] pixels in the current direction with the pen down.
29 forward(int distance) { 30 forward(int distance) {
30 double r = _direction * (PI / 180.0); 31 double r = _direction * (PI / 180.0);
31 int dx = (distance * sin(r)).toInt(); 32 int dx = (distance * sin(r)).toInt();
32 int dy = (distance * cos(r)).toInt(); 33 int dy = (distance * cos(r)).toInt();
(...skipping 19 matching lines...) Expand all
52 turnRight(int degrees) { 53 turnRight(int degrees) {
53 _turn(-degrees); 54 _turn(-degrees);
54 } 55 }
55 56
56 /// Move to [x, y] with the pen up. 57 /// Move to [x, y] with the pen up.
57 flyTo(int x, int y) { 58 flyTo(int x, int y) {
58 this._x = x; 59 this._x = x;
59 this._y = y; 60 this._y = y;
60 } 61 }
61 } 62 }
OLDNEW
« no previous file with comments | « samples/stm32f746g-discovery/touch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698