Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created November 28, 2011 22:53
Show Gist options
  • Save alanleard/1402470 to your computer and use it in GitHub Desktop.
Save alanleard/1402470 to your computer and use it in GitHub Desktop.
360 Image Rotation
var win = Ti.UI.createWindow(
{
title: "360 Image Rotation"
});
var images = [];
var imageCount = 4;
var totalCount = imageCount;
function display(){
var count = 0;
var imageView = Ti.UI.createImageView({
image:images[imageCount-1]
});
win.add(imageView);
imageView.addEventListener('swipe', function(e){
if(e.direction == 'right'){
count-=1;
if(count>(totalCount-1)){
count = totalCount-1;
}
} else {
count+=1;
if(count<1){
count = 0;
}
}
//alert(images[count]);
imageView.image = images[count];
});
}
function camera(count){
Titanium.Media.showCamera({
success:function(event)
{
var image = event.media;
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,(imageCount+1)+'.png');
f.write(image);
images.push(f.nativePath);
//alert(f.nativePath);
imageCount--;
if(count>0){
camera(imageCount);
} else {
display();
}
},
cancel:function()
{
},
error:function(error)
{
},
});
}
camera(imageCount);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment