Activate your free membership today | Log-in

Wednesday, April 11th, 2007

Prototype Graphic Framework

Category: JavaScript, Library

<>p>Sebastien Gruhier has created useful libraries such as the Prototype Window component.

Now, he has created the Prototype Graphic Framework (PGF) - a framework based on prototype to display vectorial shapes inside a web browser.

The framework has various renderers that sit on top of SVG, Canvas, and VML, so you can plug and play (although canvas support is limited right now).

JAVASCRIPT:
  1.  
  2. // Create an SVG renderer
  3. var renderer = new SVGRenderer("whiteboard");
  4.  
  5. // Create a rectangle with some attributes like color and bounds
  6. var rect = new Graphic.Rectangle(renderer);
  7. rect.setFill({r: 255, g: 0, b: 0, a: 128});
  8. rect.setStroke({r: 255, g: 255, b: 0, a: 128, w: 5});
  9. rect.setBounds(10, 20, 200, 300);
  10. rect.setRoundCorner(10, 10);
  11. rect.translate(10, 20);
  12. rect.rotate(30);
  13.  
  14. renderer.add(rect);
  15.  

Related Content:

Posted by Dion Almaer at 8:44 am
8 Comments

+++--
3.6 rating from 41 votes

8 Comments »

Comments feed TrackBack URI

Great job!

Comment by efattal — April 11, 2007

Very cool!

Comment by Rey Bango — April 11, 2007

I will definitely include this in my future projects.

Comment by Dragan — April 11, 2007

Great. I think this framework could be a milestone of web application’s developing

Comment by Daniel — April 11, 2007

It is great! Thanks for your working.

Comment by Avenger Bevis — April 12, 2007

Isn’t this done already several time?
dojo.gfx
http://www.dojotoolkit.org
cumulate draw:
http://www.cumulatelabs.com

Comment by sartre — April 13, 2007

Very cool! The SVG version works great, but the Canvas one is broken (as author says, it’s not his priority). I love the select demo. Mmm!

Comment by Leland Scott — April 14, 2007

Very cool! The SVG version works great, but the Canvas one is broken (as author says, it’s not his priority). I love the select demo. Mmm!

Comment by Leland Scott — April 14, 2007

Leave a comment

You must be logged in to post a comment.