Author Topic: [solved] different coordinates for snap for different screen aspects - how to code it?  (Read 18520 times)

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
wait... you can use floor...

you just have to multiply aspect value by 10 - so you'll have

13.33333   16    17.77778

and after floor you'll have

13.0  16.0  17.0

and use that values to define

Code: [Select]
case "17.0":
        aspect_name = "16x9";
        break;
« Last Edit: December 16, 2015, 02:29:48 PM by verion »

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
I've checked all popular resolutions and aspects - and it turns out that your workaround for my resolution (additional value) will do the trick.
Because my laptop resolution is THE ONLY resolution that is problematic. All other will give you the same result for width/height - within the same aspect ratio.

1280x720-----16:9 = 1,77777777777778
1366x768-----16:9 = 1,77864583333333
1600x900-----16:9 = 1,77777777777778
1920x1080----16:9 = 1,77777777777778

I can always make 16:9 aspect "default" - but adding another value especially for 1366/768 will tighten the system and make it more (copy-paste) users friendly.



Full resolution list below if you are interested.

Code: [Select]
Resolution - Aspect ratio



320x240-----4:3
640x480-----4:3
800x600-----4:3
1024x768-----4:3
1152x864-----4:3
1280x960-----4:3
1400x1050-----4:3
1600x1200-----4:3
2048x1536-----4:3
3200x2400-----4:3
4000x3000-----4:3
6400x4800-----4:3

___________________


1280x720-----16:9 = 1,77777777777778
1366x768-----16:9 = 1,77864583333333
1600x900-----16:9 = 1,77777777777778
1920x1080----16:9 = 1,77777777777778

___________________

320x200-----16:10
640x400-----16:10
1280x800-----16:10
1440x900-----16:10
1680x1050-----16:10
1920x1200-----16:10
2560x1600-----16:10
3840x2400-----16:10
7680x4800-----16:10

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
yes i wasn't quite thinking but that should work fine and would solve your lone resolution issue. Although a proper round to tenth function might be nice to include in my utils I am working on :)

What about vertical aspects? What do we want to support, just the same reversed? I don't really use those currently.
« Last Edit: December 16, 2015, 03:55:29 PM by liquid8d »

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
I think "just the same reversed" is fine. For vertical 3:4 and maybe 10:16 are viable options. You can just throw 9:16 to the mix - but it is very unlikely that someone will use it for vertical (or design layout for 9:16).

---

I think that you could also add the option to define global variables - related to aspect.

like
::moveDown = 120

local screenBottomTitle fe.add_text("[Title]", 0, 1050+moveDown, 500, 30);

in this example
for 16:9 moveDown = 0
for 16:10 moveDown = 120

this way my [title] will be always at the bottom of the screen - regardless of screen aspect 16:9 or 16:10


I know you can do the same with coordinates table - but it could be a simpler solution when only one coordinate change is needed. The easy way to push some elements down/up left/right.

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
latest findings :)

"correct" aspect case for 1366x768 is 1.77865 it looks like it is rounded to #.#####


so it should be
case "1.77865":

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
sounds good - i added the case. And I'll add the vertical cases you mentioned, we can always add others if needed.

In regards to positioning - there's two different methods I have been working on. With animation, I had a positioning function with screen positions like center, left, right, top, bottom. I have also been testing an 'Anchor' function, which can anchor an object inside or against another object ( for example, anchor an image within a surface, or to the right of a surface ). I'm not sure if that should be part of the 'settings' module or something separate. In your case, are you referring to a padding when anchoring to a certain area?

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Quote
positioning function with screen positions like center, left, right, top, bottom.

sounds great if you can stack/combine them - like left-center or top-bottom
But one thing would be really great (and mayby it is that way) If using positioning other that top-left could change insetion point.

example:

placing square image 400x400px in bottom-left corner should change "insert point" to the bottom-left corner of the image (default is top-left)

something like this:

Code: [Select]
fe.add_image( name, insertPoint, x, y, w, h )

fe.add_image( "square.png", bottom-left, 0, 0, 400, 400 )

should give me visible square in bottom-left corner of the screen
So in this example using bottom-left effectively changes coordinate system for inserted objects (bottom-left corner of the screen is now "locally" point 0.0 and top-right is screenWidth.screenHeight)




Quote
'Anchor' function, which can anchor an object inside or against another object
I don't know if I understand your intend correctly. It should work the same way "inside" surface treating surface like new "screen", with top-left being top-left corner of the surface. And padding (moving away from insertion point) should be done with inserted object placement coordinates - but it could work only if coordinate system would change relatively to insertion point.

« Last Edit: December 18, 2015, 06:08:20 AM by verion »