# Equalling the rotation of an image with its object. Box2dweb

I have some hard time making the rotation of an image equal to the rotation object that the image belongs to. Simply put it, I don't know how to do it properly but i am not asking for a how-to guide but for some tips/hint and/or infos that i am not aware of...

I was able to align perfectly the image with the object, and so if the object moves in a linear fashion the image is at all times on top of the object and everything is smooth and perfect. But how is it possible to make the rotation of the image be the same as of the object it belongs to.

No-matter what i tried it is always somewhat off or the rotation of the image behaves weird when in the end the object stops rotating. I tried using using GetAngle(), GetAngularVelocity(), combinations of both, but never succeeded.

function Draw_and_Rotate(){
for (b = world.GetBodyList() ; b; b = b.GetNext()){
var angle = ((b.GetAngle()*180)/(Math.PI))/SCALE;
var angle_vel = ((b.GetAngularVelocity()*180)/(Math.PI))/SCALE;
var pos = b.GetPosition();
console.log((angle));
if (b.GetUserData() == "bo_img"){
ctx.save();//save the ctx state prior changing it.This method pushes the current state onto the stack.
ctx.translate(pos.x*SCALE , pos.y*SCALE );
ctx.rotate(angle);
ctx.drawImage(box_img, - (box_img.width / 2), - (box_img.height / 2));
ctx.restore();//restoring ctx state.This method pops the TOP state on the stack, restoring the context to that state.
}

}
}


this is the part that deals only with one body and its image. If someone needs some more clarification please ask....