Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>dla mendeli</title>
- <style>
- </style>
- </head>
- <body>
- <canvas id="myCanvas" width="600" height="600" style="border:1px solid #d3d3d3;">Not supported
- </canvas>
- <script>
- function obracaj() {
- offset = 1
- r = 200
- //ctx.beginPath();
- //ctx.moveTo(30, 0)
- if (licznik == 360) {
- licznik = 0
- } else {
- ctx.clearRect(-300, -300, cnv.height, cnv.width)
- x = r * Math.cos((Math.PI / 180) * licznik)
- y = r * Math.sin((Math.PI / 180) * licznik)
- //ctx.moveTo(x, y)
- ctx.drawImage(img, (-imgSize / 2) + x, (-imgSize / 2) + y, imgSize, imgSize)
- }
- //console.log(x, y)
- // ctx.lineTo(30, 0)
- // ctx.stroke();
- licznik += offset
- //console.log(licznik)
- }
- var licznik = 0
- var cnv = document.getElementById("myCanvas");
- var ctx = cnv.getContext("2d");
- var imgSize = cnv.height / 4
- var img = new Image()
- img.src = 'https://p7.hiclipart.com/preview/635/60/839/car-wheel-coloring-book-lakeside-bicycles-wheel.jpg'
- ctx.translate(cnv.height / 2, cnv.width / 2)
- // ctx.fillStyle = "#ff0000"
- // ctx.fillRect(0, 0, 50, 50)
- const cos = setInterval(() => {
- obracaj()
- }, 10)
- // img.onload = function () {
- // //ctx.drawImage(img, -imgSize / 2, -imgSize / 2, imgSize, imgSize)
- // }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment