Last active
August 29, 2015 14:22
-
-
Save zakki/6ddbe1ab03f4e4f94164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 51f165b05a354ea047aca4436c191c2008d5058d Mon Sep 17 00:00:00 2001 | |
From: MATSUZAKI Kensuke <[email protected]> | |
Date: Fri, 12 Jun 2015 17:39:11 +0900 | |
Subject: [PATCH] Fix drawing | |
--- | |
Makefile | 2 +- | |
graph.ml | 11 +++++++---- | |
2 files changed, 8 insertions(+), 5 deletions(-) | |
diff --git a/Makefile b/Makefile | |
index ac22afa..a99344d 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -10,7 +10,7 @@ DEPFLAGS=$(COMPFLAGS) | |
OBJS=graph.cmo | |
graph.js: graph | |
- js_of_ocaml +graphics.js $^ --pretty | |
+ js_of_ocaml +graphics.js $^ -pretty | |
graph: $(OBJS) | |
$(OCAMLC) $(COMPFLAGS) -linkall -linkpkg -o graph $< | |
diff --git a/graph.ml b/graph.ml | |
index 81534f6..a20b598 100644 | |
--- a/graph.ml | |
+++ b/graph.ml | |
@@ -55,16 +55,19 @@ let update arr = | |
let draw arr (canvas: Html.canvasElement Js.t) = | |
let c = canvas##getContext(Html._2d_) in | |
let clear_graph c = | |
- c##strokeStyle <- js "0,0,0"; | |
+ c##fillStyle <- js "rgb(0,0,0)"; | |
c##fillRect (0., 0., (float_of_int len_x), (float_of_int len_y)); | |
- c##strokeStyle <- js "0,255,255"; | |
+ c##strokeStyle <- js "rgb(0,255,255)"; | |
c##strokeRect (0., 0., (float_of_int len_x), (float_of_int len_y)) in | |
let draw_cubes c arr = | |
- c##strokeStyle <- js "0,0,255"; | |
+ c##beginPath(); | |
+ c##strokeStyle <- js "rgb(0,0,255)"; | |
Array.iter (fun item -> | |
print_cube item; | |
+ c##moveTo (item.px, item.py); | |
c##arc (item.px, item.py, 5., (10. *. 3.14 /. 180.), (80. *. 3.14 /. 180.), Js._false); ()) | |
- arr in | |
+ arr; | |
+ c##stroke() in | |
clear_graph c; draw_cubes c arr | |
let (>>=) = Lwt.bind | |
-- | |
2.1.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment