npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mandelbrot-viewer

v1.0.2

Published

A Mandelbrot set viewer for your browser

Downloads

18

Readme

mandelbrot-viewer-js

Explore the Mandelbrot set using this HTML5 + Javascript viewer.

Check out the live demo!

Features

  • Click & drag zooming.
  • 'Checkered' and 'Checkered B&W' color schemes.
  • Control the render using the 'Cancel' and 'Repaint' buttons.
  • Zoom-in and zoom-out buttons.
  • 'Reset' button to return to initial settings.

Quick start

Options to add mandelbrot-viewer-js to your project:

  • Install with npm: npm install mandelbrot-viewer-js
  • Download the latest release
  • Clone the repo: git clone https://github.com/llop/mandelbrot-viewer-js.git

Basic use

Include 'mandelbrot-viewer.js' in your HTML file.

<script src='mandelbrot-viewer.js'></script>

Add the viewer's HTML elements:

<canvas id='mandelbrot-canvas' width='1000' height='562'>Your browser does not support canvas.</canvas>
<div id='mandelbrot-params'>
  Center @ (, i); &nbsp; Width: ; &nbsp; Height:
</div>
<div>
  <label for='color-select'>Color scheme:</label>
  <select id='color-select' name='color-select'>
    <option value='0' selected>Checkered</option>
    <option value='1'>Checkered B&amp;W</option>
  </select>
  <button id='repaint-btn' type='button'>Repaint</button>
  <button id='zoom-in-btn' type='button'>Zoom in</button>
  <button id='zoom-out-btn' type='button'>Zoom out</button>
  <button id='reset-btn' type='button'>Reset</button>
  <button id='cancel-btn' type='button'>Cancel</button>
</div>

A circle of radius 2 and centered at (0, 0i) is initially fitted in the canvas regardless of its dimensions. All elements are, of course, customizable via CSS.

Start the viewer with the following code:

<script>
window.addEventListener('load', event => {
  const canvas = document.getElementById('mandelbrot-canvas');
  const mandelbrot = new Mandelbrot(canvas);
  const mandelbrotControls = new MandelbrotControls(mandelbrot, {
    colorSelect: document.getElementById('color-select'),
    repaintButton: document.getElementById('repaint-btn'),
    resetButton: document.getElementById('reset-btn'),
    cancelButton: document.getElementById('cancel-btn'),
    zoomInButton: document.getElementById('zoom-in-btn'),
    zoomOutButton: document.getElementById('zoom-out-btn'),
    paramsText: document.getElementById('mandelbrot-params')
  });
  mandelbrotControls.start();
});
</script>

A working example can be found in index.html.

Advanced use

Specify the coloring function for the Mandelbrot:

const mandelbrot = new Mandelbrot(canvas, {
  colorFuncId: Mandelbrot.COLOR_CHECKERED
});

Available options are Mandelbrot.COLOR_CHECKERED and Mandelbrot.COLOR_CHECKERED_BW.

Events are dispatched whenever a scan starts or ends. To add listeners:

// Attach listeners before calling mandelbrotControls.start()
mandelbrotControls.on('scan-start', event => {
  console.log('scan-start', event);
});
mandelbrotControls.on('scan-end', event => {
  console.log('scan-end', event);
});
mandelbrotControls.start();

License

mandelbrot-viewer-js is released under the MIT License. See LICENSE for details.