I'm working on an image annotator that utilizes paper.js
PointText
objects for part of it. One thing we're looking into is allowing the user to highlight different parts of the text of a given PointText
object with different colors and font sizes.
I saw the Gradient
option on the paper.js
website, but that would feel like more of a hack to get working, assuming it would work in the first place. Then I would have to get it to display properly in the textarea
used for editing the PointText
, which sounds even more hacky; I would like a cleaner solution.
Any solutions must allow the text to be draggable within the bounds of the canvas.
I don't have any code to show because I haven't found anything to try, but I wanted to see if the SO community is aware of any possible solutions.
I think text tools are still in development in Paper.js*, so I guess you have to create one PointText by color or use gradients as you suggested if you want to stick with Paper.js.
In my opinion you should really consider overlaying text on top of the canvas and handle styles with CSS. Here is an example:
html:
coffeescript:
css:
*http://paperjs.org/reference/textitem/
Edit
You can then use html-to-canvas or rasterizeHTML.js to convert your colored text into an image that you can paste onto the paper.js canvas at the correct location. (You can use Raster to import your image into paper.js)