CINXE.COM

An Intro to Raphaël - Raphaël

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="https://gmpg.org/xfn/11"> <meta name='robots' content='index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1' /> <!-- This site is optimized with the Yoast SEO plugin v23.7 - https://yoast.com/wordpress/plugins/seo/ --> <title>An Intro to Raphaël - Rapha&euml;l</title> <link rel="canonical" href="http://raphaeljs.com/" /> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="website" /> <meta property="og:title" content="An Intro to Raphaël - Rapha&euml;l" /> <meta property="og:description" content="The most popular coding language for the web is javascript; so much so that since the advent of HTML5, it has now been officially accepted as the default standard. Javascript has moved beyond a smaller client-side browser-based language to become integrated not just for front-end design, but also for back-end server-side development. As a result [&hellip;]" /> <meta property="og:url" content="http://raphaeljs.com/" /> <meta property="og:site_name" content="Rapha&euml;l" /> <meta property="article:modified_time" content="2019-03-03T21:33:48+00:00" /> <meta property="og:image" content="http://raphaeljs.com/wp-content/uploads/2018/09/circle.png" /> <meta name="twitter:card" content="summary_large_image" /> <script type="application/ld+json" class="yoast-schema-graph">{"@context":"https://schema.org","@graph":[{"@type":"WebPage","@id":"http://raphaeljs.com/","url":"http://raphaeljs.com/","name":"An Intro to Raphaël - Rapha&euml;l","isPartOf":{"@id":"http://raphaeljs.com/#website"},"primaryImageOfPage":{"@id":"http://raphaeljs.com/#primaryimage"},"image":{"@id":"http://raphaeljs.com/#primaryimage"},"thumbnailUrl":"http://raphaeljs.com/wp-content/uploads/2018/09/circle.png","datePublished":"2018-09-23T16:49:09+00:00","dateModified":"2019-03-03T21:33:48+00:00","breadcrumb":{"@id":"http://raphaeljs.com/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["http://raphaeljs.com/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"http://raphaeljs.com/#primaryimage","url":"http://raphaeljs.com/wp-content/uploads/2018/09/circle.png","contentUrl":"http://raphaeljs.com/wp-content/uploads/2018/09/circle.png"},{"@type":"BreadcrumbList","@id":"http://raphaeljs.com/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home"}]},{"@type":"WebSite","@id":"http://raphaeljs.com/#website","url":"http://raphaeljs.com/","name":"Rapha&euml;l","description":"JavaScript Library","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http://raphaeljs.com/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"}]}</script> <!-- / Yoast SEO plugin. --> <link rel="alternate" type="application/rss+xml" title="Rapha&euml;l &raquo; Feed" href="http://raphaeljs.com/feed" /> <link rel="alternate" type="application/rss+xml" title="Rapha&euml;l &raquo; Comments Feed" href="http://raphaeljs.com/comments/feed" /> <script type="text/javascript"> /* <![CDATA[ */ window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/15.0.3\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/15.0.3\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/raphaeljs.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=6.6.2"}}; /*! This file is auto-generated */ !function(i,n){var o,s,e;function c(e){try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(o,JSON.stringify(t))}catch(e){}}function p(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data),r=(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0),new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data));return t.every(function(e,t){return e===r[t]})}function u(e,t,n){switch(t){case"flag":return n(e,"\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f","\ud83c\udff3\ufe0f\u200b\u26a7\ufe0f")?!1:!n(e,"\ud83c\uddfa\ud83c\uddf3","\ud83c\uddfa\u200b\ud83c\uddf3")&&!n(e,"\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f","\ud83c\udff4\u200b\udb40\udc67\u200b\udb40\udc62\u200b\udb40\udc65\u200b\udb40\udc6e\u200b\udb40\udc67\u200b\udb40\udc7f");case"emoji":return!n(e,"\ud83d\udc26\u200d\u2b1b","\ud83d\udc26\u200b\u2b1b")}return!1}function f(e,t,n){var r="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?new OffscreenCanvas(300,150):i.createElement("canvas"),a=r.getContext("2d",{willReadFrequently:!0}),o=(a.textBaseline="top",a.font="600 32px Arial",{});return e.forEach(function(e){o[e]=t(a,e,n)}),o}function t(e){var t=i.createElement("script");t.src=e,t.defer=!0,i.head.appendChild(t)}"undefined"!=typeof Promise&&(o="wpEmojiSettingsSupports",s=["flag","emoji"],n.supports={everything:!0,everythingExceptFlag:!0},e=new Promise(function(e){i.addEventListener("DOMContentLoaded",e,{once:!0})}),new Promise(function(t){var n=function(){try{var e=JSON.parse(sessionStorage.getItem(o));if("object"==typeof e&&"number"==typeof e.timestamp&&(new Date).valueOf()<e.timestamp+604800&&"object"==typeof e.supportTests)return e.supportTests}catch(e){}return null}();if(!n){if("undefined"!=typeof Worker&&"undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof URL&&URL.createObjectURL&&"undefined"!=typeof Blob)try{var e="postMessage("+f.toString()+"("+[JSON.stringify(s),u.toString(),p.toString()].join(",")+"));",r=new Blob([e],{type:"text/javascript"}),a=new Worker(URL.createObjectURL(r),{name:"wpTestEmojiSupports"});return void(a.onmessage=function(e){c(n=e.data),a.terminate(),t(n)})}catch(e){}c(n=f(s,u,p))}t(n)}).then(function(e){for(var t in e)n.supports[t]=e[t],n.supports.everything=n.supports.everything&&n.supports[t],"flag"!==t&&(n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&n.supports[t]);n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&!n.supports.flag,n.DOMReady=!1,n.readyCallback=function(){n.DOMReady=!0}}).then(function(){return e}).then(function(){var e;n.supports.everything||(n.readyCallback(),(e=n.source||{}).concatemoji?t(e.concatemoji):e.wpemoji&&e.twemoji&&(t(e.twemoji),t(e.wpemoji)))}))}((window,document),window._wpemojiSettings); /* ]]> */ </script> <style id='wp-emoji-styles-inline-css' type='text/css'> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 0.07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style> <link rel='stylesheet' id='wp-block-library-css' href='http://raphaeljs.com/wp-includes/css/dist/block-library/style.min.css?ver=6.6.2' type='text/css' media='all' /> <style id='classic-theme-styles-inline-css' type='text/css'> /*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} </style> <style id='global-styles-inline-css' type='text/css'> :root{--wp--preset--aspect-ratio--square: 1;--wp--preset--aspect-ratio--4-3: 4/3;--wp--preset--aspect-ratio--3-4: 3/4;--wp--preset--aspect-ratio--3-2: 3/2;--wp--preset--aspect-ratio--2-3: 2/3;--wp--preset--aspect-ratio--16-9: 16/9;--wp--preset--aspect-ratio--9-16: 9/16;--wp--preset--color--black: #000000;--wp--preset--color--cyan-bluish-gray: #abb8c3;--wp--preset--color--white: #ffffff;--wp--preset--color--pale-pink: #f78da7;--wp--preset--color--vivid-red: #cf2e2e;--wp--preset--color--luminous-vivid-orange: #ff6900;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;--wp--preset--spacing--20: 0.44rem;--wp--preset--spacing--30: 0.67rem;--wp--preset--spacing--40: 1rem;--wp--preset--spacing--50: 1.5rem;--wp--preset--spacing--60: 2.25rem;--wp--preset--spacing--70: 3.38rem;--wp--preset--spacing--80: 5.06rem;--wp--preset--shadow--natural: 6px 6px 9px rgba(0, 0, 0, 0.2);--wp--preset--shadow--deep: 12px 12px 50px rgba(0, 0, 0, 0.4);--wp--preset--shadow--sharp: 6px 6px 0px rgba(0, 0, 0, 0.2);--wp--preset--shadow--outlined: 6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1);--wp--preset--shadow--crisp: 6px 6px 0px rgba(0, 0, 0, 1);}:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-background-color{background-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-pale-pink-background-color{background-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-background-color{background-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-background-color{background-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-background-color{background-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-background-color{background-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-background-color{background-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-background-color{background-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-background-color{background-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-background-color{background-color: var(--wp--preset--color--vivid-purple) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-border-color{border-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-pale-pink-border-color{border-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-border-color{border-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-border-color{border-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-border-color{border-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-border-color{border-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-border-color{border-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-border-color{border-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-border-color{border-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-border-color{border-color: var(--wp--preset--color--vivid-purple) !important;}.has-vivid-cyan-blue-to-vivid-purple-gradient-background{background: var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple) !important;}.has-light-green-cyan-to-vivid-green-cyan-gradient-background{background: var(--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan) !important;}.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange) !important;}.has-luminous-vivid-orange-to-vivid-red-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-orange-to-vivid-red) !important;}.has-very-light-gray-to-cyan-bluish-gray-gradient-background{background: var(--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray) !important;}.has-cool-to-warm-spectrum-gradient-background{background: var(--wp--preset--gradient--cool-to-warm-spectrum) !important;}.has-blush-light-purple-gradient-background{background: var(--wp--preset--gradient--blush-light-purple) !important;}.has-blush-bordeaux-gradient-background{background: var(--wp--preset--gradient--blush-bordeaux) !important;}.has-luminous-dusk-gradient-background{background: var(--wp--preset--gradient--luminous-dusk) !important;}.has-pale-ocean-gradient-background{background: var(--wp--preset--gradient--pale-ocean) !important;}.has-electric-grass-gradient-background{background: var(--wp--preset--gradient--electric-grass) !important;}.has-midnight-gradient-background{background: var(--wp--preset--gradient--midnight) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-medium-font-size{font-size: var(--wp--preset--font-size--medium) !important;}.has-large-font-size{font-size: var(--wp--preset--font-size--large) !important;}.has-x-large-font-size{font-size: var(--wp--preset--font-size--x-large) !important;} :where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;} :where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;} :root :where(.wp-block-pullquote){font-size: 1.5em;line-height: 1.6;} </style> <link rel='stylesheet' id='headline-style-css' href='http://raphaeljs.com/wp-content/themes/headline/style.css?ver=6.6.2' type='text/css' media='all' /> <link rel="https://api.w.org/" href="http://raphaeljs.com/wp-json/" /><link rel="alternate" title="JSON" type="application/json" href="http://raphaeljs.com/wp-json/wp/v2/pages/8" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://raphaeljs.com/xmlrpc.php?rsd" /> <meta name="generator" content="WordPress 6.6.2" /> <link rel='shortlink' href='http://raphaeljs.com/' /> <link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="http://raphaeljs.com/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fraphaeljs.com%2F" /> <link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="http://raphaeljs.com/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fraphaeljs.com%2F&#038;format=xml" /> </head> <body class="home page-template-default page page-id-8 hdl-orange"> <div id="page" class="site"> <div class="site-header"> <div class="container"><div class="row"> <div class="col-md-12"> <a class="skip-link screen-reader-text" href="#content">Skip to content</a> <header id="masthead"> <div class="site-branding text-center"> <p class="site-title"><a href="http://raphaeljs.com/" rel="home">Rapha&euml;l</a></p> <p class="site-description">JavaScript Library</p> </div><!-- .site-branding --> </header> </div> </div></div><!-- .container --> </div> <div class="main-navigation-container"> <div class="container"><div class="row"> <div class="col-md-12"> <nav id="site-navigation" class="main-navigation"> <div class="menu-toggle-container text-center"> <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">Menu</button> </div> <div id="primary-menu" class="menu"><ul> <li class="page_item page-item-8 current_page_item"><a href="http://raphaeljs.com/" aria-current="page">An Intro to Raphaël</a></li> </ul></div> </nav><!-- #site-navigation --> </header><!-- #masthead --> </div> </div></div><!-- container --> </div><!-- main-navigation-container --> <div id="content" class="site-content"> <div class="container"><div class="row"> <div class="col-md-9 right-sidebar"> <div id="primary" class="content-area"> <main id="main" class="site-main"> <article id="post-8" class="post-8 page type-page status-publish hentry"> <header class="entry-header"> <h1 class="entry-title">An Intro to Raphaël</h1> </header><!-- .entry-header --> <div class="entry-content"> <p>The most popular coding language for the web is javascript; so much so that since the advent of HTML5, it has now been officially accepted as the default standard. Javascript has moved beyond a smaller client-side browser-based language to become integrated not just for front-end design, but also for back-end server-side development. As a result there are has been a huge growth of Javascript libraries, ranging from the popular JQuery library all the way through React.js, Angular, and VUE.js.</p> <p>While can seem a little overwhelming deciding which library or framework to use for developing your pages, once you get an understanding of the strengths and weaknesses of the different languages, the decision becomes a good deal less complicated . There&#8217;s no reason to stick with a single library, and different frameworks have different purposes. This is absolutely as true with Raphael.js as it is with any of the others.</p> <p>However, before we discuss this, let&#8217;s take a step back. The main area where Javascript continues to reign is in front-end development, which continues to be one of the biggest growth areas on the web. This is the case for some fairly obvious reasons; it is the part of the web that people <i>see</i>. One of the biggest appeals of developing for the front end, is that it is an excellent place for <i>artists</i> to show their work.</p> <p>Historically, artists will work with any medium that can be manipulated for creative purposes., but each generation finds new ones that become popular. As cave walls were a popular artistic medium in the earliest stages in human development, modes of expression soon moved toward creating sculptures in stone.</p> <p>As new materials appeared, they too became used for artistic expression. Throughout much of civilized history, canvas and oil paints made it possible for fantastic paintings to be created. In fact the word “canvas” has now become synonymous with any artistic medium.</p> <p>Today, one of the most popular artistic media is the web, and the web browser has become a new canvas. Artists flock to the web, not only because of its flexibility, but also because it can serve simultaneously as a gallery for works, be they individual masterpieces, or functional and usable artisinal pieces. <a href="https://www.theblogstarter.com">Anyone can start a blog</a>, and if it can be created, it can be viewed by anyone, by typing in a simple URL or clicking a link.</p> <p>The web becomes the gallery, and the browser becomes our canvas, but we need our tools, our paint, and our brushes. This is where Raphael appears.</p> <h3><b>What is Raphael?</b></h3> <p>Named for the artist Raffaello Sanzio da Urbino, Rapahel.js is a javascript library designed specifically for artists and graphic designers. It is the brush that you can use to apply images directly to the canvas of the browser.</p> <p>With Raphael.js you are given the power of Scalable Vector Graphics (SVG) to be able to use your web browser to created detailed drawings, which, when combined with the pigments available in your CSS paint kit, you can create beautiful and professional graphics right on the screen, without having to rely on using uploaded images. As Javascript has already become the official language of the web, it should work seamlessly with almost any browser, and load quickly into any web page.</p> <h3><b>Scalable Vector Graphics</b></h3> <p>Let&#8217;s take a look at Scalable Vector Graphics, or SVG. As a graphic artist, you may already be familiar with SVG. If you&#8217;re not, let’s break this down a little. Vector graphics are a method for creating digital images using mathematical commands in a two or three-dimensional space. If you remember your high-school math, you&#8217;ll remember the XY axis. That is your two dimensional space, with X representing a horizontal coordinate, and Y, the vertical. (For three dimensions, you add Z for depth, but that&#8217;s beyond where we&#8217;re going here). Scalable Vector Graphics are simply a method of describing drawings in this system using an XML format. Here&#8217;s an example for drawing a circle:</p> <pre><code> &lt;svg width="80" height="80"&gt; &lt;circle cx="40" cy="40" r="30" stroke="#000" stroke-width="1" fill="#FFF" /&gt; &lt;/svg&gt; </code></pre> <p><img decoding="async" class="aligncenter size-full wp-image-11" src="http://raphaeljs.com/wp-content/uploads/2018/09/circle.png" alt="" width="64" height="68" /></p> <p>You&#8217;ll note that we are defining the size of the circle and then the XY axis at half of the size, and then the “r” simply specifies the radius. Pretty straightforward, right?</p> <h3><b>Raphael Demonstration</b></h3> <p>Using SVG drawing images into an HTML page will work, however it can be fairly clumsy for actual graphic design. It is necessary to define each and every element, and your code can end up a little cluttered. You can do much of what you want, but you will need to define each and every element, and it requires a little more complex visualization to be able to create more elaborate designs. Styling the image means jumping back and forth into your CSS files, or putting awkward inline styles directly into your code. Actually creating art or useful designs beyond those simply shapes can require a monumental amount of effort (not to mention how unsightly your code can start to look!)</p> <p>Let&#8217;s take a quick look at what Raphael can do. With only a few lines of code, you can draw far more elaborate shapes, using vectors as if you are handling a brush or pencil. Here&#8217;s the same image, using Raphael.</p> <pre><code> &lt;div id="container"&gt;&lt;/div&gt; &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"&gt; &lt;/script&gt; &lt;script&gt; var paper = Raphael("container", 500, 300); var dot = paper.circle(250, 150, 30).attr({ fill: "#FFF", stroke: "#000", "stroke-width": 1 }); &lt;/script&gt; </code></pre> <p>If you run this in your browser, you&#8217;ll see that it works very similarly. However in the code, you can see a few difference. First you&#8217;ll note that we have defined a container div, and within the Raphael object, we have set some clearly defined dimensions on the XY axis. This your canvas. Like a painter, you have set up your work space. You have a clean, blank surface with which to work. Everything you work on, will now live within your canvas (in this case, named named as the variable “paper”). You can see that not only did we define the circle, but we also defined the XY location on the paper itself. However, as Raphael is a javascript library, we have the ability to be a lot more flexible and can create shapes that could be painstaking if done manually using SVG in the XML format. By bringing in some of your basic mathematical skills, you can create shapes that would have taken a long time to create, using other methods. Here&#8217;s an example of one of the creative things that you can do:</p> <pre>window.onload = function() { var paper = new Raphael("container", 500, 300); for(var i = 0; i &lt; 5; i+=1) { var multiplier = i*5; paper.circle(250 + (2*multiplier), 150 + multiplier, 50 - multiplier) </pre> <p>With a few few quick calculations using the power of Javascript, you can generate an image that looks like this:</p> <p><img decoding="async" class="aligncenter size-full wp-image-13" src="http://raphaeljs.com/wp-content/uploads/2018/09/circles.png" alt="" width="129" height="118" /></p> <p>You can begin to see the possibilities. Raphael let&#8217;s you enter create complex images mathematically right in the page, without having to jump back and forth into the CSS file. Let&#8217;s take a look at what we can do if we just add a little bit of styling right into our original image:</p> <pre>var dot = paper.circle(250, 150, 30).attr({ gradient: '90-#000-#FF0000', stroke: '#000', 'stroke-width': 3, 'stroke-linejoin': 'round', rotation: -120 }); </pre> <p>Your simple circle is suddenly no longer just a plain image on the page. You should get a result that looks like this:</p> <p><img decoding="async" class="aligncenter size-full wp-image-12" src="http://raphaeljs.com/wp-content/uploads/2018/09/redcircle.png" alt="" width="81" height="81" /></p> <p>The results you get start to take a genuine artistic flair, and suddenly your SVG images start to come alive. If you are already familiar with the power of using SVG, you already know that there&#8217;s a lot more that you can do than making pretty colored circles. You can draw pretty much any shape that comes to mind, ranging from other basic geometric shapes, to straight lines, to curving arcs and patterns.</p> <h3><b>Why use Raphael?</b></h3> <p>After going over some of the demonstrations above, I can already sense the excitement you are feeling as you become familiar with what Raphael can do. While there are a few other libraries that can do similar things as Raphael, such as D3, Raphael is distinct for a few reasons.</p> <p>D3 is certainly a very powerful tool and will do much of what Raphael does. Most of what you can do in Raphael you can also do in D3. Many will argue that D3 is far more powerful, and indeed it can handle more complex graphics, particularly for business purposes. However, from an artistic standpoint, you already know that you don&#8217;t always want to use the same tool for everything. Sure D3 is powerful. So is a heavy duty spray gun. That does not mean that it is right for all artistic purposes. Sometimes you only need a simple brush.</p> <p>Raphael also has a few advantages that D3 does not. Raphael has a much lower learning curve. From an artistic point-of view, you may not wish to spend months getting used to your tools, when all you really want do is to start painting. Another huge advantage of Raphael is that it will work in older browsers. Older versions of IE do not allow SVG to be rendered directly. Raphael will even work in IE6, something which very few modern tools can claim. From the very important standpoint of usability and user experience, as a rule, you generally do not want to force users to change their tools simply to see your beautiful creations. Raphael is also popular, meaning that not only is it likely to be around for a long time, it also means that there is a ton of support available for <i>free!</i> Who can argue with that?</p> <p>There really is no reason not to learn Raphael, especially considering the ease of entry, so why not jump right in and start creating?</p> <pre></pre> </div><!-- .entry-content --> </article><!-- #post-8 --> </main><!-- #main --> </div><!-- #primary --> </div> <div class="col-md-3"> <aside id="secondary" class="widget-area"> <section id="search-2" class="widget widget_search"><form role="search" method="get" class="search-form" action="http://raphaeljs.com/"> <label> <span class="screen-reader-text">Search for:</span> <input type="search" class="search-field" placeholder="Search &hellip;" value="" name="s" /> </label> <input type="submit" class="search-submit" value="Search" /> </form></section> <section id="recent-posts-2" class="widget widget_recent_entries"> <h2 class="widget-title">&nbsp;</h2> <ul> <li> <a href="http://raphaeljs.com/reference.html">Documentation</a> </li> </ul> </section> </aside><!-- #secondary --> </div> </div><!-- #content --> </div></div><!-- container --> <div class="container"><div class="row"> <div class="col-md-12 col-lg-12"> <footer id="colophon" class="site-footer"> <div class="site-info"> Powered by Headline WordPress Theme </a> </div><!-- .site-info --> </footer><!-- #colophon --> </div> </div></div><!-- .container --> </div><!-- #page --> <script type="text/javascript" src="http://raphaeljs.com/wp-content/themes/headline/js/script.js?ver=1.0.1" id="headline-script-js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10