meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:design_guide_text [2020/12/03 03:18]
JSCAD Editor
en:design_guide_text [2022/04/14 08:32] (current)
rozek included "require" statements, corrected mistakes
Line 1: Line 1:
 ==== Text ==== ==== Text ====
  
-Text can be used in designs to create the outline of charaters, which can then be used to create either 2D or 3D shapes.+Text can be used in designs to create the outline of characters, which can then be used to create either 2D or 3D shapes.
  
 //NOTE: Only the ASCII characters can be used today.// //NOTE: Only the ASCII characters can be used today.//
Line 17: Line 17:
  
 <code javascript> <code javascript>
-let outlines = vectorChar('H'); +const { vectorChar } = require('@jscad/modeling').text 
-let outlines = vectorChar({ height: 50 }, 'i');+ 
 +const outlines = vectorChar('H'); 
 +const outlines = vectorChar({ height: 50 }, 'i');
 </code> </code>
  
Line 24: Line 26:
  
 <code javascript> <code javascript>
 +const { path2 } = require('@jscad/modeling').geometries
 +
 const segmentToPath = (segment) => { const segmentToPath = (segment) => {
-  return geometries.path2.fromPoints({close: false}, segment)+  return path2.fromPoints({close: false}, segment)
 } }
  
-let paths = outlines.segments.map((segment) => segmentToPath(segment))+const paths = outlines.segments.map((segment) => segmentToPath(segment))
 </code> </code>
  
Line 48: Line 52:
  
 <code javascript> <code javascript>
-let outlines = vectorText('JSCAD'); +const { vectorText } = require('@jscad/modeling').text 
-let outlines = vectorText({ yOffset: -90, height: 10, extrudeOffset: 2, input: 'JSCAD is awesome!' }); + 
-let outlines = vectorText({ height: 25, align: 'right', lineSpacing: 2.2, extrudeOffset: 2 }, 'JSCAD\nRocks!!');+const outlines = vectorText('JSCAD'); 
 +const outlines = vectorText({ yOffset: -90, height: 10, extrudeOffset: 2, input: 'JSCAD is awesome!' }); 
 +const outlines = vectorText({ height: 25, align: 'right', lineSpacing: 2.2, extrudeOffset: 2 }, 'JSCAD\nRocks!!'); 
 +</code> 
 + 
 +Again, you will have to convert the output of `vectorText` into a list of paths before it becomes actually useful: 
 + 
 +<code javascript> 
 +const { path2 } = require('@jscad/modeling').geometries 
 + 
 +const segmentToPath = (segment) => { 
 +  return path2.fromPoints({close: false}, segment) 
 +
 + 
 +const paths = outlines.map((segment) => segmentToPath(segment))
 </code> </code>
  
Line 75: Line 93:
  
 const main = () => { const main = () => {
-  let outlines = vectorText({height: 42, align: 'right', font: myfont}, 'JSCAD\nROCKS!!'+  const outlines = vectorText({height: 42, align: 'right', font: myfont}, 'JSCAD\nROCKS!!'
-  let paths = outlines.map((segment) => segmentToPath(segment))+  const paths = outlines.map((segment) => segmentToPath(segment))
   return paths   return paths
 } }
Line 83: Line 101:
 </code> </code>
  
-**//Special Note: These fonts are NOT TrueType fonts. There are libraries that create outlines from TrueType (and other) fonts.//**+**//Special Note: These fonts are 'single-line' fonts, NOT TrueType fonts. There are libraries that create outlines from TrueType (and other) fonts.//**