@gogrillion/matrix2html

1.0.0 • Public • Published

matrix2html

Pretty print matrices in various HTML formats

Features

  • Tables

Usage

.toTable( data: array )

# matrix2html.toTable(data[, rowLength])

Compile an HTML table from array values in data. If rowLength is provided, one dimensional arrays will wrap at rowLength items. This is meant to be useful for situations like WebGL where matrices which are commonly stored as a Float32Array of 16 elements.

Examples

Generate a table for a mat4 WebGL Matrix

    let matrix = mat4.identity();
    console.log( matrix2html.toTable(matrix, 4) ); // wrap rows at 4 elements

Console's output will be

<table>
  <tr>
    <td>1</td>
    <td>0</td>
    <td>0</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>1</td>
    <td>0</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>1</td>
    <td>0</td>
  </tr>
  <tr>
    <td>0</td>
    <td>0</td>
    <td>0</td>
    <td>1</td>
  </tr>
</table>

-- or visually --

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

License

Copyright (C) 2018 GoGrillion

gl-graph is licensed under the ISC License

Package Sidebar

Install

npm i @gogrillion/matrix2html

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

3.25 kB

Total Files

4

Last publish

Collaborators

  • gogrillion