<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Logo</title>
<style>
footer{
display: block;
border-top: 1px solid orange;
margin: 10px;
font-family: "Trebuchet MS",Arial, Helvetica, sans-serif;
font-weight: bold;
}
article{
display:block;
font-family:Georgia, "Times New Roman", Times, serif;
margin: 5px;
}
</style>
<!--Start of Script-->
<script language="javascript">
var ctx;
var factorValue =1;
var fontfamily = "65px 'Gill Sans UltraBold', sans-serif";
function init() {
ctx = document.getElementById('canvas').getContext('2d');
ctx.font = fontfamily;
ctx.save();
dologo();
}
function dologo() {
var offsety = 80 ;
ctx.restore();
ctx.save();
ctx.clearRect(0,0,600,400);
ctx.scale(factorvalue,factorvalue);
ctx.fillText("HTML", 31,60);
ctx.translate(0,offsety);
//5 sided orange Background
ctx.fillStyle = "#E34C26";
ctx.beginPath();
ctx.moveTo(39, 250);
ctx.lineTo(17, 0);
ctx.lineTo(262, 0);
ctx.lineTo(239, 250);
ctx.lineTo(139, 278);
ctx.closePath();
ctx.fill();
//right
ctx.fillStyle = "#F06529";
ctx.beginPath();
ctx.moveTo(139, 257);
ctx.lineTo(220, 234);
ctx.lineTo(239, 20);
ctx.lineTo(139, 20);
ctx.closePath();
ctx.fill();
//light gray
ctx.fillStyle = "#EBEBEB";
ctx.beginPath();
ctx.moveTo(139, 113);
ctx.lineTo(98, 113);
ctx.lineTo(96, 82);
ctx.lineTo(139, 82);
ctx.lineTo(139, 51);
ctx.lineTo(62, 51);
ctx.lineTo(70, 144);
ctx.lineTo(139, 144);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.moveTo(139, 193);
ctx.lineTo(105, 184);
ctx.lineTo(103, 159);
ctx.lineTo(72, 159);
ctx.lineTo(76, 207);
ctx.lineTo(139, 225);
ctx.closePath();
ctx.fill();
}
</script>
</head>
<body onLoad="init();">
<canvas id="canvas" width="600" height="400">Your</canvas>
</body>
</html>
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
Oh okie !, I’m new to this Thanks for editing the content and for the info as well
I’m getting the following error when I run your code:
“Uncaught ReferenceError: factorvalue is not defined”
Take a good look at the name of that variable. Remember, JS is case sensitive.
Brilliant , thanks alot ! , it’s working !!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.