Resizing png file

Need a little help!!!

Friday, June 13, 2008 by Automan | Discussion: DesktopX Tutorials

Hi folks;

I have a menu system built into my DesktopX theme, and I need a little scripting help?

I am building in Photoshopcs3 all of the png files for certain links and task like Utilities, Media,Office,etc.

Now I make the images at 64 pixels an I am trying to use cod to make the images change size to 72 pixels with " Mouse over".

I need a way to increase the size just like Object dock plus. Increase the size with code so the it will enlarge the image to jump out to the 72 pixels.

Can someone help me on this, I need it to move smoothly to the larger size.

Thanks folks!!!

Automan

SirSmiley
Reply #1 Friday, June 13, 2008 3:00 PM
Code: vbscript
  1. 'Called on mouse over object
  2. Sub Object_OnMouseEnter
  3. Object.Resize 72,72
  4. End Sub
  5. 'Called when mouse leaves object
  6. Sub Object_OnMouseLeave
  7. Object.Resize 64,64
  8. End Sub
PuterDudeJim
Reply #2 Friday, June 13, 2008 4:04 PM
'Called on mouse over object
Sub Object_OnMouseEnter
Object.Resize 72,72
End Sub

'Called when mouse leaves object
Sub Object_OnMouseLeave
Object.Resize 64,64
End Sub


Didnt work for me.
ZubaZ
Reply #3 Friday, June 13, 2008 4:22 PM
Worked here

How would you make it grow from the center?
PuterDudeJim
Reply #4 Friday, June 13, 2008 4:33 PM
Does the object need to have 1 state or two? Does it need to be named object? I know I sound dumb...lol.
ZubaZ
Reply #5 Friday, June 13, 2008 4:42 PM
No and no.
PuterDudeJim
Reply #6 Friday, June 13, 2008 4:45 PM
No and no.


No and no what? 1 or 2 states?
PuterDudeJim
Reply #7 Friday, June 13, 2008 4:48 PM
Got it now, 1 state works! Thanx!
Automan
Reply #8 Friday, June 13, 2008 8:17 PM
Hello again folks;

Looks like we are kind of missing the idea here, as when you use the code here which I have used to resize before; it will move the png image larger and down to the bottom left by a little bit. This would also need to have a - off set to make the image just grow larger.

The one thing I am trying to do is set the image to spring out larger just like Object dock plus.

Object dock moves the image at a smooth pace to the larger size instead of just jumping to the resize, thus forth there has to be away to get the alignment right and also get the smooth slowe spring up action.

Any ideas using a little math maybe?

Thanks for all the help here, if this can be done, then any part of an object on the desktop can be set by vbcode to move in the same fasion.

Thanks again for the brain work. It's really appreciated!

Automan
SirSmiley
Reply #9 Friday, June 13, 2008 8:31 PM
You won't get the same smoothness as objectdock without a timer. Pretty sure I have something in my code base...here you go.
Code: vbscript
  1. Dim MinW,MaxW
  2. MinW = 64
  3. MaxW = 128
  4. MinH = 64
  5. MaxH = 72
  6. Sub Object_OnScriptEnter
  7. object.width = MinW
  8. Object.Height = MinH
  9. End Sub
  10. 'Called on mouse over object
  11. Sub Object_OnMouseEnter
  12. Call Grow
  13. End Sub
  14. 'Called when mouse leaves object
  15. Sub Object_OnMouseLeave
  16. Call Shrink
  17. End Sub
  18. Function Shrink
  19. object.KillTimer 200
  20. object.SetTimer 100,10
  21. End Function
  22. Function Grow
  23. object.KillTimer 100
  24. object.SetTimer 200,10
  25. End Function
  26. Sub object_ontimer100
  27. If object.width => MinW Then
  28. object.width = object.width - 4
  29. object.height = object.height - 4
  30. Object.Left = Object.Left + 2
  31. Object.Top = Object.Top + 2
  32. Else
  33. object.KillTimer 100
  34. End If
  35. End Sub
  36. Sub object_ontimer200
  37. If object.width <= MaxW Then
  38. object.width = object.width + 4
  39. object.height = object.height + 4
  40. Object.Left = Object.Left - 2
  41. Object.Top = Object.Top - 2
  42. Else
  43. object.KillTimer 200
  44. End If
  45. End Sub
SirSmiley
Reply #10 Friday, June 13, 2008 8:34 PM
There's an error MaxW=128 should be MaxW=72.
SirSmiley
Reply #11 Friday, June 13, 2008 8:50 PM
A little cleaner script.

Code: vbscript
  1. Dim MinW,MaxW
  2. MinW = 64
  3. MaxW = 128
  4. MinH = 64
  5. MaxH = 72
  6. Sub Object_OnScriptEnter
  7. object.width = MinW
  8. Object.Height = MinH
  9. End Sub
  10. 'Called on mouse over object
  11. Sub Object_OnMouseEnter
  12. Call Grow
  13. End Sub
  14. 'Called when mouse leaves object
  15. Sub Object_OnMouseLeave
  16. Call Shrink
  17. End Sub
  18. Function Shrink
  19. object.KillTimer 200
  20. object.SetTimer 100,10
  21. End Function
  22. Function Grow
  23. object.KillTimer 100
  24. object.SetTimer 200,10
  25. End Function
  26. Sub object_ontimer100
  27. If object.width => MinW Or object.Height=> MinH Then
  28. object.Resize object.Width-4,object.Height-4
  29. object.Move object.Left+2,object.Top+2
  30. Else
  31. object.KillTimer 100
  32. End If
  33. End Sub
  34. Sub object_ontimer200
  35. If object.Width<=MaxW Or object.Height<=MaxH Then
  36. object.Resize object.Width+4,object.Height+4
  37. object.Move object.Left-2,object.Top-2
  38. Else
  39. object.KillTimer 200
  40. End If
  41. End Sub
RomanDA
Reply #12 Saturday, July 26, 2008 6:13 PM
i think i have seen that code somewhere before.

lol
superman
Reply #13 Sunday, August 3, 2008 2:05 PM
Somewhere!
...Where?
Automan
Reply #14 Tuesday, September 2, 2008 7:28 AM
Hi folks;

Great job on the code here, I have it working, but a always when you think youn have it perfect you find a change that would make it even better. So here goes.

Most of us have seen the new Impulse Ver.2 and it is slick! My only problem is that I don't want it running in memory all the time. So I turned and looked at my Menu system and presto it hit me.

In the new impulse there is a mouse over event that uses a black bar that when presed it will change to orange. This being said, I decided to mae my menu just like impulse but with out all the goodies thatn it has. Below is a list of what I am trying to do.

1 DesktopX pops open the menu.
2 When your mouse passes over the text name of the object it wii show the "Black Image".
Also I need a call to png "Icon image to make it use the code that was made before on the icon image to grow to the max height or on leave shrink back down to the correct state, This where I get into trouble..How do you call the resize code that is in the Icon to make it 92 as if the mouse was over it and the shrink it back down when the mouse leaves the text and bar

I will post an image of what I'm trying to do in a few minutes.

Anyway if you have seen the new Impulse and move your mouse over the menu like " My Desktop"
The change is rally cool!!!!

DesktopX PopUp
Mouse over = Black then
om Mouse pause over the Icon and the bar will switch to a gold/orange bar and text stays the same color unless you want it to...On click program startsm

I hope all of this has made a little sense, sounds cool anyway.........

Thanks a million guys and gals......


Automn   

Automan




BigDogBigFeet
Reply #15 Tuesday, September 2, 2008 11:12 AM

Have you considered using animation strips instead of script?  They might work better for this.

RomanDA
Reply #16 Tuesday, September 2, 2008 8:25 PM

There are always a bunch of ways to do things in DX

Animation strips can work good, so can a timer, its more CPU intensive.  In the strip you can control how long things take, and also when to start stop or REVERSE the animation.  Im sure i have a tutorial on this somewhere out there if you need one.

Lumic
Reply #17 Thursday, September 4, 2008 6:10 AM

It is also much more time consuming

 

Plus you lose the dock items' customizability.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01