Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ctx = document.getElementById("canvas").getContext("2d");
- function draw()
- {
- for (var i = 0; i < 100; i++) {
- ctx.beginPath();
- ctx.moveTo(20+i*20,0);
- ctx.lineTo(20+i*20,800);
- ctx.stroke();
- ctx.beginPath();
- ctx.moveTo(0,20+i*20);
- ctx.lineTo(600,20+i*20);
- ctx.stroke();
- }
- ctx.Nebo(); //небо
- var grad = ctx.createLinearGradient(20, 0, 480, 300);
- grad.addColorStop(0, '#B5FBFF');
- grad.addColorStop(1, '#2994FF');
- ctx.fillStyle = grad;
- ctx.fillRect(0, 0, 600, 480);
- ctx.fill();
- ctx.beginPath(); //поле
- var grad = ctx.createLinearGradient(0, 800, 0, 500);
- grad.addColorStop(0, '#FFC961');
- grad.addColorStop(1/2, '#BEF574');
- grad.addColorStop(1, '#FFFF66');
- ctx.fillStyle = grad;
- ctx.fillRect(0, 500, 600, 300);
- ctx.beginPath(); //дорога у дома
- var grad = ctx.createLinearGradient(0, 500, 0, 480);
- grad.addColorStop(0, '#DBDBDB');
- grad.addColorStop(1, '#BDBDBD');
- ctx.fillStyle = grad;
- ctx.fillRect(0, 480, 600, 20);
- ctx.beginPath(); //т. елки
- ctx.fillStyle = "rgb(54,99,55)";
- ctx.moveTo(140,480);
- ctx.lineTo(140,160);
- ctx.lineTo(200,480);
- ctx.fill();
- ctx.beginPath(); //круглая елка
- ctx.arc(540, 400, 80, 0, Math.PI*2, true);
- ctx.fillStyle = "rgb(54,99,55)";
- ctx.fill();
- ctx.beginPath(); //стена
- ctx.fillStyle = "rgb(250,250,250)";
- ctx.fillRect(240,320,80,160);
- ctx.fillStyle = "rgb(205,205,205)";
- ctx.fillRect(320,320,80,160);
- ctx.fillStyle = "rgb(205,205,205)";
- ctx.fillRect(400,420,180,60);
- ctx.fillStyle = "rgb(250,250,250)";
- ctx.fillRect(140,400,100,80);
- ctx.beginPath(); //окошки и дверь
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(280,340,20,40);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(260,420,40,60);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(360,340,20,40);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(500,440,10,20);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(540,440,10,20);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(160,420,10,20);
- ctx.fillStyle = "rgb(86,63,31)";
- ctx.fillRect(200,420,10,20);
- ctx.beginPath(); //газон у дома
- var grad = ctx.createLinearGradient(400, 470, 400, 480);
- grad.addColorStop(0, 'green');
- grad.addColorStop(1, '#363636');
- ctx.fillStyle = grad;
- ctx.fillRect(400, 470, 180, 10);
- ctx.beginPath(); //крыша
- ctx.fillStyle = "rgb(220,57,19)";
- ctx.moveTo(240,320);
- ctx.lineTo(320,240);
- ctx.lineTo(320,320);
- ctx.fill();
- ctx.beginPath();
- ctx.fillStyle = "rgb(173,46,14)";
- ctx.moveTo(320,240);
- ctx.lineTo(400,320);
- ctx.lineTo(320,320);
- ctx.fill();
- ctx.fillStyle = "rgb(220,57,19)";
- ctx.fillRect(400,360,160,60);
- ctx.beginPath(); //крыша
- ctx.fillStyle = "rgb(173,46,14)";
- ctx.moveTo(400,420);
- ctx.lineTo(400,360);
- ctx.lineTo(480,360);
- ctx.fill();
- ctx.beginPath();
- ctx.fillStyle = "rgb(220,57,19)";
- ctx.moveTo(560,360);
- ctx.lineTo(580,420);
- ctx.lineTo(560,420);
- ctx.fill();
- ctx.fillStyle = "rgb(220,57,19)";
- ctx.fillRect(160,340,80,60);
- ctx.beginPath();
- ctx.fillStyle = "rgb(220,57,19)";
- ctx.moveTo(140,400);
- ctx.lineTo(160,340);
- ctx.lineTo(160,400);
- ctx.fill();
- ctx.beginPath(); //св. елки
- ctx.fillStyle = "rgb(67,152,70)";
- ctx.moveTo(80,480);
- ctx.lineTo(140,160);
- ctx.lineTo(140,480);
- ctx.fill();
- ctx.beginPath(); // св. елки
- ctx.fillStyle = "rgb(67,152,70)";
- ctx.moveTo(40,480);
- ctx.lineTo(80,120);
- ctx.lineTo(80,480);
- ctx.fill();
- ctx.beginPath(); //т. елки
- ctx.fillStyle = "rgb(54,99,55)";
- ctx.moveTo(80,480);
- ctx.lineTo(80,120);
- ctx.lineTo(120,480);
- ctx.fill();
- }
- function snowdrawing()
- {
- clear();
- ctx.beginPath();
- if (positionXx < 1500) {
- positionXx += 2;
- } else
- {
- positionXx = 10;
- positionY = 10;
- }
- for (var i = 0; i <= 400; i++) {
- var x = Math.round(Math.random() * 1000),
- y = Math.round(Math.random() * 1000);
- ctx.beginPath();
- ctx.fillStyle = "rgba(255,255,255,0.4)";
- ctx.arc(x, y + positionY, 5, 0, Math.PI * 2, true);
- ctx.fill();
- ctx.beginPath();
- ctx.fill();
- ctx.closePath();
- }
- setInterval(drawing,100);
- var positionXxx = 0;
- var positionY = 0;
- var positionXx = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement