From 525fbf8f8cedc8b576278d9490673119e676de36 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Mon, 18 Jul 2022 22:26:31 -0700 Subject: [PATCH] Adding basic box. --- web/platform.fs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/web/platform.fs b/web/platform.fs index 146dba2..1371277 100644 --- a/web/platform.fs +++ b/web/platform.fs @@ -39,6 +39,10 @@ if (!globalObj.write) { context.filler = document.createElement('div'); document.body.insertBefore(context.filler, document.body.firstChild); context.canvas = document.createElement('canvas'); + context.canvas.width = 1000; + context.canvas.height = 1000; + context.canvas.style.width = '1px'; + context.canvas.style.height = '1px'; context.canvas.style.top = 0; context.canvas.style.left = 0; context.canvas.style.position = 'fixed'; @@ -66,11 +70,13 @@ if (!globalObj.write) { var width = window.innerWidth; var theight = Math.max(120, Math.floor(window.innerHeight / 6)); var height = window.innerHeight - theight; - if (width == context.width && height == context.height) { +/* + if (width != context.width && height != context.height) { return; } - context.canvas.width = width; - context.canvas.height = height; +*/ + context.canvas.style.width = width + 'px'; + context.canvas.style.height = height + 'px'; context.filler.style.width = '1px'; context.filler.style.height = height + 'px'; context.width = width; @@ -82,7 +88,7 @@ if (!globalObj.write) { context.ctx.fillRect(0, 0, context.canvas.width, context.canvas.height); } window.onresize = function(e) { - Draw(); + Resize(); }; window.onkeypress = function(e) { context.inbuffer.push(e.keyCode); @@ -193,11 +199,34 @@ r| }) | 7 jseval! +r| +(function(sp) { + var c = i32[sp>>2]; sp -= 4; + var h = i32[sp>>2]; sp -= 4; + var w = i32[sp>>2]; sp -= 4; + var y = i32[sp>>2]; sp -= 4; + var x = i32[sp>>2]; sp -= 4; + if (globalObj.write) { + return sp; + } + function HexDig(n) { + return ('0' + n.toString(16)).slice(-2); + } + context.ctx.fillStyle = '#' + HexDig((c >> 16) & 0xff) + + HexDig((c >> 8) & 0xff) + + HexDig(c & 0xff); + context.ctx.fillRect(x, y, w, h); + return sp; +}) +| 8 jseval! + forth definitions web : bye 0 terminate ; : page 12 emit ; : gr 1 7 call ; : text 0 7 call ; +$ffffff value color +: box ( x y w h -- ) color 8 call ; forth definitions