Skip to content

Instantly share code, notes, and snippets.

@donayama
Created December 19, 2011 22:28
Show Gist options
  • Save donayama/1499215 to your computer and use it in GitHub Desktop.
Save donayama/1499215 to your computer and use it in GitHub Desktop.
Filterable Cameraの利用例(in 聖地巡礼S) これをapp.jsからTi.include してグローバルイベントでcallしてます
var module = require('jp.msmc.filterablecamera');
var presets = {
/*
* Normal
*/
Normal : new module.Filter(function() {
// NO OPERATION
}),
/*
* Gray
*/
Gray : new module.Filter(function() {
this.grayscale();
}),
/*
* Vintage
*/
Vintage : new module.Filter(function() {
this.sepia(0.8).vignette(0.8, 0.5);
}),
/*
* OrangePeel
*/
OrangePeel : new module.Filter(function() {
this.curves({
chan : 'rgb',
start : [0.0, 0.0],
ctrl1 : [0.4, 0.19],
ctrl2 : [0.55, 0.78],
end : [1.0, 1.0]
}).vibrance(-0.3).saturation(-0.3).colorize('#ff9000', 0.3).contrast(-0.05).gamma(1.4);
}),
/*
* Lomo
*/
Lomo : new module.Filter(function() {
this.brightness(0.15).exposure(0.15).curves({
chan : 'rgb',
start : [0.0, 0.0],
ctrl1 : [0.78, 0.0],
ctrl2 : [0.6, 1.0],
end : [1.0, 1.0]
}).saturation(-0.2).gamma(1.8).vignette(0.5, 0.6).brightness(0.05);
}),
/*
* Love
*/
Love : new module.Filter(function() {
this.brightness(0.05).exposure(0.08).colorize('#c42007', 0.3).vibrance(0.5).gamma(1.3);
})
};
var setting = require('setting');
var qualities = ['Photo', 'High', 'Low'];
// default filter
var activeFilterName = 'Normal';
module.activeFilter = presets[activeFilterName];
var settingView = setting.createSettingView();
Array.prototype.indexOf = function(value) {
for(var i = 0; i < this.length; i++) {
if(this[i] === value) {
return i;
}
}
return -1;
};
module.addEventListener('change', function(e) {
var target = setting.targets[e.target];
// activate current setting
for(var i in target) {
if(e.target === 'activeFilter') {
target[i].active = (activeFilterName === target[i].value);
} else {
target[i].active = (module[e.target] === target[i].value);
}
}
// show setting
settingView.showSetting({
title : setting.titles[e.target],
data : target,
selected : function(item) {
if(e.target === 'activeFilter') {
module[e.target] = presets[item.value];
activeFilterName = item.value;
} else {
module[e.target] = item.value;
}
}
});
});
Ti.API.addEventListener('plib:showCamera', function(data) {
if(Ti.Media.isMediaTypeSupported('camera', Ti.Media.MEDIA_TYPE_PHOTO) == false) {
alert('カメラがサポートされていません。');
return;
}
if(data.filter) {
module.showCamera({
squared : true,
showControls : true,
animated : true,
autohide : true,
saveToPhotoGallery : true,
overlay : settingView,
quality : 'High',
backgroundImage : false,
success : function(image) {
// argument 'image' is picture you took
Ti.API.debug("image was captured.");
},
error : function() {
Ti.API.debug("image was not captured.");
},
cancel : function() {
Ti.API.debug("capturing was canceled.");
}
});
} else {
Titanium.Media.showCamera({
success : function(event) {
},
cancel : function() {
},
error : function(error) {
},
saveToPhotoGallery : true,
allowEditing : false,
autohide : true,
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});
}
});
@wpccolorblind
Copy link

Where is this iOS module now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment