giovedì 4 gennaio 2018

Immagine sempre scalata proporzionalmente

Se volete un'immagine sempre scalata proporzionalmente rispetto alla finestra del programma, io consiglio questa tecnica:
  1. Chiamate l'immagine myImage
  2. Digitate nel terminale di livecode:
    set the realsize of image "myImage" to (the width of image "myImage", the height of image "myImage")
    set the startSizeStack of image "myImage" to (the width of this stack, the height of this stack)
  3. Adesso mettete nello stack il seguente codice:
    on resizeStack
       put the top of image "myImage" into tTop
       put the left of image "myImage" into tLeft
       put the realSize of image "MyImage" into tSize
       put the startsizeStack of image "myImage" into tSS
       set the width of image "myImage" to (item 1 of tSize * the width of this stack / item 1 of tSS )
       set the height of image "myImage" to (item 2 of tSize * the height of this stack / item 2 of tSS )
       if the width of image "myImage" > the height of image "myImage" then
          set the width of image "myImage" to (item 1 of tSize / item 2 of tSize * the height of image "myImage")
       else
          set the height of image "myImage" to (item 2 of tSize / item 1 of tSize * the width of image "myImage")
       end if
       set the top of image "myImage" to tTop
       set the left of image "myImage" to tLeft
       pass resizeStack
    end resizeStack

  4. Questo è il risultato:

Nessun commento:

Posta un commento