Code Monkey home page Code Monkey logo

raphael-zoom's Introduction

Raphaël Zoom plugin - 0.0.4

What is it?

An extension to the Raphael Vector Library.
It enables Raphael to zoom the whole paper, stroke widths included.

The zoom functionality is non destructive. This means that you can set the zoom back to 1 (100%) at any time.

Usage

Basic usage:

Create a paper of 800 × 500 at 10, 10 and initialize it's zoom

var paper = Raphael(10, 10, 800, 500).initZoom();

Add a circle and initialize it's zoom

var circle = this.paper.circle(150, 120, 100).initZoom();
circle.setAttr({
  fill:           "#83B100",
  stroke:         "#333",
  "stroke-width": 10
});

Set the paper zoom to 50%

paper.setZoom(0.5);

When using a zoomed paper the standard "attr" method should be replaced with "setAttr". The raphael.zoom plugin will than take care of zoomed stroke widths and text elements.

Example of setting attributes with the zoom plugin:

circle.setAttr("stroke-width", 2);

or

circle.setAttr({ "stroke-width": 2 });

Important: Using element.attr instead of element.setAttr with a zoomed paper, the shape will be transformed in the current zoom value and not the real value!

Also element.translate shoud be replaced with element.setTranslation. Like

Translate element

circle.setTranslation(20, 30);

Dependencies

To-do

  • animated zoom

raphael-zoom's People

Watchers

James Cloos avatar ruanbl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.