Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   Вращение объекта на canvas (https://javascript.ru/forum/dom-window/79409-vrashhenie-obekta-na-canvas.html)

Jimy 04.02.2020 11:38

Вращение объекта на canvas
 
Добрый день! Вот фрагмент:
var sphere=function(x,y,radius){
 //ctx_scene.globalCompositeOperation='lighter';
    this.x=x;
    this.y=y;
    this.radius=radius;
    this.draw=function(){
       var grd=ctx_scene.createRadialGradient(this.x-5,this.y,this.radius/1000,this.x,this.y,this.radius)
       grd.addColorStop(0,'blue');
        grd.addColorStop(0.8,'white');
        ctx_scene.fillStyle=grd;
        ctx_scene.beginPath();
        ctx_scene.arc(this.x,this.y,this.radius,0,Math.PI*2,false);
        ctx_scene.fill(); };
};
var sphr=new sphere(200,400,10);


sphr.draw();

Подскажите, как заставить объект непрерывно вращаться вокруг своей оси? Например, по часовой стрелке?
Спасибо.

Jimy 05.02.2020 04:47

А сам понял. Объект нельзя крутить, зато можно крутить сам канвас...

Alexandroppolus 05.02.2020 08:06

https://developer.mozilla.org/ru/doc...tions#Rotating


Часовой пояс GMT +3, время: 01:59.