Roblox Lua Script, How to make a frame decrease its size from left to right? - lua

I'm trying to make a health bar that decreases from left to right instead of from right to left
and it has to be this way because of how the interface looks, I've tried different calculations but all of them were close but too far and I'm running out of ideas on how to make it

Take a look into anchor point.
What anchor point does is set the origin of the UI. So for your use case, you'll probably want to set the anchor point to [1,0]. Which means the UI will scale to the left
(White Box) Anchor point 0,0
(White Box) Anchor point 1,0
With an anchor point of 1,0, it will scale to the left

Related

Indesign Bug? Choosing Fancy Corners Reverses Function of Align Stroke Inside/Outside

I think that this might be a bug in InDesign but I thought that it might be handy to know.
Here's how to recreate: Create a rectangle 200px x 200px, with a 4pt stroke. Set Align stroke to INSIDE. Set the top left xy pos of the rectangle to 100px,100px so that you can easily see changes, and leave the Reference Point in the top left. Now when you change stroke widths, everything is fine, and change corner types, everything is fine, EXCEPT the Fancy Corners. So if you choose Fancy Corners, the x/y becomes 96,96 and total width/height changes to 208 x 208 which is incorrect. Now change the Align Stroke to "OUTSIDE", and the x/y changes back to 100,100 and the rectangle size changes back to 200 x 200. Completely backwards, but just for the Fancy Corners.
Please comment if this is an expected response.

Does UIOffsetMake() use the traditional top left corner origin (0,0) or bottom left origin?

View geometry in UIKit specifies that it acts on an axis starting from the top left corner (0,0) and increasing in x and y as you travel toward the bottom right.
UIOffsetMake() is used a lot in UIKit Dynamics, and I was wondering if it follows a similar model. It's used to specify, relative to the center of the UIView, where you want the point where the view gets pushed to originate from.
If I specify UIOriginMake(5.0, -5.0) does it change it from the center to further in the bottom right? As in it goes down 5 vertically and 5 over horizontally? Or does it follow the traditional UIView model where that would indicate it goes 5 points over horizontally and 5 points up vertically?
I have no reason to think it doesn't follow UIView's model, but I wasn't positive and I wanted to make sure.
You'll find the answer in the docs for the UIOffset struct:
The components are positive for right or down, negative for left or up.

How can I draw a point at my ImagevView's anchorpoint?

I am trying to achieve some effect using imageViews and I need to set the anchorpoint correctly. It is very hard without it being visible.
How would you go about showing it up on the imageview ?
The anchor point is a property specified on the layer (you will need QuartCore to access it). It is specified in the unit coordinate space of the device (both x and y goes from 0 to 1 within the bounds of the layer. You can know the coordinate of the actor point by multiplying the x value with the width and the y value with the height. To draw a point at that location you could just add a new, small layer (bounds 4x4 and corner radius 4 (to get a circle))
Be aware that changing the anchor point will change where the layer (and the view) appears on screen as the frame is calculated relative to the anchor point. To have the frame appear in the same place after the anchor point has been set you could re-set the frame (this will update the layers position so that the frame is what you expect it to be)

Aligning text to always be on the outside of line

I know how to align text diagonally, but I'm having trouble aligning the text to be always on the outside, as the diagram shows:
http://i38.tinypic.com/rs4zlj.png
The lines will always be positioned as a triangle.
What I get instead is, depending on the angle, text is inside or out (and upside down). Is there any math that can help me out here? I have the angle of every line, if that is helpful at all.

Repositioning images on FormResize proportionally

I have a Delphi form with TImages on it. Actually, it's a "fake" desktop with "icons" (the TImages).
When the user resizes the form (scales it or maximizes it, for example) the icons on the form should align proportionally.
Right now, I'm doing something like this with the images:
ImageX.Left:=Round(ImageX.Left * (Width / OldWidth));
ImageX.Top:=Round(ImageX.Top * (Height / OldHeight));
Now this is OK, as long as I start to make the maximized form smaller.
In that case the rightmost images are cut in part by the form's border (they're off the form's client area).
If I reposition these images to fit the client area, then the position of the icons get distorted upon scaling back to maximum size.
Any ideas for a better algorithm/fix?
Thanks!
First of all, you can't have a correctly scaled desktop when you only move the images, and don't scale them as well. You can do slightly better by moving the midpoints of your images, not their top left corner. It still won't be perfect, but it will work better. Of course, now the images will be cropped on all four sides, not just bottom and right, but at least it will be symmetrical :-)
Second, you will get accumulative rounding errors since you constantly override the "original" values (ImageX's top and left coordinate). You'd be better off having the original values stored in some sort of collection or array, and setting the new position based on the original value, rather than the previous value.
Something like this:
ImageX.Left:=Round(ImageX_OriginalLeft * (Width / Original_Width));

Resources