initial commit
This commit is contained in:
+4
-3
@@ -1,7 +1,8 @@
|
||||
import '../styles/globals.css'
|
||||
import "../styles/globals.css";
|
||||
import "../styles/index.css";
|
||||
|
||||
function MyApp({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />
|
||||
return <Component {...pageProps} />;
|
||||
}
|
||||
|
||||
export default MyApp
|
||||
export default MyApp;
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
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.days;
|
||||
|
||||
//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("days", x, 375);
|
||||
ctx.fillText("days", 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.days + "-days.png"
|
||||
);
|
||||
res.status(200).send(png);
|
||||
};
|
||||
|
||||
export default ApiResponse;
|
||||
@@ -0,0 +1,88 @@
|
||||
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.days;
|
||||
|
||||
//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(
|
||||
"Cache-Control",
|
||||
"s-maxage=0",
|
||||
"content-disposition",
|
||||
"attachment; filename=" + imageRef.days + "-sleeps.png"
|
||||
);
|
||||
res.status(200).send(png);
|
||||
};
|
||||
|
||||
export default ApiResponse;
|
||||
@@ -0,0 +1,78 @@
|
||||
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.weeks;
|
||||
|
||||
console.log(imageStr, x, y);
|
||||
ctx.lineWidth = 25;
|
||||
|
||||
ctx.strokeStyle = "#cc3333";
|
||||
ctx.fillStyle = "white";
|
||||
|
||||
// ctx.lineJoin = "round";
|
||||
ctx.font = "245px Dancing";
|
||||
|
||||
ctx.strokeText(imageStr, 40, 375);
|
||||
|
||||
ctx.fillText(imageStr, 40, 375);
|
||||
|
||||
ctx.lineWidth = 10;
|
||||
ctx.strokeStyle = "white";
|
||||
ctx.fillStyle = "#cc3333";
|
||||
//ctx.textAlign = "left";
|
||||
ctx.font = "80px Dancing Script";
|
||||
ctx.strokeText("weeks today is", 40, 500);
|
||||
ctx.fillText("weeks today is", 40, 500);
|
||||
|
||||
ctx.strokeStyle = "white";
|
||||
ctx.fillStyle = "#cc3333";
|
||||
//ctx.textAlign = "left";
|
||||
ctx.font = "80px Dancing Script";
|
||||
ctx.strokeText("Christmas Day", 40, 610);
|
||||
ctx.fillText("Christmas Day", 40, 610);
|
||||
|
||||
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.weeks + "-weeks.png"
|
||||
);
|
||||
res.status(200).send(png);
|
||||
};
|
||||
|
||||
export default ApiResponse;
|
||||
@@ -0,0 +1,22 @@
|
||||
// 404.js
|
||||
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const FourOhFour = (props) => {
|
||||
const router = useRouter();
|
||||
|
||||
let numbDays = router.query.n;
|
||||
return (
|
||||
<div>
|
||||
<Image
|
||||
src={"/api/days/" + numbDays}
|
||||
width="940"
|
||||
height="788"
|
||||
alt="days"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FourOhFour;
|
||||
@@ -1,69 +0,0 @@
|
||||
import Head from 'next/head'
|
||||
import Image from 'next/image'
|
||||
import styles from '../styles/Home.module.css'
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<meta name="description" content="Generated by create next app" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
<main className={styles.main}>
|
||||
<h1 className={styles.title}>
|
||||
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
||||
</h1>
|
||||
|
||||
<p className={styles.description}>
|
||||
Get started by editing{' '}
|
||||
<code className={styles.code}>pages/index.js</code>
|
||||
</p>
|
||||
|
||||
<div className={styles.grid}>
|
||||
<a href="https://nextjs.org/docs" className={styles.card}>
|
||||
<h2>Documentation →</h2>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<a href="https://nextjs.org/learn" className={styles.card}>
|
||||
<h2>Learn →</h2>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/vercel/next.js/tree/master/examples"
|
||||
className={styles.card}
|
||||
>
|
||||
<h2>Examples →</h2>
|
||||
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
>
|
||||
<h2>Deploy →</h2>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a public URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer className={styles.footer}>
|
||||
<a
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Powered by{' '}
|
||||
<span className={styles.logo}>
|
||||
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
|
||||
</span>
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 404.js
|
||||
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const FourOhFour = (props) => {
|
||||
const router = useRouter();
|
||||
|
||||
let numbSleeps = router.query.n;
|
||||
return (
|
||||
<div>
|
||||
<Image
|
||||
src={"/api/sleeps/" + numbSleeps}
|
||||
width="940"
|
||||
height="788"
|
||||
alt="sleeps"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FourOhFour;
|
||||
@@ -0,0 +1,22 @@
|
||||
// 404.js
|
||||
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const FourOhFour = (props) => {
|
||||
const router = useRouter();
|
||||
|
||||
let numbWeeks = router.query.n;
|
||||
return (
|
||||
<div>
|
||||
<Image
|
||||
src={"/api/weeks/" + numbWeeks}
|
||||
width="940"
|
||||
height="788"
|
||||
alt="weeks"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FourOhFour;
|
||||
Reference in New Issue
Block a user