Created
February 25, 2016 11:41
-
-
Save hansemannn/cd11ccac9243ebe1b8ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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