text-to-triangles

0.0.1 • Public • Published

text-to-triangles

convert text string to triangles, for nodejs

Installation

npm i text-to-triangles

Usage

here we render a random text scene with ascii-raytracer

var ttt = require('text-to-triangles');
var res = ttt.renderTextAsTrianglesAndLines("H?@終極鴨醬");
var mesh = res.tris;
//mesh.push(...res.linesTris);

// res = {
//     tris: meshTrisRemapped, //triangles raw
//     lines: lines2, //edge line segments
//     linesTris: linesTris  //triangles representing edge-beams
// }

var config = {
    tris:mesh,
    triangleColors: mesh.map(t=>[Math.random(),Math.random(),Math.random()]),
    resolution: 64,
    aspectRatio: 1.0,
    mouseControl:true,
    cameraPos: [22,29,-12],
    cameraRot: [2.37,-4.5]
}

var art = require('ascii-raytracer');
art.runScene(config);

//update the triangles in the scene...
var t0=Date.now();
setInterval(function(){
    var res = ttt.renderTextAsTrianglesAndLines((Date.now()-t0)+"");
    var mesh = res.tris;
    art.updateDfForTris(mesh);
},1000);

img1

img2

See Also

stonks

Readme

Keywords

Package Sidebar

Install

npm i text-to-triangles

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

22.2 kB

Total Files

6

Last publish

Collaborators

  • stonkpunk