Skip to main content
Home

Built and signed on GitHub Actions

A web-native renderer for the `carefree-board` project.

This package works with Browsers
This package works with Browsers
JSR Score
70%
Published
a year ago (0.0.6)

cfb-web

This module implements a web-native renderer for the carefree-board project. It will render the board in a web browser, by transpiling the data structures into dom elements.

Quick Start

We've provided a convenient deno task to run a demo for cfb-web:

deno task run:web

This task simply executes the run_web.ts script, which will bundle cfb-web and then serve the demo's index.html file.

The procedure mentioned above is easy to integrate into deno deploy - that's why I'm able to host it at https://cfb-web.deno.dev/!

Usage

cfb-web should be used in a browser runtime as its name suggests. It implements the following layers for the cfb project:

  • WebRenderer: Structured the dom hierarchy for WebRenderNode to be rendered.
  • WebRenderNode: Concrete implementations that can transpile nodedom elements.
  • PointerHandler: Handles pointer events from the browser.
import {
  EventSystem,
  Graph,
  makeSingleNode,
  Matrix2D,
  World,
} from "@carefree0910/cfb-core";
import * as web from "@carefree0910/cfb-web";

const node = makeSingleNode({
  type: "rectangle",
  uuid: "0",
  alias: "rect",
  transform: Matrix2D.from(50, 50, 50, 50),
  params: {
    fillParamsList: [{ type: "color", color: "#ff0000", opacity: 0.25 }],
  },
  z: 0,
});
const graph = Graph.fromNodes([node]);
const renderer = new web.WebRenderer(graph);
const pointerHandler = new web.PointerHandler();
const eventSystem = new EventSystem([pointerHandler]);
const world = new World({ renderer, eventSystem });
world.start().then(() => console.log(world));
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.