-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag Single Object #1
Comments
History of sketch is stored in
```
sketchpad.room.sketch.framesHistory
```
and
```
sketchpad.room.sketch.toolsCache
```
Tools like a rectangle, photo or text are represented as a single object so you can easily change information about them.
Here is an example:
```
/******** OBJECT ANIMATION DEMO ************/
/*global sketchpad*/
setInterval(function () {
"use strict";
var sketch = sketchpad.room.sketch;
sketch.framesHistory.forEach(function (frame) {
frame.evs.forEach(function (event) {
var eventFrameVewport = sketch.getCachedFrame(event.cid);
// eventFrameVewport contains information about drawer viewport, tool type and tool config
// eventFrameVewport.tol = "rect";// tool type
// eventFrameVewport.cnf.col = "rgba(" + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random() * 256) + "," + Math.random() + ")";
// start(x, y) and end(x, y) defines rectangle and are relative to viewport
//
// move right:
event.pts.x[0] = event.pts.x[0] + 1; // start x
event.pts.y[0] = event.pts.y[0]; // start y
event.pts.x[1] = event.pts.x[1] + 1; // end x
event.pts.y[1] = event.pts.y[1]; // end y
// rotate:
eventFrameVewport.rot = (eventFrameVewport.rot + 1) % 360;
});
});
sketchpad.refreshWindow();
}, 100);
```
Here is snippet: https://jsbin.com/biwewodutu/1/edit?js,output
(draw something to see how objects moves)
… Wiadomość napisana przez Maninarang ***@***.***> w dniu 20.12.2017, o godz. 13:40:
How can we move single objects rather than viewport..like i just want to move image or text rather than whole viewport
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#1>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ASl-29YHK4ApwAq_CnwKV2pOY5MVaX4mks5tCQAigaJpZM4RIVYP>.
|
Thats nice.. but what my problem is i dont understand how to select particular object(like text or image or rectangle) and drag it from one position to other.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can we move single objects rather than viewport..like i just want to move image or text rather than whole viewport
The text was updated successfully, but these errors were encountered: