-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
23 lines (19 loc) · 859 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// rndhex - main.ts
import { bold, rgb24 } from "https://deno.land/[email protected]/fmt/colors.ts";
// Function to generate a random hex color code
export function getRandomHexCode(): string {
const randomInt = Math.floor(Math.random() * 0xffffff);
return `#${randomInt.toString(16).padStart(6, '0')}`;
}
// Function to print a square of hashtags with the background color
export function printColoredSquare(hex: string) {
const r = parseInt(hex.substring(1, 3), 16);
const g = parseInt(hex.substring(3, 5), 16);
const b = parseInt(hex.substring(5, 7), 16);
// Print a 3x3 square with the background color
const square = `###\n###\n###`;
console.log(rgb24(bold(square), { r, g, b }));
}
const hexCode = getRandomHexCode();
console.log(hexCode); // Print the random hex code
printColoredSquare(hexCode); // Print the square with the hex color