Skip to content

Instantly share code, notes, and snippets.

View icecandy's full-sized avatar

Simon Buckingham icecandy

View GitHub Profile
@icecandy
icecandy / manualAnimation.js
Created September 28, 2017 12:13
Titanium Custom Animation Example: manualAnimation.js library file
// @author Simon Buckingham
// @date 27 September 2017
// @description Uses a single imageView/view and just swaps image property according to a timer. Gives more control than using the usual imageView "images" property
// eg one can start at an arbitrary frame number (not implemented yet) and also better playback for Android.
// Copyright (c) 2017 Simon Buckingham. All Rights Reserved.
// Please see the LICENSE file included with this distribution for details.
module.exports = ManualAnimation;
//@_params Object - function parameters...
@icecandy
icecandy / gist:40dff4525b8e80feab9df57a981990f2
Created September 28, 2017 14:34
Titanium example of defining an array of animation file names
Alloy.Globals.animationFilenames = [];
function initAnimationFilenames() {
var filename;
for (var i = 1; i <= 118; i++) {
filename = '/images/animation/animation_' + padNumber(i, 3) + '.png';
Alloy.Globals.animationFilenames.push(filename);
}
}
@icecandy
icecandy / imageLibrary.js
Created October 9, 2017 12:05
Image library to render SVG icons in Titanium
// Image Library
// @author Simon Buckingham
// @date 29th September, 2017
// This uses a combination of techniques to:
// (i) create bitmaps from SVG vector files using the com.geraudbourdin.svgview native cross-platform module
// (ii) create a tinted image.
// Note: there is a weird effect that on iOS using Ti.UI.createMaskedImage it creates blobs that are vertically flipped and
// so we need to use a transform = Ti.UI.create2DMatrix().scale(1, -1) to flip the image back again.
// Copyright (c) 2017 Simon Buckingham. All Rights Reserved.
// Please see the LICENSE file included with this distribution for details.