Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <article class="row">
- <canvas id="can" class="col-10 col-lg-4 mt-5 offset-1" ></canvas>
- <script>
- var canvas = document.getElementById("can");
- var wysokosc=-150;
- var speed=2.5;
- function draw()
- {
- var ctx = canvas.getContext("2d");
- ctx.clearRect(0,0,400,150);
- ctx.save();
- ctx.translate(0,wysokosc);
- ctx.beginPath();
- ctx.strokeStyle="rgba(255,0,0,0.4)";
- ctx.fillStyle="rgba(255,0,0,0.3)";
- ctx.moveTo(130,0);
- ctx.lineTo(130,70);
- ctx.lineTo(110,70);
- ctx.lineTo(140,150);
- ctx.lineTo(170,70);
- ctx.lineTo(150,70);
- ctx.lineTo(150,0);
- ctx.lineTo(130,0);
- ctx.fill();
- ctx.restore();
- wysokosc+=speed;
- if(wysokosc>150)
- {
- wysokosc=-150;
- }
- window.requestAnimationFrame(draw);
- }
- $(document).ready(function() {
- window.requestAnimationFrame(draw);
- });
- </script>
- </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement