<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Designing with text]]></title><description><![CDATA[<p dir="auto">Hello, I'm currently starting to work with text to create 2d effects. I thought I could isolate each letter then translate/rotate/scale it as needed, but apparently the function that makes the paths from the vectorText data doesn't return one path by letter but sometimes more. Apparently I need to change my code and get the path for each letter separately.</p>
<p dir="auto">Here's what I did :</p>
<pre><code>function main() {
  const jscad = require('@jscad/modeling')
  const { vectorText } = jscad.text
  const { geom2, path2 } = jscad.geometries
  const { align, rotateX, rotateZ } = jscad.transforms
  const { arc } = jscad.primitives
  const { colorize } = jscad.colors
 
  function texte (ch) {
    const outlines = vectorText(ch);
    const segmentToPath = (segment) =&gt; {
      return path2.fromPoints({close: false}, segment)
    }
    const paths = outlines.map((segment) =&gt; segmentToPath(segment))
    return paths
  }
  
  const t1 = texte("012345");
  const t2 = align({grouped:true}, t1);
  const nbL = t2.length;
  
  let t3 = [];
  t2.forEach((p, index) =&gt; {
    t3.push(rotateZ(index/nbL, p));
  });
  
  console.log(t3)
  
  return t3
}

module.exports = { main }
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1677492986361-capture-d-%C3%A9cran-du-2023-02-27-11-03-07.png" alt="Capture d’écran du 2023-02-27 11-03-07.png" class=" img-fluid img-markdown" /><br />
On the snapshot the 4 is apparently made of 2 paths, and the console output shows that there are 7 paths for 6 characters.</p>
<p dir="auto">What I would like to do is to have curve that could be handled by parameters, and then the letters will follow that curves, first curve for the placement, second for the scale, I hope that it will be possible using Bezier.</p>
]]></description><link>https://openjscad.nodebb.com/topic/398/designing-with-text</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 17:51:40 GMT</lastBuildDate><atom:link href="https://openjscad.nodebb.com/topic/398.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 27 Feb 2023 10:24:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Designing with text on Wed, 01 Mar 2023 08:22:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hrgdavor" aria-label="Profile: hrgdavor">@<bdi>hrgdavor</bdi></a> That would be great. For the moment I'm certainly going to try to do the same thing using svg into vanilla js.</p>
]]></description><link>https://openjscad.nodebb.com/post/1308</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1308</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Wed, 01 Mar 2023 08:22:14 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Tue, 28 Feb 2023 16:56:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> I have on my list adding better support for ttf fonts, google fonts, but it will be some time until I get to it. There is also a bug in JSCAD bezier svg handling, that caused some of fonts to display differently than originally designed.</p>
]]></description><link>https://openjscad.nodebb.com/post/1306</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1306</guid><dc:creator><![CDATA[hrgdavor]]></dc:creator><pubDate>Tue, 28 Feb 2023 16:56:36 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Tue, 28 Feb 2023 16:44:43 GMT]]></title><description><![CDATA[<p dir="auto">I didn't take care that text vectors are only line segments, so they won't produce nice designs when curves will be needed. So I will try at one moment of this project to use curves for my text output, but it's still early for that.</p>
]]></description><link>https://openjscad.nodebb.com/post/1305</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1305</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Tue, 28 Feb 2023 16:44:43 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 22:24:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/z3dev" aria-label="Profile: z3dev">@<bdi>z3dev</bdi></a> Thank you for the link to the project, looks promising.</p>
]]></description><link>https://openjscad.nodebb.com/post/1304</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1304</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Mon, 27 Feb 2023 22:24:33 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 21:35:28 GMT]]></title><description><![CDATA[<p dir="auto">For those looking for support for fonts, there's a little library that can be used in projects.</p>
<p dir="auto"><a href="https://github.com/jscad-community/jscad-text" rel="nofollow ugc">https://github.com/jscad-community/jscad-text</a></p>
]]></description><link>https://openjscad.nodebb.com/post/1303</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1303</guid><dc:creator><![CDATA[z3dev]]></dc:creator><pubDate>Mon, 27 Feb 2023 21:35:28 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 18:01:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hrgdavor" aria-label="Profile: hrgdavor">@<bdi>hrgdavor</bdi></a> I'm trying to create small scripts to easily create design from text, just like those you can do with Inkscape using path effects, or the very old WordArt from MS Word. The main weakness of using JSCAD for that is that for the moment it is not possible to choose a font that is installed into the pc as .ttf, I'm starting to look at this file format to see it I can use it directly to use its vectors.</p>
]]></description><link>https://openjscad.nodebb.com/post/1302</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1302</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Mon, 27 Feb 2023 18:01:22 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 17:24:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> VectorChar seems to work better, so you have a solution <img src="https://openjscad.nodebb.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=4619dfc2edd" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /> Please share results of what you are aiming to create.</p>
]]></description><link>https://openjscad.nodebb.com/post/1301</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1301</guid><dc:creator><![CDATA[hrgdavor]]></dc:creator><pubDate>Mon, 27 Feb 2023 17:24:13 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 16:46:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hrgdavor" aria-label="Profile: hrgdavor">@<bdi>hrgdavor</bdi></a> I think I understand your statement, first rotate then translate, but for this example I didn't start from a curve, so I didn't have translation coordinates.</p>
]]></description><link>https://openjscad.nodebb.com/post/1300</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1300</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Mon, 27 Feb 2023 16:46:48 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 15:39:48 GMT]]></title><description><![CDATA[<p dir="auto">Here is the result using VectorChar instead of VectorText</p>
<pre><code>function main() {
  const jscad = require('@jscad/modeling')
  const { vectorText, vectorChar } = jscad.text
  const { geom2, path2 } = jscad.geometries
  const { align, translateX, rotateZ, center } = jscad.transforms
  const { arc } = jscad.primitives
  const { colorize } = jscad.colors
  const { measureAggregateBoundingBox } = jscad.measurements
  //const { union } = jscad.booleans
 
  function lettre (ch) {
    const outlines = vectorChar(ch);
    const segmentToPath = (segment) =&gt; {
      return path2.fromPoints({close: false}, segment)
    }
    const paths = outlines.segments.map((segment) =&gt; segmentToPath(segment))
    return paths
  }
  
  let t = "MAKE IT REAL";
  let t1 = t.split("");
  let t2 = [];

  let x = 0;
  let nbL = 0;
  t1.forEach((l, index) =&gt; {
    if (l == ' ') {
      x += 10;
    }
    else {
      nbL++;
      let L = lettre(l);
      let b = measureAggregateBoundingBox(L);

      if (index == 0) {
        t2.push(L);
        x = b[0][1];
      }
      else {
        let b = measureAggregateBoundingBox(t2);
        x+= b[1][1]
        t2.push(translateX(x, L));
      }
    }
  });
  
  let t3 = [];
  t2.forEach((p, index) =&gt; {
    t3.push(rotateZ(Math.PI*index/(nbL-1), p));
  });
  
  return [
    t2
    , colorize([0,1,0], t3)
  ];
}

module.exports = { main }
  
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1677512384940-capture-d-%C3%A9cran-du-2023-02-27-16-39-18.png" alt="Capture d’écran du 2023-02-27 16-39-18.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Now I can start using control curves.</p>
]]></description><link>https://openjscad.nodebb.com/post/1299</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1299</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Mon, 27 Feb 2023 15:39:48 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 15:17:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hrgdavor" aria-label="Profile: hrgdavor">@<bdi>hrgdavor</bdi></a> Thank you, the only problem seems to be the fact that a character can have more than one segment and there is no way to know it with VectorText, so I'm doing it with VectorChar, almost done. About bezier, I hope that bezierAt() and tangentAt() could give the data I need, I prefer to avoid using librairies whenever possible.</p>
]]></description><link>https://openjscad.nodebb.com/post/1298</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1298</guid><dc:creator><![CDATA[gilboonet]]></dc:creator><pubDate>Mon, 27 Feb 2023 15:17:34 GMT</pubDate></item><item><title><![CDATA[Reply to Designing with text on Mon, 27 Feb 2023 14:45:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gilboonet" aria-label="Profile: gilboonet">@<bdi>gilboonet</bdi></a> taking a quick glance at the screenshot, you would not have issues with "4" if the sequence of transformations is rotation first, then translation. Using bezier is ok, but I am not sure there is anything to directly get value you need from bezier control points. But there are few bezier libs in JS that you could use to do whatever you might need.</p>
<p dir="auto">like <a href="https://pomax.github.io/bezierjs/" rel="nofollow ugc">https://pomax.github.io/bezierjs/</a></p>
]]></description><link>https://openjscad.nodebb.com/post/1297</link><guid isPermaLink="true">https://openjscad.nodebb.com/post/1297</guid><dc:creator><![CDATA[hrgdavor]]></dc:creator><pubDate>Mon, 27 Feb 2023 14:45:19 GMT</pubDate></item></channel></rss>