position fixed finally
This commit is contained in:
+3
-3
@@ -14,9 +14,9 @@ inline bool ViButton(Vec2Df mp, float x, float y, float radius, Color color){
|
||||
|
||||
inline bool ViTexButton(Vec2Df mp, Vec2Df position, float rotation, float radius, Texture2D tex, Color color){
|
||||
float scale = (radius*2.0f) / (float)tex.width;
|
||||
Vec2Df center_pos = (position + Vec2Df((tex.width*scale) / 2.0f, 0.0f)).orbitAtAngle(radius, -rotation*DEG2RAD); //- Vec2Df(0, (tex.width*scale) / 2.0f).rotate(rotation);
|
||||
DrawTextureEx(tex, center_pos, rotation, scale, color);
|
||||
|
||||
Vec2Df start_position = position - Vec2Df((tex.width*scale) / 2.0f, (tex.height*scale) / 2.0f);
|
||||
Vec2Df center_pos = start_position.rotateAround(position, rotation);
|
||||
DrawTexturePro(tex, Rectangle(0.0, 0.0, tex.width, tex.height), Rectangle(center_pos.x, center_pos.y, tex.width*scale, tex.height*scale), Vec2Df(0,tex.height*scale/2.0f), rotation, color);
|
||||
return (Vector2Distance(mp, position) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ namespace VISEQ::VMATH{
|
||||
return Vec2D(cos(deg*DEG2RAD) * x, sin(deg*DEG2RAD) * y);
|
||||
};
|
||||
|
||||
Vec2D rotateAround(Vec2D<T> v, float deg){
|
||||
return Vec2D(cos(deg*DEG2RAD) * (x - v.x), sin(deg*DEG2RAD) * (y-v.y)) + v;
|
||||
};
|
||||
|
||||
Vec2D norm() { return *this / length();};
|
||||
|
||||
Vec2D center(Vec2D v){
|
||||
|
||||
Reference in New Issue
Block a user