horoscope

by Abhishek Kumar

HTML

<canvas id=canvas></canvas>

JavaScript

// Get the canvas element and its context
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

// Define the zodiac signs and their symbols
var signs = [
  {name: "Aries", symbol: "♈︎"},
  {name: "Taurus", symbol: "♉︎"},
  {name: "Gemini", symbol: "♊︎"},
  {name: "Cancer", symbol: "♋︎"},
  {name: "Leo", symbol: "♌︎"},
  {name: "Virgo", symbol: "♍︎"},
  {name: "Libra", symbol: "♎︎"},
  {name: "Scorpio", symbol: "♏︎"},
  {name: "Sagittarius", symbol: "♐︎"},
  {name: "Capricorn", symbol: "♑︎"},
  {name: "Aquarius", symbol: "♒︎"},
  {name: "Pisces", symbol: "♓︎"}
];

// Define some random horoscopes
var horoscopes = [
  "You will have a great day today.",
  "You will face some challenges, but you will overcome them.",
  "You will meet someone new and interesting.",
  "You will discover something surprising about yourself.",
  "You will have a chance to make a positive change in your life.",
  "You will enjoy some quality time with your loved ones.",
  "You will learn something new and useful.",
  "You will have some fun and excitement.",
  "You will feel inspired and creative.",
  "You will achieve a goal that you have been working on."
];

// Define the font size and style
var fontSize = 20;
var font = fontSize + "px Arial";

// Define the colors for the text and the background
var textColor = "#ffffff";
var bgColor = "#000000";

// Clear the canvas and fill it with the background color
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = bgColor;
ctx.fillRect(0, 0, canvas.width, canvas.height);

// Pick a random sign and horoscope
var signIndex = Math.floor(Math.random() * signs.length);
var sign = signs[signIndex];
var horoscopeIndex = Math.floor(Math.random() * horoscopes.length);
var horoscope = horoscopes[horoscopeIndex];

// Set the text color and font
ctx.fillStyle = textColor;
ctx.font = font;

// Calculate the x and y coordinates for the sign name and symbol
var signNameX = (canvas.width -...