Permalink
Browse files

switch to new dart2js compiler.

  • Loading branch information...
1 parent 33c1377 commit aef675d4a9e264839f742b05e9b5df1ee46426ad @akrennmair committed May 10, 2012
Showing with 49 additions and 52 deletions.
  1. +1 −1 Makefile
  2. +37 −38 bb_master.dart
  3. +11 −13 bb_slave.dart
View
@@ -6,7 +6,7 @@ GOSRC=$(wildcard *.go)
all: $(JS_SRC) $(GOBIN)
%.dart.js: %.dart
- $$DART_SDK/bin/frogc --enable-type-checks $< || ( $(RM) $@ && exit 1 )
+ $$DART_SDK/bin/dart2js --out=$@ $< || ( $(RM) $@ && exit 1 )
$(GOBIN): $(GOSRC)
go build -o $@
View
@@ -2,52 +2,51 @@
#import('dart:json');
void main() {
- window.on.contentLoaded.add( (e) {
- bool mouseDown = false;
- CanvasElement canvas = document.query('#bb');
- CanvasRenderingContext2D ctx = canvas.getContext("2d");
- List<int> coords;
- int left_offset, top_offset;
+ print("entered main");
+ bool mouseDown = false;
+ CanvasElement canvas = document.query('#bb');
+ CanvasRenderingContext2D ctx = canvas.getContext("2d");
+ List<int> coords;
+ int left_offset, top_offset;
- Future<ElementRect> f = canvas.rect; f.then((ElementRect rect) {
- left_offset = rect.offset.left;
- top_offset = rect.offset.top;
- });
+ Future<ElementRect> f = canvas.rect; f.then((ElementRect rect) {
+ left_offset = rect.offset.left;
+ top_offset = rect.offset.top;
+ });
- canvas.on.mouseDown.add( (MouseEvent e) {
- mouseDown = true;
- ctx.beginPath();
- coords = [];
+ canvas.on.mouseDown.add( (MouseEvent e) {
+ mouseDown = true;
+ ctx.beginPath();
+ coords = [];
+ int x = e.clientX - left_offset;
+ int y = e.clientY - top_offset;
+ coords.add(x);
+ coords.add(y);
+ print("mouseDown = true x = ${x} y = ${y}");
+ ctx.moveTo(x, y);
+ });
+
+ canvas.on.mouseMove.add( (MouseEvent e) {
+ if (mouseDown) {
int x = e.clientX - left_offset;
int y = e.clientY - top_offset;
+ ctx.lineTo(x, y);
coords.add(x);
coords.add(y);
- print("mouseDown = true x = ${x} y = ${y}");
- ctx.moveTo(x, y);
- });
-
- canvas.on.mouseMove.add( (MouseEvent e) {
- if (mouseDown) {
- int x = e.clientX - left_offset;
- int y = e.clientY - top_offset;
- ctx.lineTo(x, y);
- coords.add(x);
- coords.add(y);
- ctx.stroke();
- print("stroke x = ${x} y = ${y}");
- }
- });
+ ctx.stroke();
+ print("stroke x = ${x} y = ${y}");
+ }
+ });
- WebSocket ws_send = new WebSocket("ws://" + window.location.host + "/senddata");
+ WebSocket ws_send = new WebSocket("ws://" + window.location.host + "/senddata");
- canvas.on.mouseUp.add( (MouseEvent e) {
- if (mouseDown) {
- mouseDown = false;
- print("mouseDown = false");
- ws_send.send(JSON.stringify(coords));
- coords = [];
- }
- });
+ canvas.on.mouseUp.add( (MouseEvent e) {
+ if (mouseDown) {
+ mouseDown = false;
+ print("mouseDown = false");
+ ws_send.send(JSON.stringify(coords));
+ coords = [];
+ }
});
}
View
@@ -2,20 +2,18 @@
#import('dart:json');
void main() {
- window.on.contentLoaded.add( (e) {
- CanvasElement canvas = document.query('#bb');
- CanvasRenderingContext2D ctx = canvas.getContext("2d");
+ CanvasElement canvas = document.query('#bb');
+ CanvasRenderingContext2D ctx = canvas.getContext("2d");
- WebSocket ws_recv = new WebSocket("ws://" + window.location.host + "/recvdata");
- ws_recv.on.message.add((event) {
- print("received data: ${event.data}");
- List<int> coords = JSON.parse(event.data);
- ctx.beginPath();
- for (int i=0;i<coords.length;i+=2) {
- ctx.lineTo(coords[i], coords[i+1]);
- }
- ctx.stroke();
- });
+ WebSocket ws_recv = new WebSocket("ws://" + window.location.host + "/recvdata");
+ ws_recv.on.message.add((event) {
+ print("received data: ${event.data}");
+ List<int> coords = JSON.parse(event.data);
+ ctx.beginPath();
+ for (int i=0;i<coords.length;i+=2) {
+ ctx.lineTo(coords[i], coords[i+1]);
+ }
+ ctx.stroke();
});
}

0 comments on commit aef675d

Please sign in to comment.