var a = document.getElementById("myCanvas"); var b = a.getContext("2d"); b.fillStyle = "#AF1E2C"; var size = 400; function createStar(x, y, s) { b.beginPath(); b.moveTo(x, y); b.lineTo(x + s, y); b.lineTo(x + s * 0.15, y + s * 0.5); b.lineTo(x + s / 2, y - s * 0.4); b.lineTo(x + s * 0.85, y + s * 0.5); b.lineTo(x, y); b.fill(); } createStar(150, 300, size);