Skip to content

sjs/ripscripjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RIPscrip Viewer

A lightweight JavaScript RIPscrip renderer with a reusable API, a standalone viewer, examples, and an optional PHP URL proxy.

Files

  • ripscrip.js — reusable JavaScript API
  • ripscrip-viewer.html — standalone browser UI using ripscrip.js
  • ripscrip-example.html — programmatic usage example using ripscrip.js
  • rip-proxy.php — optional same-origin proxy for remote RIP URLs
  • README.md — this file

Standalone viewer

Open:

ripscrip-viewer.html

The standalone viewer uses ripscrip.js for all RIP rendering. It provides:

  • local file upload
  • remote URL loading
  • optional proxy endpoint
  • source textarea
  • canvas scale control
  • PNG export

Programmatic usage

<div id="rip-target"></div>

<script src="ripscrip.js"></script>
<script>
    const viewer = new RipScripViewer("#rip-target", {
        scale: 2
    });

    viewer.renderString("!|*|c0F|@0505Hello RIPscrip|c0C|C50280F");
</script>

Render from a URL

<div id="rip-target"></div>

<script src="ripscrip.js"></script>
<script>
    const viewer = new RipScripViewer("#rip-target", {
        scale: 2,
        proxy: "/rip-proxy.php?url="
    });

    async function renderRemote() {
        await viewer.renderUrl("https://files.artpacks.org/2005/sadist05.zip/k%21triump.rip");
    }

    renderRemote().catch(console.error);
</script>

API

Constructor

const viewer = new RipScripViewer(target, options);

Options:

  • target — DOM element or CSS selector
  • scale — display scale multiplier, default 1
  • proxy — optional proxy endpoint for remote URL loading
  • append — if false, clears target before inserting the canvas
  • className — class applied to the generated canvas

Methods

viewer.renderString(ripText);
await viewer.renderUrl(url);
viewer.clear();
viewer.setScale(3);
viewer.toDataURL();

renderString() and renderUrl() return:

{
    canvas,
    commands,
    unsupported,
    skipped,
    messages
}

CORS and URL loading

Direct browser fetches to third-party RIP URLs usually fail unless the remote server sends CORS headers.

Use the included rip-proxy.php on the same origin as your page:

proxy: "/rip-proxy.php?url="

Notes

This renderer supports a practical subset of RIPscrip commands, including common drawing primitives used by legacy RIP art files. It is intended as a lightweight browser renderer rather than a full RIPTerm clone.

About

A lightweight JavaScript RIPscrip renderer with a reusable API, a standalone viewer, examples, and an optional PHP URL proxy.

Topics

Resources

Stars

Watchers

Forks

Contributors