/*************
variables to make program work
*************/
//access the canvas
var canvas = document.getElementById('myCanvas');
//access drawing environment
var context = canvas.getContext("2d");
//create a new image
var space = new Image();
space.src = "https://i.postimg.cc/DyNVWvJm/space.jpg";
//size
var size = 10;
//variables for rectangles
/***********
function for drawing stuff
ALL OF YOUR CODE GOES HERE vvvv
************/
//noodle backround
var noodle = new Image(noodle);
noodle.src = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzeLV4wJGeZYOuox_SjUTb1uo0TZWMwOClLyNnfWN0IsGtKO5p"
context.drawImage(noodle, 0, 0, 500, 500)
//noodle ad
//text
function draw(Rect) {
size = size + 5
//color rect 1
context.fillStyle = "Black";
//shape rect 1
context.fillRect(0, 0, 30, 500);
//color rect 5
context.fillStyle = "Black";
//shape rect 5
context.fillRect(470, 0, 30, 500);
//color rect 2
context.fillStyle = "white";
//shape rect 2
context.fillRect(140, 130, 200, 200);
//color rect 3
context.fillStyle = "red";
//shape rect 3
context.fillRect(160, 160, size, size);
//color rect 4
context.fillStyle = "yellow";
//shape rect 4
context.fillRect(220, 220, size, size);
//text
context.fillStyle = "black"
var ctx = canvas.getContext("2d");
ctx.font = "20px Arial";
ctx.fillText("now available in different flavors",30,400);
//text
context.fillStyle = "black"
var cta = canvas.getContext("2d");
cta.font = "30px Arial";
cta.fillText("Nissin cup noodles",140,220);
//text
context.fillStyle = "black"
var ctb = canvas.getContext("2d");
ctb.font = "20px Arial";
ctb.fillText("Do not microwave!",30,370);
}
/************
Call the function
************/
draw();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.