From 2cd6f1707d5f58d4de7b56658716b1dac455ca20 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 28 Mar 2022 13:07:55 +0100 Subject: [PATCH] removed sleeps --- pages/api/sleeps/[sleeps].js | 86 ------------------------------------ 1 file changed, 86 deletions(-) delete mode 100644 pages/api/sleeps/[sleeps].js diff --git a/pages/api/sleeps/[sleeps].js b/pages/api/sleeps/[sleeps].js deleted file mode 100644 index fba5d9e..0000000 --- a/pages/api/sleeps/[sleeps].js +++ /dev/null @@ -1,86 +0,0 @@ -import Canvas, { registerFont } from "canvas"; -import fs from "fs"; - -const ApiResponse = async (req, res) => { - //const { color } = req.query; - const imageRef = req.query; - const canvas = Canvas.createCanvas(940, 788); - const ctx = canvas.getContext("2d"); - - const rndInt = Math.floor(Math.random() * 367) + 1; - - console.log(rndInt); - - const background = await Canvas.loadImage( - "public/images/backgrounds/background-" + rndInt + ".jpg" - ); - - registerFont("public/fonts/Dancing_Script/static/DancingScript-Bold.ttf", { - family: "Dancing", - }); - - registerFont("public/fonts/Amatic_SC/AmaticSC-Bold.ttf", { - family: "AmaticSC", - }); - - ctx.drawImage(background, 0, 0, canvas.width, canvas.height); - - let x = canvas.width / 2 + 80; - let y = canvas.height - canvas.height / 2.5; - let imageStr = imageRef.sleeps; - - //console.log(imageStr, x, y); - ctx.lineWidth = 25; - - ctx.strokeStyle = "#cc3333"; - ctx.fillStyle = "white"; - - // ctx.lineJoin = "round"; - ctx.font = "245px Dancing"; - - imageStr.length == 3 - ? ctx.strokeText(imageStr, 120, 375) - : imageStr.length == 2 - ? ctx.strokeText(imageStr, 220, 375) - : ctx.strokeText(imageStr, 320, 375); - - imageStr.length == 3 - ? ctx.fillText(imageStr, 120, 375) - : imageStr.length == 2 - ? ctx.fillText(imageStr, 220, 375) - : ctx.fillText(imageStr, 320, 375); - - ctx.lineWidth = 10; - ctx.strokeStyle = "white"; - ctx.fillStyle = "#cc3333"; - //ctx.textAlign = "left"; - ctx.font = "147px Dancing Script"; - ctx.strokeText("sleeps", x, 375); - ctx.fillText("sleeps", x, 375); - - ctx.strokeStyle = "white"; - ctx.fillStyle = "#cc3333"; - //ctx.textAlign = "left"; - ctx.font = "140px Dancing Script"; - ctx.strokeText("until Christmas", 100, 560); - ctx.fillText("until Christmas", 100, 560); - - ctx.strokeStyle = "white"; - ctx.fillStyle = "white"; - ctx.textAlign = "left"; - ctx.font = "50px AmaticSC"; - //ctx.strokeText("WWW.GETAHEADCHRISTMAS.CO.UK", x, y); - ctx.fillText("WWW.GETAHEADCHRISTMAS.CO.UK", 40, 740); - - console.log(ctx); - - const png = canvas.toBuffer("image/png"); - - res.setHeader( - "content-disposition", - "attachment; filename=" + imageRef.sleeps + "-sleeps.png" - ); - res.status(200).send(png); -}; - -export default ApiResponse;