Skip to content

Commit

Permalink
working on serverless function for thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Jul 20, 2022
1 parent b143646 commit aa61634
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

.vercel

node_modules/
node_modules/
yarn.lock
7 changes: 2 additions & 5 deletions api/thumbnail/[name].js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as gridEngine from "../../engine/engine.js";
import { palette } from "../../palette.js";
import fetch from 'node-fetch';

async function drawGame(game) {

Expand Down Expand Up @@ -30,12 +31,8 @@ async function drawGame(game) {

screen.data.fill(255);
drawTiles(state, api, screen, bitmaps);
const canvas = document.createElement("canvas");
canvas.width = canvas.height = Math.max(screen.width, screen.height);
canvas.imageSmoothingEnabled = false;
canvas.getContext("2d").putImageData(screen, 0, 0);

return { name: game, image: canvas.toDataURL(), url };
return { name: game, image: screen, url };


function blitSprite(screen, sprite, tx, ty) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lzutf8": "^0.6.2",
"marked": "^4.0.17",
"md5": "^2.3.0",
"node-fetch": "^3.2.9",
"uhtml": "^3.0.1",
"vanilla-tilt": "^1.7.2"
},
Expand Down

0 comments on commit aa61634

Please sign in to comment.