Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var module = require("ti.glpaint");
- var isErasing = false;
- var win = Ti.UI.createWindow({
- backgroundColor: "#fff"
- });
- var paintView = module.createPaintView({
- brush: {
- opacity: 1,
- tintColor: "red",
- image: "brush.png",
- scale: 2
- },
- top: 100
- });
- var btn1 = Ti.UI.createButton({
- title: "Change to green color",
- top: 30
- });
- var btn2 = Ti.UI.createButton({
- title: "Is erasing: false",
- top: 50
- });
- var btn3 = Ti.UI.createButton({
- title: "Take snapshot",
- top: 70
- });
- btn1.addEventListener("click", function() {
- paintView.setBrush({
- opacity: 1,
- tintColor: "green",
- image: "brush2.png",
- scale: 1
- })
- });
- btn2.addEventListener("click", function() {
- isErasing = !isErasing;
- paintView.setErasing(isErasing);
- btn2.setTitle(isErasing ? "Is erasing: true" : "Is erasing: false");
- //paintView.erase();
- });
- btn3.addEventListener("click", function() {
- var image = paintView.takeGLSnapshot();
- var win2 = Ti.UI.createWindow({title: "Snapshot!", backgroundColor: "#000"});
- var nav = Ti.UI.iOS.createNavigationWindow({window: win2});
- var close = Ti.UI.createButton({title: "Close"});
- close.addEventListener("click", function() {nav.close();});
- win2.setLeftNavButton(close);
- win2.add(Ti.UI.createImageView({image: image}));
- nav.open({modal: true});
- });
- win.add(paintView);
- win.add(btn1);
- win.add(btn2);
- win.add(btn3);
- win.open();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement