From 590edcd7419963cfe870eb639538cd6a918dd3cf Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Wed, 8 Jan 2020 17:44:51 -0500 Subject: added rasterization for space -> tile transform --- space.js | 7 ++++--- utils/raster.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 utils/raster.js diff --git a/space.js b/space.js index d4e4567..d7f68e8 100644 --- a/space.js +++ b/space.js @@ -134,10 +134,11 @@ function Space(){ this.subsection = function(range){ // range is a coordinate pair // Similarly excludes this.loc newspace = new Space(); - for (let line=range[0][0]; line<=range[1][0]; line++){ + for (let line=range[0][0]; line vec.dot(coord,[1/8, 1/16])).map(tile => vec.elem(tile, [], a => Math.floor(a))); + for (let y=dim[0][0]; y<=dim[0][1]; y++) for (let x=dim[1][0]; x<=dim[1][1]; x++){ + let tile = tileToChar([y,x]); + tiles[tile] = space.subsection(tile, vec.add(tile, [8,16])); + } + return tiles +} -- cgit