39
RAPHAËL AND YOU Trotter Cashion RubyNation 2011

Raphaël and You

Embed Size (px)

DESCRIPTION

This is the Raphaël talk that I gave to RubyNation on April 1, 2011.

Citation preview

Page 1: Raphaël and You

RAPHAËL AND YOUTrotter Cashion

RubyNation 2011

Page 2: Raphaël and You

THIS IS ON THE INTERNET!

•Slideshare - http://www.slideshare.net/trotter/raphal-rubynation

•My Bloggy Blog - http://trottercashion.com

Page 3: Raphaël and You

IT’S ME!

Page 4: Raphaël and You

CO-FOUNDER

http://mashion.net

Page 6: Raphaël and You

http://gems.github.com/octocat.png

github.com/trotter

Page 7: Raphaël and You
Page 9: Raphaël and You

http://images.coveralia.com/audio/m/Men_At_Work-Super_Hits-Frontal.jpg

COMES FROM A LAND DOWN UNDER

Page 11: Raphaël and You

“RAPHAËL IS A SMALL JAVASCRIPT LIBRARY THAT SHOULD SIMPLIFY

YOUR WORK WITH VECTOR GRAPHICS ON THE WEB.”

http://raphaeljs.com/

Page 14: Raphaël and You

SVG VML

VECTOR GRAPHICS

Throws never ending deprecation parties.

Page 15: Raphaël and You

SMALL - 60KB*

0

30

60

90

120

Socket.IO Raphaël jQuery YUI

* 20Kb with GZIP

Page 16: Raphaël and You

SIMPLE

r = Raphael("somediv", 100, 100);rect = r.rect(20, 20, 50, 50);

setInterval(function () { rect.rotate(1);}, 10);

Page 17: Raphaël and You

THE COMPETITION

The Canvas Part

Page 18: Raphaël and You

FOR YOUR MANAGER

Raphaël Canvas Flash

Tiny Download

Fast

Open

All Browsers

Mobile

Shapes

x x

x x ?

x x

x x

? x

x x

Page 19: Raphaël and You

http://www.comicvsaudience.net/images/dom.jpg

Everything is a node and can be treated like a normal DOM

element.

Page 20: Raphaël and You

Yes... this means binding with jQuery is fair game.

Page 22: Raphaël and You

NEW YORK TIMES

Page 23: Raphaël and You

RECTANGLES, HOW DO THEY WORK?

This one

r = Raphael("jobs-graph", 640, 120);

rect = r.rect(481, 30, 7, 90);rect.attr({stroke: "none",           fill: "#446093"});

Page 24: Raphaël and You

TEXT, HOW DO THEY WORK?

Hi Bill!

r = Raphael("jobs-graph", 640, 140);

text = r.text(490, 130, "CLINTON");text.attr({font: "8px Courier",           fill: "#9c9c9b"});

Page 25: Raphaël and You

THE INVISIBLE HOVER

Only the black line for now

hover = r.rect(481, 0, 8, 120);hover.attr({stroke: "none",            "fill": "#fff",            "fill-opacity": 0});

$(hover.node).hover(function () {  rect.attr({"stroke": "#000"});}, function () {  rect.attr({"stroke": "none"});});

Page 26: Raphaël and You

EXPECT A BLOG POST ON CALLOUTS

http://trottercashion.com

The Callout

Page 27: Raphaël and You

WALL STREET JOURNAL

Page 28: Raphaël and You

STATES ARE PATHS

r = Raphael("usa", 637, 432);path = r.path("M352,226L401,224L403,227L399,232L407,231L408,233L404,235L406,236L405,237L405,238L404,238L404,240L403,239L402,240L403,240L402,242L404,244L401,246L401,248L399,248L400,250L399,249L398,250L399,251L398,251L398,255L397,256L396,256L395,258L394,257L396,259L394,259L395,260L394,262L393,261L394,264L392,265L394,266L391,266L392,267L391,267L391,269L393,269L392,270L393,269L392,270L393,272L394,271L393,273L392,274L392,275L358,276L358,269L354,269L353,268L353,242L350,226L352,226Z");path.attr({fill: "#3081c2",           stroke: "#828282"});

Page 29: Raphaël and You

STATES ARE PATHS

r = Raphael("usa", 637, 432);path = r.path( "M352,226 L401,224 L403,227 Z");path.attr({fill: "#3081c2",           stroke: "#828282"});

I grew up here!

Page 30: Raphaël and You

MAKE IT BIGGER!*

path.animate({scale: [2, 2]}, 1000);

*WSJ actually does much more crazy than this

Page 31: Raphaël and You

NISSAN

Page 32: Raphaël and You

IMAGES, HOW DO THEY WORK?

r = Raphael("nissan", 1264, 568);r.image( "/images/learn/nodes/6/6i1.png", 672, 301, 48, 48);

This one

Page 33: Raphaël and You

THE IMAGE FROM BEFORE...

This could have been a circle!

circle.attr({ fill: "270-#58a0ff-#5fe2fe",  stroke: "none"});

Page 34: Raphaël and You

CIRCLES, HOW DO THEY WORK?

circle = r.circle(213, 244, 5);circle.attr({stroke: "#a2c9e3",             "stroke-width": 4,             "stroke-opacity": 0.6});

Transparency for teh win!

Page 35: Raphaël and You

HOW DO WE FIX THE LINE?

Transparency reveals we lose!

rad = 30 * Math.PI / 180;startX = Math.cos(rad) * 7 + 213;startY = Math.sin(rad) * 7 + 244;path = ["M", startX, startY, "l 300,100"];r.path(path);

Page 36: Raphaël and You

WHIPLASH!*

circle.click(function () {  circle.animate({cx: 513,                  cy: 344},                 1000,                 "elastic");});

*Nissan actually swaps the circle out for an animated gif, which is then animated w/ Raphaël.

Page 37: Raphaël and You

RAPHAËL LINKS

•Raphaël - http://raphaeljs.com

•Testing - http://bit.ly/raphael-testing

•More this month... - http://trottercashion.com

Page 38: Raphaël and You

EXAMPLE SITES

•New York Times - http://nyti.ms/eoxtC6

•Wall Street Journal - http://on.wsj.com/hMsmqW

•Nissan - http://bit.ly/fJ2zPb

Page 39: Raphaël and You

THANK YOU!