Advertisement
Guest User

transform

a guest
Apr 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. # Unity -> imageTargetHeight = 1
  2.  
  3. float imageTargetAspectRatio = imageTarget.imageTargetWidth / imageTarget.imageTargetHeight;
  4. float imageTargetCenterY = imageTarget.bottomRight.y - ((imageTarget.bottomRight.y - imageTarget.topLeft.y) / 2.0f);
  5. float imageTargetHeight = imageTarget.bottomRight.y - imageTarget.topLeft.y;
  6. float imageTargetWidth = imageTarget.bottomRight.x - imageTarget.topLeft.x;
  7.  
  8. rectangle
  9.     //x = ((rect.Left - imgTargetCenterX) / imageTargetWidth) * imageTargetAspectRatio;
  10.     x = (rect.Left - imgTargetCenterX) / imageTargetHeight;
  11.     y = (imgTargetCenterY - rect.top) / imageTargetHeight;
  12.     width = rect.width / imageTargetHeight;
  13.     height = rect.height / imageTargetHeight;
  14.    
  15. circle
  16.     x = (circle.Left - imgTargetCenterX) / imageTargetHeight;
  17.     y = (imgTargetCenterY - circle.top) / imageTargetHeight;
  18.     radius = circle.width / imageTargetHeight;
  19.    
  20. text
  21.     x = (text.Left - imgTargetCenterX) / imageTargetHeight;
  22.     y = (imgTargetCenterY - text.top) / imageTargetHeight;
  23.     int font_size = (float)(((text.lineHeight * text.fontSize) / imageTargetHeight) * 10);
  24.     if(font_size < 1)
  25.         font_size = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement