Last active
December 24, 2015 00:59
-
-
Save Omar-Gonzalez/6720244 to your computer and use it in GitHub Desktop.
Touch and Drag a Vector Line W/Titanium & lines.mod
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
//Import Lines Module | |
var lines = require('com.lines'); | |
//Window: | |
var win = Ti.UI.createWindow({ | |
backgroundColor:'black' | |
}); | |
//First event listener TouchStart the Origin Point | |
win.addEventListener('touchstart',function(e){ | |
attrib = { | |
color:'yellow', | |
touchEnable:true, | |
thickness:5 | |
}; | |
var startX = e.x; | |
var startY = e.y; | |
from = {x:startX,y:startY}; | |
to = {x:0,y:0}; | |
lineOne = lines.createLine(from,to,attrib); | |
}); | |
//Second Listener TouchMove(drag) Endpoint | |
win.addEventListener('touchmove',function(e){ | |
win.remove(lineOne); | |
var touchX = e.x; | |
var touchY = e.y; | |
to = {x:touchX,y:touchY}; | |
lineOne = lines.createLine(from,to,attrib); | |
win.add(lineOne); | |
}); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple draw tool: touch for origin point, drag for endpoint.