Raphaël: JavaScript Vector Graphics Library

2.3.0 · abandoned · verified Sun Apr 19

Raphaël is a JavaScript library designed to simplify working with vector graphics on the web. It uses SVG for modern browsers (Firefox, Safari, Chrome, Opera) and VML for older Internet Explorer, providing a consistent API across different rendering engines. The current stable version is 2.3.0, released in 2018. The library is largely considered feature-complete but is no longer actively maintained, with the last code changes dating back several years. Key differentiators include its cross-browser compatibility, especially its VML fallback for legacy IE, and its relatively small footprint. Development is dormant, with releases historically occurring sporadically as PRs were gathered and tested. It relies on the `eve` library for custom event handling.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Raphaël canvas, draw basic shapes like circles and rectangles, and add text to the canvas using a simple HTML file with a CDN import.

<html>
<head>
  <title>Raphaël Quickstart</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js"></script>
</head>
<body>
  <div id="holder"></div>
  <script>
    window.onload = function () {
      // Create a canvas with a width of 320px and a height of 200px
      // and place it in the element with the ID 'holder'.
      var paper = Raphael(document.getElementById('holder'), 320, 200);

      // Draw a circle at x=50, y=50 with a radius of 40
      var circle = paper.circle(50, 50, 40);
      circle.attr({
        fill: '#f00',
        stroke: '#fff',
        'stroke-width': 5
      });

      // Draw a rectangle at x=100, y=20 with width=100, height=60
      var rect = paper.rect(100, 20, 100, 60);
      rect.attr({
        fill: '#0f0',
        stroke: '#000',
        'stroke-width': 2,
        opacity: 0.7
      });

      // Add text
      var text = paper.text(250, 100, "Hello Raphaël");
      text.attr({
        font: '20px Arial',
        fill: '#00f'
      });
    };
  </script>
</body>
</html>

view raw JSON →