// In this blog we learn that how to use paint module in appcelerator
// This module is very easy to use.
// This paint module is available on appcelerator market place.
//Sample code is available here. :)
You can get module using this link
https://dl.dropboxusercontent.com/u/72783403/paint.zip
var Paint = require('ti.paint');
var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});
var paintView = Paint.createPaintView({
top : 0,
right : 0,
bottom : 80,
left : 0,
strokeColor : 'black',
strokeAlpha : 255,
strokeWidth : 5,
eraseMode : false
});
win.add(paintView);
var clear = Ti.UI.createButton({
bottom : 40,
right : 50,
width : 75,
height : 30,
title : 'Clear'
});
clear.addEventListener('click', function() {
paintView.clear();
});
win.add(clear);
var save = Ti.UI.createButton({
bottom : 40,
left : 50,
width : 75,
height : 30,
title : 'Save'
});
save.addEventListener('click', function() {
var filename = "sample.png";
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
if (file.exists()) {
file.deleteFile();
}
file.write(paintView.toImage());
var path = file.nativePath;
Ti.API.info('path of image' + path);
alert('Image Save');
});
win.add(save);
win.open();
// This module is very easy to use.
// This paint module is available on appcelerator market place.
//Sample code is available here. :)
You can get module using this link
https://dl.dropboxusercontent.com/u/72783403/paint.zip
var Paint = require('ti.paint');
var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});
var paintView = Paint.createPaintView({
top : 0,
right : 0,
bottom : 80,
left : 0,
strokeColor : 'black',
strokeAlpha : 255,
strokeWidth : 5,
eraseMode : false
});
win.add(paintView);
var clear = Ti.UI.createButton({
bottom : 40,
right : 50,
width : 75,
height : 30,
title : 'Clear'
});
clear.addEventListener('click', function() {
paintView.clear();
});
win.add(clear);
var save = Ti.UI.createButton({
bottom : 40,
left : 50,
width : 75,
height : 30,
title : 'Save'
});
save.addEventListener('click', function() {
var filename = "sample.png";
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
if (file.exists()) {
file.deleteFile();
}
file.write(paintView.toImage());
var path = file.nativePath;
Ti.API.info('path of image' + path);
alert('Image Save');
});
win.add(save);
win.open();
No comments:
Post a Comment