JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Access to the (fake) FileSystem in WEB Applications

    Development Discussions
    1
    1
    102
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • z3dev
      z3dev last edited by z3dev

      Here's something for those wanting 'more' from JSCAD designs.

      The 'fs' (File System) module is available to designs, both NODE.js and WEB versions.

      const fs = require('fs')
      

      The WEB versions is not 100% compatible, but it can provide access to other data. For example, fonts can be added to the contents of a JSCAD project. And the font can be read via the 'fs' module.

      const data = fs.readFileSync('project_text/Osaka.ttf')
      

      And used with the jscad-text project, outlines of characters can be created very easily.

      const {primitives} = require('@jscad/modeling')
      
      const { loadFontFromData, textToPaths } = require('./jscad-text')
      
      const fs = require('fs')
      
      const main = (params) => {
        const data = fs.readFileSync('project_text/Osaka.ttf')
      
        const font = loadFontFromData(data)
      
        const paths = textToPaths({font, segments: 144}, 'JSCAD! 大好きです!')
      
        return paths
      }
      
      module.exports = { main }
      

      5.png

      1 Reply Last reply Reply Quote 3
      • First post
        Last post
      Powered by NodeBB | Contributors