From 2f4dd240c4da1a1e1c776fe1a2e31b7bf8fb0744 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 25 Jul 2012 17:24:52 +0200 Subject: [PATCH] Change setting of color via context.fillStyle --- 3_FirstInteractive/code/haste/helpers.js | 2 +- 3_FirstInteractive/code/uhc/JavaScript.hs | 2 +- 3_FirstInteractive/code/uhc/helpers.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/3_FirstInteractive/code/haste/helpers.js b/3_FirstInteractive/code/haste/helpers.js index b51513a..c3d2107 100644 --- a/3_FirstInteractive/code/haste/helpers.js +++ b/3_FirstInteractive/code/haste/helpers.js @@ -28,7 +28,7 @@ function jsFillRect(context, x, y, width, height, _) { } function jsSetFillColor(context, color, _) { - context.setFillColor(color); + context.fillStyle = color; return [1,0]; } diff --git a/3_FirstInteractive/code/uhc/JavaScript.hs b/3_FirstInteractive/code/uhc/JavaScript.hs index e918cfd..166cced 100644 --- a/3_FirstInteractive/code/uhc/JavaScript.hs +++ b/3_FirstInteractive/code/uhc/JavaScript.hs @@ -26,7 +26,7 @@ getContext2d canvasName = do foreign import js "%1.fillRect(%*)" fillRect :: Context2D -> Double -> Double -> Double -> Double -> IO () -foreign import js "%1.setFillColor(%*)" +foreign import js "jsSetFillColor(%*)" jsSetFillColor :: Context2D -> JSString -> IO () setFillColor ctx = jsSetFillColor ctx . toJS foreign import js "%1.clearRect(%2, %3, %4, %5)" diff --git a/3_FirstInteractive/code/uhc/helpers.js b/3_FirstInteractive/code/uhc/helpers.js index 591ca0a..6302f83 100644 --- a/3_FirstInteractive/code/uhc/helpers.js +++ b/3_FirstInteractive/code/uhc/helpers.js @@ -7,3 +7,7 @@ function jsSaveGlobalObject(name, obj) { function jsLoadGlobalObject(name) { return allObjects[name]; } + +function jsSetFillColor(context, color) { + context.fillStyle = color; +}