Titanium Ace Snow object creates a falling snowflake effect for your application window.

It is possible to set quantity and speed of flakes, and also provide image of custom snowflake. This object also provides methods to start or stop snowing and add flakes.

Package contains Ace.snow.js and example Titanium application project.



Example codes

//include snow object

//create main window
var win = Titanium.UI.createWindow({  
    title:'Snowing window',

//generate snow
var snow = new Ace.snow(win, {
	//color of snowflake
	//use image property to provide image
	color: 'white',
	//time to take for one snowflake to fall(ms)
	fallingTime: 12000,
	//interval between snowflakes(ms)
	flakeInterval: 800,
	//flake size
	flakeSize: 10,
	//difference between size for smallest and largest
	sizeDelta: 5,
	//animation curve
	//should snow flakes fade out while falling
	fadeOut: true,
	//should snow start automatically
	autoStart: true

Example video

Video of module example app:

Method list


Back to method list

Method namenew snow(window, config);
DescriptionCreate snow instance for specified window
Input parameters

window - Titanium window object, where snow will appear

json config - Json structure with configuration properties

  • string image - path for snowflake image (default: none)
  • string color - color of snowflake if image is not used (default:white)
  • int fallingTime - time in miliseconds for one snowflake to fall (default: 12000)
  • int flakeInterval - time in miliseconds between new snowflakes appearing (default: 800)
  • int flakeSize - average snowflake size in platform specific units (default: 10)
  • int sizeDelta - difference from average snowflake size for smaller and greater snwoflakes (default: 5)
  • Titanium curve - Titanium animation curve (default: Titanium.UI.ANIMATION_CURVE_EASE_IN)
    • Titanium.UI.ANIMATION_CURVE_EASE_IN: Accelerate the animation slowly
    • Titanium.UI.ANIMATION_CURVE_EASE_OUT: Decelerate the animation slowly
    • Titanium.UI.ANIMATION_CURVE_EASE_IN_OUT: Accelerate and decelerate the animation slowly
    • Titanium.UI.ANIMATION_CURVE_LINEAR: Make the animation speed constant throughout the animation cycles
  • bool fadeOut - should snow flakes fade out while falling (default: true)
  • bool autoStart - should snow start automatically (default: true)
Example input
var snow = new Ace.snow(win);

Start snow

Back to method list

Method namestart()
DescriptionStart snowing if sowing was stopped or wasn't started automatically

Stop snow

Back to method list

Method namestop()
DescriptionStop new flakes from appearing

Add flake

Back to method list

Method nameaddFlake(x, r)
DescriptionSnow flakes will appear automatically based on provided configuration, but it is possible to add additional snowflakes using this method
Input parameters

int x - coordinate on x axis, where snow should appear (deault: random, limited by screen width)

int r - radius of snowflake (default: random, limited by provided configuration)

Latest changes

None for now