-
10 Oct 2012 3:19 PM #1
Unanswered: paperjs+sencha bug
Unanswered: paperjs+sencha bug
i'm creating a sencha application which draw a line on a picture inside a paperjs canvas. The line is drawn using mouseup event from paperjs. i use the event.downPoint and event.point for the extremities of the line. The user can draw only one single line on the canvas. After he draw it he can move the extremities clicking again on the canvas. The code i'm using is this:
you can find an working example of what i want to accomplish hereCode:var path = new Path(); path.strokeColor = 'black'; path.strokeWidth = 5; var ok = false; function onMouseUp(event) { if(ok){ var point = path.getNearestPoint(event.downPoint); if(point.x == path.segments[0].point.x && point.y == path.segments[0].point.y ){ path.segments[0].point = event.downPoint; }else{ path.segments[1].point = event.downPoint; } }else{ path.add(event.downPoint); path.add(event.point); ok = true; } }
http://jsfiddle.net/NwwEv/
I need yo integrate this into a sencha touch 2.0 application
what i've tried to do is to add the paper.js code at the end of the head section from the index file of the sencha application.
My problem is that the extremities points are not updated when try to do that. It's drawing another line starting from one of the extremities points to the point where i've clicked every time when i click on the canvas after i draw the line.Code:<script type="text/javascript" src="paper.js"></script> <script type="text/paperscript" canvas="largeImage" id="paperscope"> var path = new Path(); path.strokeColor = 'black'; path.strokeWidth = 5; var ok = false; function onMouseUp(event) { if(ok){ var point = path.getNearestPoint(event.downPoint); if(point.x == path.segments[0].point.x && point.y == path.segments[0].point.y ){ path.segments[0].point = event.downPoint; }else{ path.segments[1].point = event.downPoint; } }else{ path.add(event.downPoint); path.add(event.point); ok = true; } } </script>
It's like the variable path isnt stored and each time is creating a new line.
Thanks
-
12 Oct 2012 6:17 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3106
I don't see anywhere where you tried to integrate with ST2
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Oct 2012 9:54 AM #3
paper.js is included directly in the index.html of the sencha application. the canvas of paperjs is present in a tabpanel of the application.
Code:<!DOCTYPE HTML>h <html manifest="" lang="en-US"> <head> <meta charset="UTF-8"> <link rel="shortcut icon" href="./resources/icons/favicon.ico"> <script type="text/javascript" src="sdk/microloader/development.js"></script> <script type="text/javascript" src="paper.js"></script> <script type="text/paperscript" canvas="largeImage" id="paperscope"> var path = new Path(); path.strokeColor = 'black'; path.strokeWidth = 5; var ok = false; function onMouseUp(event) { if(ok){ var point = path.getNearestPoint(event.downPoint); if(point.x == path.segments[0].point.x && point.y == path.segments[0].point.y ){ path.segments[0].point = event.downPoint; }else{ path.segments[1].point = event.downPoint; } }else{ path.add(event.downPoint); path.add(event.point); ok = true; } } </script> </head> <body onload="onLoad()"> <div id="appLoadingIndicator"> <div></div> <div></div> <div></div> </div> </body> </html>


Reply With Quote