OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

vectorChar vs. vectorText

Open z3dev opened this issue 3 years ago • 1 comments

From rozek via User Group

Hello!

First of all: thank you very much for [Open]JSCAD - it often helps me modeling technical objects which can then be sent to a 3D printer.

A few days ago, I've started tweaking the JSCAD User Guide mainly by adding require statements to the examples found there in order to simplify coding for casual JSCAD users like me.

During that process, I - again - stumbled across a difference between vectorChar and vectorText: while both methods are described as producing outlines which have to be converted into paths in order to be used for rendering, vectorChar "hides" its segments in a sub-property outlines.segments while vectorText directly produces segments (although the example calls them outlines as well).

Shouldn't both methods behave similarly? Or shouldn't the examples and their descriptions clearly describe the differences between both methods?

z3dev avatar Apr 17 '22 07:04 z3dev

From rozek via User Group

suggestions would depend on whether you would accept breaking API changes or prefer keeping the API stable.

A somewhat silly idea could be to assign the output of vectorText to its own subproperty segments (outlines.segments = outlines) : in that case, one would always have to convert outlines.segments.

From a user's point of view, however, the main question should probably be why vectorChar and vectorText do not produce paths right away - and why there are two such methods (since vectorText looks like a superset of vectorChar).

A possible non-breaking consequence could be: invent a new function textPaths (or similar) with a signature like vectorText which directly produces paths:

const { textPaths } = require('@jscad/modeling').text const paths = textPaths('JSCAD') Such a method should be trivial to implement.

z3dev avatar Apr 17 '22 07:04 z3dev