開発環境
- OS X Mavericks - Apple (OS)
 - Dart Editor (開発環境)
 - Dartium | Dart/ Structured web apps (ブラウザ, Dart VM 用 (Chromium with the Dart VM))
 - Safari (ブラウザ, JavaScript 用)
 - Dart (プログラミング言語)
 
Head First Java 第2版 ―頭とからだで覚えるJavaの基本(Kathy Sierra (著)、Bert Bates (著)、島田 秋雄 (監修)、神戸 博之 (監修)、高坂 一城 (監修)、夏目 大 (翻訳)、オライリージャパン)の12章(GUIの基礎)、自分で考えてみよう(p.383))をDartで考えてみる。
その他参考書籍
- What is Dart? [Kindle版] (O'Reilly Media) Kathy Walrath Seth Ladd (著) このブログでの感想
 
自分で考えてみよう(p.383)
コード
sample.dart
import 'dart:html';
import 'dart:math' as math;
import 'dart:async' as async;
void main() {
  div.style
      ..width = '650px'
      ..height = '650px'
      ..border = 'solid';
  canvas
      ..width = 650
      ..height = 650;
  div.append(canvas);
  animation_start.onClick.listen((MouseEvent event) {
    ctx..fillStyle = 'white'
        ..strokeStyle = 'white'
        ..rect(0, 0, 650, 650)
        ..fill();
    x = 50;
    y = 50;
    draw();
  });
}
DivElement div = querySelector('#d0');
ButtonElement animation_start = querySelector('#animation_start');
CanvasElement canvas = new CanvasElement();
CanvasRenderingContext2D ctx = canvas.context2D;
int x;
int y;
void draw() {
  if (x < 600) {
    ctx
        ..rect(x - 26, y - 26, 50, 50)
        ..fillStyle = 'white'
        ..strokeStyle = 'white'
        ..fill()
        ..beginPath()
        ..arc(x, y, 25, 0, 2 * math.PI)
        ..fillStyle = 'red'
        ..strokeStyle = 'red'
        ..fill();
    div.innerHtml = '';
    div.append(canvas);
  } else {
    return;
  }
  x += 1;
  y += 1;
  async.Timer t = new async.Timer(new Duration(milliseconds: 10), draw);
}
  
    
						
0 コメント:
コメントを投稿