Skip to content
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

WIP: paper.js integration #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

WIP: paper.js integration #68

wants to merge 4 commits into from

Conversation

rksm
Copy link
Member

@rksm rksm commented Nov 12, 2012

This is work in progress and the outcome of a weekend project.

paper.js is a HTML canvas JS library that supports
vector-style canvas rendering. Since our current path / polygon implementation
that is SVG-based suffers from the issues that arise when combining SVG /
HTML, this might be a a replacement.

Usage:

require('apps.paperjs').toRun(function() {
    var path = new apps.paperjs.Path([pt(0,0), pt(20,10), pt(100,100)]);
    path.openInWorld();
});

@bgnk
Copy link
Contributor

bgnk commented Nov 12, 2012

Nice, that approach seems to be fast and robust.
Now we just need a pen tool and some bezier handles and we could really get it going in the graphics department :)

if (!this.selectedSegment) return false;
var pos = this.localize(evt.getPosition()),
point = new paper.Point(pos.x, pos.y);
point = point.subtract(this.getOrigin());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the path is rotated (through the normal Lively rotate), moving one point influences the positions of the others.
Maybe the problem can be found here somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we could apply the morphic transformations here to fix that behavior. However, I thought that it might be even better to change how rotation is done for paperjs morphs by using paperjs transformations and rotate the paperjs objects on the canvas itself... for simple usage of lines/curves the current behavior should be OK, though.

@rksm
Copy link
Member Author

rksm commented Nov 13, 2012

bezier handles: nice thing is they come for free as paperjs draws them when a paperjs item is marked "selected". Unfortunately their style is not yet customizable.

@calmez
Copy link
Contributor

calmez commented Dec 9, 2012

This is super cool. I would like to use that for the SyncMorph in the Webwerkstatt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants