Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposal] Make origin_x and origin_y independent of picture size #554

zpaolo11x opened this Issue Apr 3, 2019 · 0 comments


None yet
1 participant
Copy link

zpaolo11x commented Apr 3, 2019

Right now origin_x and origin_y are very useful to place images, but not so useful for scaling: let's say you want to place a picture in the middle of the layout:

local pic = fe.add_image ("abg.jpg",flw*0.5,flh*0.5,400,400)
pic.origin_x = 200
pic.origin_y = 200

this works perfectly, but let's say I want to scale the picture, a command like

pic.width = 600

doesn't work well because the center of scaling is still locked at 200 pixels. So I'll have to explicitly reposition the image center, for example with a function like this:

function picscale (obj,scale){
   obj.width = obj.width * scale
   obj.height = obj.height * scale
   obj.origin_x = obj.width * 0.5
   obj.origin_y = obj.height * 0.5

It would be nice to be able to define a "relative_origin_x" and "relative_origin_y" as fractional values from 0 to 1, so that, for example, 0.5 and 0,5 keeps the image centered even when changing the scale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.