Archive for category SVG

Cool SVG Puzzle Demo Using JQuery SVG

Via HRJ ("Overworked mad genius readying to take on the world. I am his neighbor") comes a cool puzzle piece demo written using SVG and JQuery SVG:

HRJ has some nice code. First he calls the Flickr API using JQuery and JSON and makes a JigSaw puzzle piece for each one; in the code below he is also grabbing a picture name from the #hash value in the URL if it is present:

JAVASCRIPT:
updateStatus('Fetching photo from Flickr');
$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=3cac122425cd16eaa1ea4c1b8bb3ff26&photo_id='+specifiedHash[1]+'&format=json&jsoncallback=?', function(response) {
    if (response.stat && response.stat == 'ok') {
      var p = response.photo;
      $.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=3cac122425cd16eaa1ea4c1b8bb3ff26&photo_id='+specifiedHash[1]+'&format=json&jsoncallback=?', function(response2) {
        if (response2.stat && response2.stat == 'ok') {
          updateStatus('Observe the tiles. Click on them to begin.');
          var medSize = response2.sizes.size[4] ? response2.sizes.size[4] : response2.sizes.size[3];
          currJigsaw = new JigSaw(medSize.source, medSize.width, medSize.height, p.urls.url[0]._content, p.title._content);
          var locationMatch = photoHashIgnorePattern.exec(window.location),
              myLocation = locationMatch ? locationMatch[1] : window.location;

          $('#puzzleLink').html('<a href="'+myLocation+'#photo_'+p.id+'">Puzzle\'s link</a>');
        }
      });
    } else {
      updateStatus('Error! Couldn\'t load image');
    }
});
 

The code that animates all the tiles when you first click on a board is interesting, using a bit of JQuery SVG:

JAVASCRIPT:
function startPlayInit() {
      var imgCenter = {x : width/2, y: height/2};
      for (var i = tiles.length; i--;) {
        $(tiles[i].sN).animate({'svgTransform':'rotate('+[tiles[i].r,imgCenter.x, imgCenter.y].join(',')+') translate('+[imgCenter.x, imgCenter.y].join(',')+')'}, {
          duration:1000,
          complete : startPlay
        });
      }
    }
 

Basically each of the tiles is rotated and translated over 1 second with a nice animation effect.

Adobe Announces HTML5/CSS3/SVG Pack for Illustrator

Exciting news from Adobe; they've announced a new HTML5 Pack on Adobe Labs with support for HTML5, CSS3, and SVG:

Adobe is pleased to announce the availability of the Adobe® Illustrator® CS5 HTML5 Pack. This add-on for Illustrator CS5 15.0.1 provides initial support for HTML5 and CSS3, extends SVG capability in Illustrator CS5, and helps you easily design web and device content. In combination with the HTML5 features available in the Adobe Dreamweaver CS5 11.0.3 updater, these new tools allow web designers to take advantage of the latest advancements in HTML5.

While HTML5 and CSS3 will not be finalized for some time, and SVG support in browsers will continue to evolve, the extension provides support for a set of currently implemented features.

Some of the benefits of the HTML5 Pack:

  • Efficiently design for web and devices by exporting Illustrator Artboards for unique screen sizes using SVG and CSS3 media queries.
  • Create web widgets with Illustrator by generating dynamic vector art for data driven web work-flows.
  • Take advantage of the latest enhancements to SVG and Canvas to generate interactive web content.
  • Map artwork appearance attributes from designer to developer tools—export from the Illustrator Appearance Panel to CSS3 for streamlined styling of web pages.

Greg Rewis discusses it more in the video below:

Mordy Golding has a good description of some of the new features in this lab pack:

Parameterized SVG

You can designate certain attributes (i.e., fill, stroke, opacity) as variables right from the Appearance panel in Illustrator. When saved as SVG, developers can easily change the variable definition to "reskin" or modify the art. You can even create global variables.

Multi-screen SVG

You can create multiple artboards in Illustrator at various sizes, for example to design art for different screen sizes. You might do this to create different designs for mobile, tablet, and desktop versions of a design for example. You can then save your file as SVG and include all the different artboards. Illustrator creates an HTML file and a CSS file, along with separate SVG files for each artboard. The CSS uses media queries to detect the screen size and automatically serves up the correct SVG image.

Mark objects as canvas in SVG

You can select an object on the Illustrator artboard and then choose Object > HTML5 Canvas > Make. These elements are rasterized and included as canvas elements when saved as SVG, giving developers the ability to control the elements via JavaScript.

Export named character styles as CSS

You can define character styles in your Illustrator document, and then export those character styles as a valid CSS file. You can do this directly from the Character Styles panel.

Export artwork appearances as CSS

You can select an object in Illustrator and export valid CSS directly from the Appearance panel. Of course, if you mockup an entire page in Illustrator, you can simply select all of it and export it to a single CSS file. IDs are picked up from the Layers panel (so you want to name artwork carefully), and Illustrator can export Fill, Stroke, Opacity, and Absolute Position and Dimensions.

Include selected Graphic Styles as CSS in SVG

You can select styles from the Graphic Styles panel and choose to have them exported when you save your file as SVG. What's really cool is that you can include styles even if they aren't applied to your artwork. This would allow you to deliver multiple styles to a developer within a single SVG, and even programmatically swap styles.

Great work Adobe!