Author Topic: Resize background  (Read 3897 times)

echeg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Resize background
« on: October 03, 2012, 02:11:51 AM »
I have:
UIRoot automatic: off, manual h : 760
background 1140x760px added like sprite and attach UIStretch script

How to scale the image to the pixel size (aspect ratio) did not change?
Example:
Device 2280x760px: bg image scale*2 and cut the Y-axis
Device 1140x380px: bg image scale*2 and cut the X-axis





ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resize background
« Reply #1 on: October 03, 2012, 02:58:40 AM »
I'm confused. You ask how to scale the image, and at the same time you mention pixel size, which implies pixel-perfectness. What is it you're trying to do?

echeg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Resize background
« Reply #2 on: October 03, 2012, 03:44:47 AM »
Sorry pixel size is incorrect wording.
I say that if the aspect ratio of the image 11 to 7 after scaling it should stay the same. Just one of the axes will go beyond the scope of the camera.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Resize background
« Reply #3 on: October 03, 2012, 04:13:42 AM »
I think you're talking about a way to specify the scaling mode, am I right ?
Something similar to iOS's API :
  - stretch : aspect ratio not preserved, fill target
  - fit : aspect ratio preserved, smallest image's dimension scaled so that it fills corresponding target's dimension
  - fill : aspect ratio preserved, largest image's dimension scaled so that it fills corresponding target's dimension
  - center : do not scale, just keep centered
  - top : do not scale, just keep top-centered
  - etc... : same for all 7 others positions

Would be quite useful indeed !

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resize background
« Reply #4 on: October 03, 2012, 06:56:19 AM »
I can probably add that kind of functionality, yeah.

In any case, for the time being though -- you will simply scale your widget manually if you want its aspect ratio to be preserved.

echeg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Resize background
« Reply #5 on: October 03, 2012, 07:11:03 AM »
thx. And then I thought that it was already implemented. and I'm just doing something wrong

Just one question how do I get the size of the sprite?(1140x760px)
« Last Edit: October 03, 2012, 07:23:50 AM by echeg »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Resize background
« Reply #6 on: October 03, 2012, 07:34:54 AM »
relativeSize scaled by transform.localScale.