Jarsey45

3c dla mendeli

Sep 22nd, 2019 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <meta charset="UTF-8">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.   <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8.   <title>dla mendeli</title>
  9.   <style>
  10.  
  11.   </style>
  12. </head>
  13.  
  14. <body>
  15.   <canvas id="myCanvas" width="600" height="600" style="border:1px solid #d3d3d3;">Not supported
  16.   </canvas>
  17.  
  18.   <script>
  19.     function obracaj() {
  20.       offset = 1
  21.       r = 200
  22.       //ctx.beginPath();
  23.       //ctx.moveTo(30, 0)
  24.       if (licznik == 360) {
  25.         licznik = 0
  26.       } else {
  27.         ctx.clearRect(-300, -300, cnv.height, cnv.width)
  28.         x = r * Math.cos((Math.PI / 180) * licznik)
  29.         y = r * Math.sin((Math.PI / 180) * licznik)
  30.         //ctx.moveTo(x, y)
  31.         ctx.drawImage(img, (-imgSize / 2) + x, (-imgSize / 2) + y, imgSize, imgSize)
  32.       }
  33.       //console.log(x, y)
  34.  
  35.       // ctx.lineTo(30, 0)
  36.       // ctx.stroke();
  37.  
  38.       licznik += offset
  39.       //console.log(licznik)
  40.     }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.     var licznik = 0
  48.     var cnv = document.getElementById("myCanvas");
  49.     var ctx = cnv.getContext("2d");
  50.     var imgSize = cnv.height / 4
  51.  
  52.     var img = new Image()
  53.     img.src = 'https://p7.hiclipart.com/preview/635/60/839/car-wheel-coloring-book-lakeside-bicycles-wheel.jpg'
  54.     ctx.translate(cnv.height / 2, cnv.width / 2)
  55.  
  56.  
  57.  
  58.     // ctx.fillStyle = "#ff0000"
  59.     // ctx.fillRect(0, 0, 50, 50)
  60.     const cos = setInterval(() => {
  61.       obracaj()
  62.     }, 10)
  63.     // img.onload = function () {
  64.  
  65.     //   //ctx.drawImage(img, -imgSize / 2, -imgSize / 2, imgSize, imgSize)
  66.     // }
  67.   </script>
  68.  
  69. </body>
  70.  
  71. </html>
Add Comment
Please, Sign In to add comment