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

Side by Side Diff: sky/sdk/example/game/lib/game_demo_world.dart

Issue 1217933002: Rename RenderCanvas to PaintingCanvas to avoid confusion with other classes that inherit from Rende… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | sky/sdk/example/game/lib/node.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 part of game; 1 part of game;
2 2
3 const double _steeringThreshold = 0.0; 3 const double _steeringThreshold = 0.0;
4 const double _steeringMax = 150.0; 4 const double _steeringMax = 150.0;
5 5
6 // Random generator 6 // Random generator
7 Math.Random _rand = new Math.Random(); 7 Math.Random _rand = new Math.Random();
8 8
9 const double _gameSizeWidth = 1024.0; 9 const double _gameSizeWidth = 1024.0;
10 const double _gameSizeHeight = 1024.0; 10 const double _gameSizeHeight = 1024.0;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 _starScales = []; 365 _starScales = [];
366 _opacity = []; 366 _opacity = [];
367 367
368 for (int i = 0; i < _numStars; i++) { 368 for (int i = 0; i < _numStars; i++) {
369 _starPositions.add(new Point(_rand.nextDouble() * _gameSizeWidth, _rand.ne xtDouble() * _gameSizeHeight)); 369 _starPositions.add(new Point(_rand.nextDouble() * _gameSizeWidth, _rand.ne xtDouble() * _gameSizeHeight));
370 _starScales.add(_rand.nextDouble()); 370 _starScales.add(_rand.nextDouble());
371 _opacity.add(_rand.nextDouble() * 0.5 + 0.5); 371 _opacity.add(_rand.nextDouble() * 0.5 + 0.5);
372 } 372 }
373 } 373 }
374 374
375 void paint(RenderCanvas canvas) { 375 void paint(PaintingCanvas canvas) {
376 // Setup paint object for opacity and transfer mode 376 // Setup paint object for opacity and transfer mode
377 Paint paint = new Paint(); 377 Paint paint = new Paint();
378 paint.setTransferMode(TransferMode.plus); 378 paint.setTransferMode(TransferMode.plus);
379 379
380 double baseScaleX = 32.0 / _img.size.width; 380 double baseScaleX = 32.0 / _img.size.width;
381 double baseScaleY = 32.0 / _img.size.height; 381 double baseScaleY = 32.0 / _img.size.height;
382 382
383 // Draw each star 383 // Draw each star
384 for (int i = 0; i < _numStars; i++) { 384 for (int i = 0; i < _numStars; i++) {
385 Point pos = _starPositions[i]; 385 Point pos = _starPositions[i];
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 double dy = a.y - b.y; 454 double dy = a.y - b.y;
455 if (dx < 0.0) dx = -dx; 455 if (dx < 0.0) dx = -dx;
456 if (dy < 0.0) dy = -dy; 456 if (dy < 0.0) dy = -dy;
457 if (dx > dy) { 457 if (dx > dy) {
458 return dx + dy/2.0; 458 return dx + dy/2.0;
459 } 459 }
460 else { 460 else {
461 return dy + dx/2.0; 461 return dy + dx/2.0;
462 } 462 }
463 } 463 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/example/game/lib/node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698