Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Created February 25, 2016 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansemannn/cd11ccac9243ebe1b8ec to your computer and use it in GitHub Desktop.
Save hansemannn/cd11ccac9243ebe1b8ec to your computer and use it in GitHub Desktop.
var win = Ti.UI.createWindow();
var outterView = Ti.UI.createView({
width: 300,
height: 300,
backgroundColor: "red",
top: 40
});
var innerView = Ti.UI.createView({
width: 200,
height: 200,
backgroundColor: "yellow"
});
var trigger = Ti.UI.createButton({
top: 10,
title: "Crop to 200x200 (yellow part)"
});
var resultImageView = Ti.UI.createImageView({bottom: 40});
trigger.addEventListener("click", function() {
var image = outterView.toImage();
var cropped = image.imageAsCropped({
width: 200,
height: 200,
x: 150,
y: 150
});
resultImageView.setImage(cropped);
});
outterView.add(innerView);
win.add(outterView);
win.add(resultImageView);
win.add(trigger);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment