paperjs.org | static pages in https | Continous Integration library
kandi X-RAY | paperjs.org Summary
kandi X-RAY | paperjs.org Summary
The source of the Paper.js website translated to the static pages in by running it through in a Travis CI worker on each commit.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Compile a code fragment .
- ECMA - 262 13
- Traverse an array of path segments .
- Gets the winding value of the given point .
- Loads the specified element .
- Render an anchor element .
- Loop over two lines
- Divides the given locations into two locations .
- execute code and execute the code
- Add intersection functions
paperjs.org Key Features
paperjs.org Examples and Code Snippets
Community Discussions
Trending Discussions on paperjs.org
QUESTION
I have a paper.js vector scene containing paths with an outline but no- or a transparent fill. The onMouseEnter
/onMouseLeave
events attached to each path fire correctly when the paths have a fill colour with any non-zero alpha value, e.g. #00000001
. When the fill is transparent or absent I only trigger the onMouseEnter
events when the cursor happens to touch the outline as I move it over the shape.
While the minimal alpha solution works, or I could ensure that the fill colour matches the background colour, I have overlapping shapes and would prefer a solution that doesn't require nearly-correct hacks like that that might cause issues as many shapes stack up.
This example uses global hit-testing and I think I can make it work with some re-architecting. Is this the best approach?
Is there any way to have a transparently filled path fire onMouseEnter
events consistently as the cursor moves inside the shape?
ANSWER
Answered 2022-Feb-14 at 12:51paper.js works quite hard to exclude transparent paths from hit results. In the end the most pragmatic thing that worked for me was to patch the individual Paths I'm interested in. I'm using Typescript, hence the annotations:
QUESTION
I'm attempting to use paper.js with javascript directly: http://paperjs.org/tutorials/getting-started/using-javascript-directly/
and cannot get gradients to work. Instead of a color gradient the line just appears to be black. This occurs for all shapes, so I'm pretty sure I'm somehow setting up paper.js incorrectly. Any help would be appreciated!
Here's an example codeblock:
...ANSWER
Answered 2022-Jan-27 at 22:20In your example you referenced library as
QUESTION
In jQuery, I can attach an event to all elements like a paragraph, using $("p")
. Does something similar exist for Paper.js. I tried using project.activeLayer.children.onMouseEnter
but that did not work.
I was thinking about looping over all the children inside the onFrame
function but that seems wrong. It will probably attach multiple event listeners to the same item. So, all items will have many event listeners attached to them but I am not sure.
What is the best way to attach event listeners to all current and future items in a project layer in Paper.js?
...ANSWER
Answered 2021-Nov-18 at 08:12QUESTION
With 3 points, I am trying to achieve: rotate, move and resize after grouping them to any Path. Path can be any regular polygon shape.
So far it is rotating and moving well smoothly. However it fails on resizing.
Here is the sketch.
Can someone guide or correct?
Note: the sketch was updated to move when shape is also dragged.
...ANSWER
Answered 2021-Nov-18 at 08:04The key is to use the point
argument of the item.scale()
method.
It allows scaling the item around a custom point and not around its center, which is the default behavior.
You also have to cancel the group dragging when the scaling operation is active, like you already do with the rotation.
Here is a sketch demonstrating a simplified solution to your problem (only handles uniform scaling) that should get you on the track.
QUESTION
Checking the previous solution from a touch screen device (my mobile phone), I noticed the impossibility to select a PaperJS item by using onMouseMove
event and so set the item as value for the selectedPath
variable. Other problem, for a mobile device, is the difficulty to press the d
key on the keyboard to delete the selectedPath
...
So I thought to use the onDoubleClick
event on an added item to remove it, like in this sketch where you can draw an arrow by dragging and make it yellow with a single click or remove it with a double click on it (you can also remove the rectangle with a double click on it), but can't achieve the same in this other sketch (similar to the previous question), to remove a smooth item (drawn dragging on canvas) on double click.
Thank you for your help
...ANSWER
Answered 2021-Nov-04 at 15:26What is happening is that when you want to delete an existing item by double clicking it, you also unwantedly trigger you mousedown listener, which is used to draw new items and should not be triggered in this case.
What you need to do is check whether you are over an existing item or not before starting drawing.
Here's a sketch demonstrating a simple solution to your issue.
QUESTION
First steps with PaperJS. I realized this sketch and this video to describe the issue. As you can see in the video, drawing, for example, three items, and moving over them to select one and pressing the "d" key on keybord, it is possible to remove just the last added and selected item, but not the previous ones. If you start from the first or second item of the three added, the alert is not even triggered.
The wanted beaviour would be instead to select the event.item.selected
(moving on it with the mouse) and remove just the selected one by clicking the "d" key on keyboard.
Thank you for your help
...ANSWER
Answered 2021-Nov-02 at 11:12Your issue is that after removing the first path, your path
variable no longer points to nothing.
So the next time you hit the delete key, you no longer know the selected path.
What you should do instead is storing the currently selected path into another variable and use it instead.
Here's a corrected sketch based on your code, demonstrating this.
QUESTION
I need to get the svg element from a react-icon component to render the image using a different Javascript library.
I'm using paperjs as the drawing engine for this demo I'm working on, for the UI I use react-icons and react-bootstrap. Now paperjs allows to importSVG images, so I try the following:
...ANSWER
Answered 2021-Jun-23 at 17:20Got it! to achieve this you will need to
- Extract the path element like so
MdMemory().props.children[0].props.d
- Create an
svg
string likeconst svg = "..."
QUESTION
I'm trying to read a file from STDIN, process it with paper.js and return the results.
To get there I first tried to do it by reading in a file from the fs like this:
...ANSWER
Answered 2021-Jun-11 at 15:15I'm not able to reproduce it with another svg file like https://upload.wikimedia.org/wikipedia/commons/2/21/Speaker_Icon.svg.
Could you please link your svg file ?
I suggest you to try with the following code, as readFile on stdin could not work properly (https://github.com/nodejs/node-v0.x-archive/issues/7412)
QUESTION
I'm trying to understand how to use setpixel method that exists in the PaperJS code and its documentation but doesn't work.
Here is the Sketch example.
...ANSWER
Answered 2021-Mar-10 at 09:17This method is made to be used on a raster instance.
Extracted from the documentation, here is a sketch demonstrating what it does.
QUESTION
In PaperJS is it possible to fill a raster with a color without iterating over each pixel?
So say you have a PNG with some transparency, the pixels with no transparency will have a different color.
AFAIK you can iterate over each pixel http://paperjs.org/tutorials/images/using-pixel-colors/ and do it manually (creating an alternate pixel for each image pixel), but ideally there is a solution that doesn't require doing this pixel by pixel.
It would be nice to use the raster as a clipping mask to show the color beneath it but I believe that only works with paths.
Grateful for any help
...ANSWER
Answered 2021-Mar-09 at 18:22An alternative can be to make a clever usage of blend mode.
The principle is to use the raster as an alpha source for a shape that is positioned over it.
I don't have much time to elaborate right now, now but here is a sketch that should get you on the track.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install paperjs.org
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page