It's the holidays and I feel like sharing. Below are four quick, do-it-yourself tutorials based on my all-time favorite Christmas DesktopX widgets. Enjoy!
Is It Christmas Yet?
I absolutely love RomanDA's Christmas Countdown Snowglobe widget. It's practical, compact, and the graphics are stellar. Did I mention it has animated snow?
You might be wondering, "How can I make a countdown widget to New Year's" or "How can I make a countdown widget to Uncle Bob's birthday--no screw Uncle Bob (he gives lousy gifts)--how 'bout a countdown to the Superbowl?!"
Well, I'm pleased to say, it's not hard at all.
Concept
The concept is pretty straightforward. You need to mark what day it is, mark what day you're counting down to, and calculate how much time remains between the two dates.
Dday - Today = time remaining. It's simple and there's actually a vbscript function that does this. It's called DATEDIFF (google it.)
Execution
Keeping it simple, we'll create a display text, which will show us the days remaining (or hours, minutes, and seconds if that's what floats your boat.)
Insert this script into your text object:
Dim Ddaytxt, Dday
Sub Object_OnScriptEnter
Dday = "1/1/2009"
Ddaytxt = "New Year's Day"
Object.settimer 1, 1000 ' -one-second timer
End Sub
Sub Object_OnTimer1
Sremain = DateDiff("s", Now(), Dday) '—seconds
Minremain = DateDiff("n", Now(), Dday) '--minutes
Hremain = DateDiff("h", Now(), Dday) '--hours
Dremain = DateDiff("d", Now(), Dday) '--days
Mremain = DateDiff("m", Now(), Dday) '--months
Yremain = DateDiff("y", Now(), Dday) '--years
Newmsg = Dremain & " day(s) until " & Ddaytxt
If Newmsg <> object.text Then Object.text = Newmsg
End Sub
To display hours, seconds, or minutes instead, you'd simply change the 'Newmsg' variable like so: Newmsg = Hremain & " hours until " & Ddaytxt
Now this is a pretty static example of how to do a countdown where the dates and display text are hardcoded into the widget, but you get the basic idea. Optimally, you'd have the option to change the date and display format on demand--and, ideally, have it stop counting after Dday has passed. But hey, that's why we have RomanDA's Holiday Countdown and Holiday Countdown Pro widgets!
Twinkle, Twinkle!
Island Dog has made some incredible Christmas light widgets (check out his gallery), but Icicle Christmas Lights is my absolute fave. They just look so realistic.
Mesmerized by those blinking lights? You can make them, too. Here we'll see just how to make animated twinkling.
Execution
We need to create and animated PNG. Oh, look! HERE is a tutorial by yours truly that shows you how. Now, for these lights we need to make the colors alternate in each frame. Then, we'll just loop it and watch them twinkle.
Here are the three images I combined to make the animated PNG:
1) 2) 3)
And here's the combined image:
There's no scripting necessary; it's all done in the appearance tab. See the image below for the settings.
Clone 'em, line 'em up, group 'em, and you'll have a whole string. (Now they may not be in sync until you restart DXBuilder, but once you've done that they should alternate in order.)
Jingle Bells!
I actually have three favorite Christmas weather widgets--including Christmas Time Weather by Martin and Christmas Snow Globe Weather by RomanDA-- but if I had to pick one, it would be White Christmas by Richard Mohler. I like it because it's uniquely low-key and I can use it all year round.
I don't know about you but I just see the words "white christmas" and I hear Bing Crosby's crooning. Now, wouldn't it be swell if you could have your favorite jingles and carols play on demand in a tiny widget in the corner of your screen? You can, goshdarnit, and you don't have to load up a media player either.
This one's really a 'did you know' but I thought I'd put it out there anyways.
Concept
Have a seasonal icon in the corner of your screen like, say, this:
Or this:
And when you mouse over the object, it begins to play a jingle.
Execution
Create the mouse away and mouse over states. Find the jingle you want. Go to the mouse over state and in the sounds tab load up your song. See image below.
It plays the entire song, once, as long as your mouse remains over the object, and it stops when you move away. 'Async sound loop' repeats the song as long as your mouse is over the object.
Let it snow! Let it snow! Let it snow!
There's just one word to describe Realistic Snowflakes by GreenReaper: awesome! Watch as the snowflakes drift and float, sway and fall, heavily, lightly, fast, slow--just beautiful!
No, I can't show you how to do the cool effects GreenReaper did with his widget, but I can show you how to make objects fall randomly down your screen. I originally made this script for a birthday surprise widget (where balloons fell down the unsuspecting user's screen), but it works just as well for snowflakes.
Concept
Pick a random spot across the top of your screen, put an object there, then let it move all the way down your screen. Reduce, reuse, and recycle.
Execution
Create and object and name it "snow1" Go to Properties > Summary and set the group name to "snow". Set height and width to 10 x 10 (a good size for a snowflake.)
**SCRIPT UPDATE 12/23/08**
Create another object (you should now have a total of two objects now) and put this script in it:
Dim trigger, objcount
Dim snocount, snowidth, snolimit, snostop, snostart, snodir, snospeed
snocount= 1
objcount= Desktopx.GroupObjects("snow").count
snowidth = system.VScreenWidth - DesktopX.Object("snow1").width
'***Adjust these variables to your preferences***
snolimit = 20 '--How many objects you want
snospeed = 2 '--How fast to go
trigger = 50 '--How far apart are the objects
snodir = "up" '--Which direction (up or down)
'*************************************************
'Called when the script is executed
Sub Object_OnScriptEnter
object.KillTimer 1
If snodir = "down" Then
snostart = 0 - DesktopX.object("snow1").height
snostop = system.screenheight
Else
snostart = system.screenheight
snostop = 0 - DesktopX.object("snow1").height
trigger = system.screenheight - trigger
End If
DesktopX.object("snow1").top = snostart
Clearsnow
Dropsnow
End Sub
Function Dropsnow
Object.SetTimer 1, 20
End Function
'---Move snowflake objects downscreen, duplicate, reset positions---
Sub Object_OnTimer1
objcount= Desktopx.GroupObjects("snow").count
For Each elem In Desktopx.GroupObjects("snow")
If elem.top = trigger Then
If objcount < snolimit Then Duplicate '--if not at limit of total snowflakes, duplicate
End If
Select Case snodir
Case "down"
If elem.top => snostop Then
elem.top= snostart
Randomize Timer '--get random coordinates
snowx = Int(Rnd * snowidth) + 1 '--get random coordinates
elem.left = snowx
Else
elem.top = elem.top + snospeed
End If
Case "up"
If elem.top <= snostop Then
elem.top= snostart
Randomize Timer '--get random coordinates
snowx = Int(Rnd * snowidth) + 1 '--get random coordinates
elem.left = snowx
Else
elem.top = elem.top - snospeed
End If
End Select
Next
End Sub
'---Duplicate snowflake object, and set its starting position----
Function Duplicate
Randomize Timer
snowx = Int(Rnd * snowidth) + 1
snocount = snocount + 1
snoname= "snow" & snocount
Desktopx.Object("snow1").clone snoname, snowx, snostart
End Function
'---Delete snowflake objects on startup----
Function Clearsnow
For x = 2 To objcount
Desktopx.Object("snow" & x).delete
Next
End Function
**Notice the portion of the script between the star lines. You can change these variables to adjust the settings of the falling objects, such as speed, spacing, direction, and amount.
There you go. It's a pretty rudimentary script but hopefully you get the basic idea behind it.
Well, that's it! Thanks for reading. Happy Holidays (and happy birthday to me!)