Archive for February, 2012

All About jQuery: Fresh and Useful jQuery Plugins and Tutorials


  

Every designer knows that jQuery is not only a handy tool, but it is also very popular and widely implemented. Thus, they try to master their jQuery skills. If you fit into this category then this post of over 40 fresh and cool jQuery plugins and tutorials is for you. This showcase should allow you to grab some of the techniques required for developing a more interactive and visually appealing website with jQuery and harness the power of this tool.

When you come out the other side of this collection and have finished learning all that these plugins and tutorials throw at you, we hope that using jQuery will be a much simpler task. Which will hopefully translate into more satisfied clients and users. Enjoy!

jQuery Resources

Password Strength Verification with jQuery ( Demo | Tackle the Tutorial )
In this tutorial, we’ll construct a form that gives the user live feedback as to whether their password has sufficiently met the complexity requirements we will establish.

Screenshot

Create a Windows-like Interface with jQuery UI ( Demo | Visit the Source )
In this tutorial, you will learn how to utilize jQuery UI to create a highly-functional user interface without using anything else. By the end, you should be familiar with jQuery UI, some of its components, and basic understanding of jQuery UI’s customization.

Screenshot

Akordeon ( Demo | Visit the Source )
Akordeon is fully customizable and can be used to display large chunks of data (text, images etc.) in a limited space. For instance, you can use it to display categorized data or menu options just like a restaurant’s menu items with each category’s data displayed in a separate panel.

Screenshot

Fast and Simple Links Box Navigation Menu: BoxyMenu ( Demo | Visit the Source )
BoxyMenu is a simple and fast navigation menu plugin that renders smoothly in all major web browsers. It is simple to customize and can be plugged in to any website or web application.

Screenshot

Item Blur Effect with jQuery and CSS3 ( Demo | Visit the Source )
With this jQuery plugin you can create a simple blur effect for text-based items. The idea is to have a set of text boxes that will get blurred and scaled down once we hover over them. The item in focus will scale up.

Screenshot

jQuery Clean and Simple Tooltips: Gips ( Demo | Visit the Source )
Gips is a clean and simple jQuery plugin. Fully customizable, and easy to use. It also supports CSS themes.

Screenshot

Fullscreen Image Blur Effect with Html5 ( Demo | Visit the Source )
With this jQuery plugin you can create a fullscreen image display with small thumbnail navigation and a blur transition effect for smooth image changes.

Screenshot

jQuery Plugin for On-demand Search Box: SeacrhMeme ( Demo | Visit the Source )
This jQuery Plugin is called SearchMeme – the idea is to provide a small search button that can be placed anywhere on the website. Clicking on search button expands it to show a text box where you can type your search terms.

Screenshot

Multi-Level Hierarchical jQuery Menu: jQSimpleMenu ( Demo | Visit the Source )
jQSimpleMenu is a multi-level hierarchical jQuery drop down menu that helps you add drop down menus in your website without writing a single line of code.

Screenshot

Making a jQuery Countdown Timer ( Demo | Visit the Source )
With this jQuery plugin you can display a countdown timer. It will show the remaining days, hours, minutes and seconds to your event, as well as an animated updates every second.

Screenshot

Awesome jQuery scrolling decks plugin ( Demo | Visit the Source )
A jQuery plugin for making scrolling presentation decks with complete ease.

Screenshot

jQuery List Items Menu Like iPhone Display ( Demo | Visit the Source )
A jQuery plugin that allows you to display list items in a similar way to an iPhone home screen. If the item count exceeds the number of displayed items on one screen, users can swipe through screens.

Screenshot

3D Gallery with CSS3 and jQuery ( Demo | Visit the Source )
With this jQuery plugin you can create an outstanding 3D Gallery with CSS3.

Screenshot

Shiny Knob Control with jQuery and CSS3 ( Demo | Visit the Source )
With this jQuery plugin you can create a shiny knobbed control, with CSS3 transformations and jQuery’s new event handling methods to give visitors of your website a new way of interactively choosing a value from a range.

Screenshot

Arctext.jp – Curving Text with CSS3 and jQuery ( Demo | Visit the Source )
While CSS3 allows us to rotate letters, it is quite complicated to arrange each letter along a curved path. Arctext.js is a jQuery plugin that let’s you do exactly that. Based on Lettering.js, it calculates the right rotation of each letter and distributes the letters equally across the imaginary arc of the given radius.

Screenshot

jQuery Plugin For Rotating Image ( Demo | Visit the Source )
With this jQuery plugin you can create an amazing rotating image with the simple click of the mouse.

Screenshot

Thumbnail Proximity Effect with jQuery and CSS ( Demo | Visit the Source )
With this jQuery plugin you can create a neat thumbnail proximity effect with jQuery. The idea is to scale thumbnails when hovering over them and also scale their neighbouring thumbnails proportionally to their distance.

Screenshot

Creating Your Own Ajax Poll System ( Demo | Visit the Source )
In this tutorial we will be creating our very own polling system (AJAX) for your projects with PHP.

Screenshot

Lateral On-Scroll Sliding with jQuery ( Demo | Visit the Source )
With this jQuery plugin you can create a “slide-in on scroll� effect. You’ve probably seen this cool effect on some websites, now you can have it on yours.

Screenshot

Elastic Image Slideshow with Thumbnail Preview ( Demo | Visit the Source )
With this jQuery plugin you can create a simple elastic slideshow with a thumbnail preview. The slideshow will adjust automatically to its surrounding container and users can navigate through the slides by using the thumbnail previewer or the autoplay slideshow option.

Screenshot

More on Page Two

We are just about halfway through the post, but don’t move on just yet, there is still more jQuery goodies on page two.


Redefining Hick’s Law


  

Hick’s Law has always been a popular reference point for designers. You’ll find it cited in the endless lists of basic laws and principles that all designers should be familiar with. Given our assumed comfort level with this design cornerstone, I am surprised to see so many people getting it wrong.

What we think we understand about Hick’s Law as it pertains to Web design is oversimplified and incomplete. We need to more deeply investigate what Hick’s Law can do for Web design. In the end, we will see why this design principle is undervalued, and we will see how we have been designing incorrectly for the user’s decision-making process. In order to get there, we need to look at our current approach to Hick’s Law and why it’s wrong.

Choices
A mess of different size labels for clothing hooks. (Image: außerirdische sind gesund)

An Incomplete Definition

As it stands today, most discussions of Hick’s Law focus on a narrow portion of Web design. Traditionally, the law is used to encourage designers to limit options in navigation, lists and interactive options. Whether it’s used against drop-down and fly-out menus with too many options or pages with too many links, Hick’s Law has primarily been a counterweight to sprawl.

Overstock navigation
Don’t do this.

While the idea does have merit (massive menus really are a bad idea), it is incomplete. Why do we restrict Hick’s Law to navigation? Hyperlinks are the driving force of the Internet; they take us from one page to another and drive the action on the page. So, applying Hick’s Law should begin there. Limiting the number of links and buttons in front of users should simplify their decision-making process, enabling them to move about the Web with minimal stress and delay. But is this the end all and be all of Hick’s Law?

A Better Perspective

If we stopped here in our study of Hick’s Law, we would miss out on a lot of value. Why do we focus so much on links and clicks? While these factors do drive the user experience, they aren’t the only factors that users take into account when navigating a design. We have to remember that Hick’s Law did not come about with the invention of the Internet. Hick’s research simply shed light on how a website’s options affect the speed and ease of the user’s decision making. This makes for a pretty broad scope, because we aren’t measuring physical responses or the role that technology plays, but rather the mental processes that lead to making a decision.

So, let’s step back and consider the thought process that users go through and how many levels of decision-making a Web design can consist of. For example, instead of just regarding each link in a navigation menu, sign-up form or toolbar as its own option, we should consider the process of interacting with the navigation a decision of its own. For that matter, any given design contains a whole array of top-level “options� that demand decisions of the user.

In choosing whether to read an article, navigate to a new page, fill out a log-in form or perform a search, the user has to mentally process several options before making even a single click. Are they interested in the content on this page? They might decide to skim the headlines to see what stands out to them. Perhaps they are shopping for something. Before even hitting the “Add to cart� button, they have to choose between making the purchase, looking at product details and reviews, and shopping around for something else.

TypeKit
When browsing fonts on Typekit, the user has many more decisions to make than simply picking a font.

With all of these options available, it would seem that crunching the numbers and determining how many choices are possible would paralyze any user into indecision and make any website unusable. Clearly, this isn’t the case. So, what is it about a good design that enables users to decide and act, without being overwhelmed by too many choices? Better yet, can we measure and reproduce these factors in our design work every day?

Reapplying Hick’s Law

In order to properly apply Hick’s Law to Web design, we must approach a design the way our users do: in phases.

The first phase occurs before the website even launches. While we would never want to design based on an assumption of what our user base is looking for, visitor will rarely happen upon your website without some sort of preconception of what they are going to see. Barring the occasional hijack, most first-time visitors enter a website by clicking a link that includes a description, title or search result that hints at the content they will see. Returning visitors probably have an even better idea of what they will be running into. It is rare that a user enters a website with no clue of what it is about.

This preconception among users about content and experience is a great reason to follow a content-first design approach. Of course, this approach also happens to be entirely justified. In an age of search-engine placement and social advertising, many users are landing on content-heavy pages, not just home pages driven by calls to action. So, the first decision point is about content consumption. The human mind has trouble choosing between several options unless one clearly stands out as the best. When you water down a design with widgets and secondary content, you reduce the value of the primary content and force a harder decision on the user. The process of eliminating distracting options has to start here and should be carried on throughout the design process. The more choices we eliminate, the more enjoyable the experience will be.

Looking past the primary content, what happens when content comes in large data sets, such as a list of recent posts, product suggestions or thumbnails? It’s here that the designer can really prove their worth. We have all seen designs that lack structure, spacing and consistency. The content gets lost, or the user gives up entirely when they aren’t given the tools with which to make confident decisions. Building a great experience has a lot to do with how we empower the user’s decision-making process through these practices. When we apply our skill sets to drive users to a particular action on a page, we are counteracting the lag or complete mental shutdown that is caused by a complicated decision-making process.

Is minimalism your thing? Then a splash of color or carefully arranged negative space goes a long way to breaking down the top-level decisions that users have to make. If you find yourself painting or spacing out elements haphazardly on the page, then it’s time to reconsider the number of options on the page and choose the ones that are most important.

Information Architects
The less color we use, the more powerful it becomes.

When dealing with rich designs and content-heavy websites, patterns are your best friend. When users are in scanning mode, their eyes will key in on consistency, so your designs should be visually consistent in the right way. Are your headings different enough from your titles to be instantly recognizable as secondary or tertiary content? Always fall back on the principles of art and look at how the design uses line, shape, color and spacing. Variations in these things draw the user’s attention, while consistency breeds familiarity and easier decision-making. Pushing Hick’s Law to the core of this thought process forces us to think twice about our reasons for visually emphasizing certain elements.

When we design in patterns, we instill assumptions and behavioral patterns in our users as well. The Web has some global design patterns that help users make decisions. When text is blue and underlined, users understand they can click on it and get sent to a related resource. Similar patterns can exist within the confines of a single design. If we place a texture behind a headline, the user will associate the two things; the next time the user sees the texture, they will expect to see an element in front of it that carries the same weight or meaning as the headline they first saw. Distributing these patterns throughout a design helps users make choices based on previous experience.

What We Do With Words

Perhaps you haven’t heard the news: people don’t really read websites. Users don’t read content until they are motivated and enabled to do so. So, we need to take titles seriously and use imagery in the right way. Graphics and images are a huge draw, especially on pages loaded with text. When used correctly, they can make an otherwise heavy page easier to decipher, thus connecting users to the content they care about more quickly.

Pinterest
Thanks to design patterns and support of image thumbnails, Pinterest can load a lot of content.

Pinterest Without Images
Take away the images, and the design suddenly becomes unusable. This highlights the importance of using images properly.

Designing With Hick’s

The only way to get any real value out of Hick’s Law is to marry it with the design principles that we know and love. I challenge you to incorporate Hick’s Law into the highest levels of your design process. When you set up wireframes, look past the trees of “Link 1, Link 2, Link 3…� and see the forest of decisions that you are putting in front of users. (Cutting this forest down is totally fine.)

Prototyping stuff out? Don’t just worry about how many times to use a call-to-action style. When you group elements or space them out or change the background color or apply a texture, you are setting off a section of the design and potentially laying another choice on users. This is why design is not just about decorating the page or making a button stand out. We must respect the power of design to draw attention and, thus, strictly limit the number of decisions that we burden users with.

The Web is a wonderful place to specialize, and a lot of websites out there do a fine job of delivering a very limited scope of options to users in fine style. This level of focus is made possible by zeroing in on a core set of behaviors that are easily targeted by a consistent set of design patterns. This often has the desirable side effect of being great for mobile-first responsive design.

Quipol
Quipol focuses on doing one thing really well, which limits decision overload for users.

Where’s My Magic Number?

So, how many choices can we expect users to be able to manage before slowing down? The answer will always be relatively few. Some of the best designed and most popular websites limit options to just a few. On Google, we can log in, search or try our luck. On the Quipol page above, we can vote, log in or sign up, learn about this new service, or see more polls. The options on Twitter’s home page have lowered over time, being whittled down to simple sign-up and log-in forms.

Old Twitter
Not long ago, Twitter presented a lot of choices on the home page.

New Twitter
The new design sharply reduces these decision points and exhibits greater focus.

This is a huge design challenge that demands a lot of thought, testing and revision. The process of minimizing options for users without impairing functionality is not an exact science and no easy task. It requires studying our users’ behavior patterns and making tough decisions about what to do about such things as advertising, business-derived feature creep and actions such as logging in and signing up (which empower users but distract from the content). As we can see with Twitter, this is an evolving art form. As Twitter continues to grow in popularity, more and more users are landing on its home page already knowing what goes on there. This empowers Twitter’s design team to lower the noise that results from having to educate new users on the service.

Foursquare Explore
The “Explore� feature on Foursquare packs limitless possibility into a simple set of options.

Foursquare has also done a great job of providing a powerful tool without overwhelming users with choice. In less capable hands, Foursquare’s “Explore� feature could easily host dozens of filters, restrictions and settings to tinker with. Instead, the visitor is encouraged to use the service simply by typing what they want in the input field and hitting the only button on the screen. This simplicity is made possible by a few things. First and foremost, the core premise of the service is all about the here and now. Foursquare knows its users are interested in what’s right around them, because the service has always been about sharing and exploring your immediate surroundings; so, defaulting the search area to the user’s current location is a safe bet. Secondly, over a billion data points yield a lot of power. With such a large a set of information, Foursquare can do a lot behind the scenes to make educated guesses about what its users are really interested in.

Making Sense Of It All

So, how does rethinking Hick’s Law outside of its traditional design context make us better designers? It’s all about the process. It irks me when a client asks me to make something pretty or to put a “magic touch� on some content. Design has always been about so much more than that, and a huge part of it is making the experience effortless for users.

As we’ve seen in the examples of well-executed design above, websites take different routes and devise different solutions, but the goals are the same. When we apply principles such as Hick’s Law beyond the narrow scope of navigation sets, we start to see the power of eliminating distractions for users. Slimming websites down to one or two clear options makes for a beautiful experience and sets a lofty goal for the designer.

We can’t always eliminate all confusion for our busy, distracted users, but we can ease their pain by limiting the options that they have to mentally process. When we view chunks of content as decision-making points, it becomes clear just how much we ask of visitors. Each option is an opportunity to evaluate its importance in the design. Designers who force users to decide between only meaningful and clear options are the ones who deliver an effortless user experience. And when the experience is effortless, everyone wins.

Related Resources

(al)


© Jason Gross for Smashing Magazine, 2012.


Faces of Imagination: A Showcase of Inspiring Digital Portraits


  

As the never ending quest for inspiration pours on, we have taken our search for creative works back into the area of digital art. This time around we have found some wonderful pieces that were drawn by a range of very talented artists. Though this showcase is a collection of digital portraits, so it is a little different than some of those we have brought you in the past.

Portrait photography is often a popular medium because it gives you the chance to get up close and personal with the subject and really capture the subtle expressions and delicate features that distance can often erase. So this showcase of digital drawings have attempted to impart some of those same elements that make have made portraits a standard for generations. Take a look and see if inspiration follows.

Faces of Imagination

Altais by phoenixlu

Molt by escume

Madeline Mad by MyAmbeon

Red Orange by lolita-art

Enchantment by Vergilsparda666

Gia by WarrenLouW

Bleeding Heart by yuumei

Lackadaisy Perennial by tracyjb

Autumn by luciole

A Brief Glimpse by luciole

Strawberry Hearts by loish

Coral by escume

Fiery by alicexz

Limit by sakimichan

Snow Girl by daekazu

Mermaid by sharandula

Fu by budgie

Ablaze by moyan

Victorian Voodoo by MyAmbeon

portrait of a girl II by lolita-art

The Red Ribbon by asuka111

EPIPHANY PORTRAIT by Jujika

Keely by WarrenLouw

Rouge by escume

Steel Turquoise by loish

Melthanson by CuatroVecesUno

Bounty Hunter: Day Ain’t Done by JayAxer

Twelve Thirty Three v2 by acidlullaby

PORTRAIT OF A KILLER by AURORY

Spring by lolita-art

October by ceruleanvii

RED EARTH redpear

study3 by phoenixlu

OMAI PORTRAIT by Jujika

little princess II by ebrulii

mar by loish

Anne of Green Gables by daekazu

The Blood Eater by luciole

White Lace by moyan

Masquerade by navate

(rb)


Web-Drawing Throwdown: Paper.js Vs. Processing.js Vs. Raphael


  

Before drawing anything in a browser, ask yourself three questions:

  1. Do you need to support older browsers?If the answer is yes, then your only choice is Raphaël. It handles browsers all the way back to IE 7 and Firefox 3. Raphaël even has some support for IE 6, although some of its underlying technology cannot be implemented there.
  2. Do you need to support Android?Android doesn’t support SVG, so you’ll have to use Paper.js or Processing.js. Some rumors say that Android 4 will handle SVG, but the majority of Android devices won’t support it for years.
  3. Is your drawing interactive?Raphaël and Paper.js focus on interaction with drawn elements through clicking, dragging and touch. Processing.js doesn’t support any object-level events, so responding to user gestures is very difficult. Processing.js can draw a cool animation on your home page, but the other tools are better for interactive applications.

Paper.js, Processing.js and Raphaël are the leading libraries for drawing on the Web right now. A couple of others are up and coming, and you can always use Flash, but these three work well with HTML5 and have the widest support among browser vendors.

Choosing the right framework will determine the success of your project. This article covers the advantages and disadvantages of each, and the information you need to make the best choice.

All of the code in this article is open source and can be run on the demo page that accompanies this article.

Overview

Paper.js Processing.js Raphaël
Technology canvas tag canvas tag SVG
Language PaperScript Processing script JavaScript
Browsers IE 9 IE 9 IE 7
Mobile Yes Yes iOS only
Model Vector and raster Raster Vector
Size 56 KB 64 KB 20 KB

 

It’s all JavaScript once the page runs, but the frameworks take different paths to get there. Raphaël is written directly in JavaScript, but Paper.js uses PaperScript, and Processing.js uses its own script. They all support Firefox, Chrome and Safari, but Internet Explorer is an issue — Paper.js and Processing.js use the canvas tag and thus require IE 9.

PaperScript is a JavaScript extension that makes it possible to write scripts that don’t pollute the global namespace. This cuts down on JavaScript conflicts. PaperScript also supports direct math on objects such as Point and Size: you can add two points together as if they were numbers.

Processing.js is based on a framework named Processing, which runs in the Java Virtual Machine. You define int and float instead of var, and you can use classes with Java-style inheritance. While the Processing.js script looks a little like Java, it’s more like JavaScript and doesn’t require many of the more complex features of Java.

Using all three libraries is easy if you have some familiarity with JavaScript.

Getting Started

Start by importing each library. The process for setting each up is a little different.

Setting Up Paper.js

<head>
<script src="paper.js" type="text/javascript" charset="utf-8"></script>
<script type="text/paperscript" canvas="paperCircle" src="paper_circle.pjs" id="script"></script>
</head>
<body>
<canvas id="paperCircle" class="canvas" width="200" height="200" style="background-color: white;"></canvas>

Paper.js specifies a script type of text/paperscript and the ID of the canvas tag that you’ll draw on. It uses that ID to know where to draw.

Setting Up Processing.js

<head>
<script src="processing.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<canvas width="200" height="200" class="canvas" data-processing-sources="processing_circle.java"></canvas>

Processing.js uses the data-processing-sources attribute of the canvas tag to import your drawing. I use a .java extension for Processing’s source file so that my editor color-codes it properly. Some authors use a .pde or .pjs extension. It’s up to you.

Setting Up Raphaël

<head>
<script src="raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael_circle.js" type="text/javascript" charset="utf-8"></script>
</head>

Raphaël is imported like any other JavaScript file. It works well with jQuery’s ready function or any other JavaScript framework.

Now we can start drawing.

Object-Oriented Drawing

Both Paper.js and Raphaël use object-oriented drawing: you draw a circle and get back a circle object. Processing.js draws the circle and doesn’t give you anything back. The following simple example makes it clear. Let’s start with a circle in the middle of the screen at point 100,100.

Paper.js:

var circle = new Path.Circle(new Point(100, 100), 10);
circle.fillColor = '#ee2a33';

Raphaël:

var paper = Raphael('raphaelCircle', 200, 200);
var c = paper.ellipse(100, 100, 10, 10);
c.attr({'fill': '#00aeef', 'stroke': '#00aeef'});

Processing.js:

void setup() {
   size(200, 200);
}

void draw() {
   background(#ffffff);
   translate(100, 100);
   fill(#52b755);
   noStroke();
   ellipse(0, 0, 20, 20);
}

Each code snippet draws the same circle. The difference is in what you can do with it.

Paper.js creates the circle as a path object. We can hold onto the object and change it later. In Paper.js, circle.fillColor = 'red'; fills our circle with red, and circle.scale(2) makes it twice as big.

Raphaël follows Paper.js’ object-oriented model. In Raphaël, we can change the color of our circle with circle.attr('fill', 'red');, and scale it up with circle.scale(2, 2);. The point is that the circle is an object that we can work with later.

Processing.js doesn’t use objects; the ellipse function doesn’t return anything. Once we’ve drawn our circle in Processing.js, it’s part of the rendered image, like ink on a page; it’s not a separate object that can be changed by modifying a property. To change the color, we have to draw a new circle directly on top of the old one.

When we call fill, it changes the fill color for every object we draw thereafter. After we call translate and fill, every shape will be filled with green.

Because functions change everything, we can easily end up with unwanted side effects. Call a harmless function, and suddenly everything is green! Processing.js provides the pushMatrix and popMatrix functions to isolate changes, but you have to remember to call them.

Processing.js’ no-objects philosophy means that complex drawings run faster. Paper.js and Raphaël contain references to everything you draw, and so the memory overhead created by complex animations will slow down your application. Processing.js contains no references to drawn elements, so each shape takes up a tiny amount of memory. Memory overhead pays off if you need to access an object later, but it’s overkill if you don’t. Paper.js gives you a way out of this with the Symbol object and by rasterizing objects, but you have to plan ahead to keep the app running fast.

The object-oriented versus no-objects philosophy has implications for everything you do with these libraries. It shapes the way each library handles animations.

Let’s Make It Move

Rotating circles aren’t very interesting, so we’ll make a square rotate around a circle.

Animation in Processing.js

Processing.js supports animation with the predefined setup and draw functions, like this:

float angle = 0.0;
void setup() {
   size(200, 200);
   frameRate(30);
}

void draw() {
   background(#ffffff);
   translate(100, 100);
   fill(#52b755);
   noStroke();
   ellipse(0, 0, 20, 20);

   rotate(angle);
   angle += 0.1;
   noFill();
   stroke(#52b755);
   strokeWeight(2);
   rect(-40, -40, 80, 80);
}

The setup function is called once when the application starts. We tell Processing.js to animate with a frame rate of 30 frames per second, so our draw function will be called 30 times every second. That rate might sound high, but it’s normal for making an animation look smooth.

The draw function starts by filling in the background of the canvas; it paints over anything left over from previous invocations of the draw function. This is a major difference with Processing.js: we are not manipulating objects, so we always have to clean up previously drawn shapes.

Next, we translate the coordinate system to the 100,100 point. This positions the drawing at 100 pixels from the left and 100 pixels from the top of the canvas for every drawing until we reset the coordinates. Then, we rotate by the specified angle. The angle increases with every draw, which makes the square spin around. The last step is to draw a square using the fill and rect functions.

The rotate function in Processing.js normally takes radians instead of degrees. That’s why we increase the angle of each frame by 0.2, rather than a higher number such as 3. This is one of many times when trigonometry shows up in this method of drawing.

Animation in Paper.js

Paper.js makes this simple animation easier than in Processing.js, with a persistent rectangle object:

var r;

function init() {
   var c = new Path.Circle(new Point(100, 100), 10);
   c.fillColor = '#ee2a33';

   var point = new Point(60, 60);
   var size = new Size(80, 80);
   var rectangle = new Rectangle(point, size);
   r = new Path.Rectangle(rectangle);
   r.strokeColor = '#ee2a33';
   r.strokeWidth = 2;
}

function onFrame(event) {
   r.rotate(3);
}

init();

We maintain the state of our square as an object, and Paper.js handles drawing it on the screen. We rotate it a little for each frame. Paper.js manages the path, so we don’t have to redraw everything for each frame or keep track of the angle of rotation or worry about affecting other objects.

Animation in Raphaël

Animations in Raphaël are written in standard JavaScript, so Raphaël doesn’t have specific functions for handling animation frames. Instead, we rely on JavaScript’s setInterval function.

var paper = Raphael('raphaelAnimation', 200, 200);
var c = paper.ellipse(100, 100, 10, 10);
c.attr({
   'fill': '#00aeef',
   'stroke': '#00aeef'
});

var r = paper.rect(60, 60, 80, 80);
r.attr({
   'stroke-width': 2,
   'stroke': '#00aeef'
});

setInterval(function() {
   r.rotate(6);
}, 33);

Raphaël is similar to Paper.js in its object-oriented approach. We have a square, and we call a rotate function on it. Thus, we can easily spin the square with a small amount of code.

Interaction

Raphaël shines when you need to enable interactivity in a drawing. It provides an event model similar to JavaScript’s, making it easy to detect clicks, drags and touches. Let’s make our square clickable.

Interactions With Raphaël

var paper = Raphael('raphaelInteraction', 200, 200);
var r = paper.rect(60, 60, 80, 80);
r.attr({'fill': '#00aeef', 'stroke': '#00aeef'});

var clicked = false;

r.click(function() {
   if (clicked) {
      r.attr({'fill': '#00aeef', 'stroke': '#00aeef'});
   } else {
      r.attr({'fill': '#f00ff0', 'stroke': '#f00ff0'});
   }
   clicked = !clicked;
});

The click function in Raphaël works like jQuery, and you can add it to any object. Once we get the click event, changing the color of the square is easy. Raphaël has more functions to support dragging, hovering and all of the other user interactions you expect from JavaScript.

Interactions With Paper.js

Paper.js has a different way of managing interactions, but it’s still pretty easy:

var hitOptions = {
   fill: true,
   tolerance: 5
};

function init() {
   var point = new Point(60, 60);
   var size = new Size(80, 80);
   var rectangle = new Rectangle(point, size);
   r = new Path.Rectangle(rectangle);
   r.fillColor = '#ee2a33';
}

function onMouseUp(event) {
   var hitResult = project.hitTest(event.point, hitOptions);

   if (hitResult && hitResult.item) {
      if (hitResult.item.clicked) {
         hitResult.item.fillColor = '#ee2a33';
      } else {
         hitResult.item.fillColor = '#f00ff0';
      }

      hitResult.item.clicked = !hitResult.item.clicked;
   }
}

init();

Paper.js deals with mouse gestures through a concept called “hit testing.� A hit finds the point under the mouse cursor and figures out which object it lies above. Hit options enable you to define how the hit works: you can set options for such things as how close the mouse has to be, and whether the middle of the object counts or only the edge. We can extend this hit test to any object or group of objects in Paper.js.

The Paper.js team added object-level events similar to Raphaël’s a few weeks ago. The events should show up in the next release.

Interactions With Processing.js

Processing.js makes detecting mouse clicks tricky. It doesn’t support object-level events or hit testing, so we’re pretty much on our own.

float bx;
float by;
int bs = 20;
boolean bover = false;
boolean clicked = false;

void setup() {
   size(200, 200);
   bx = width/2.0;
   by = height/2.0;
   noStroke();
   fill(#52b755);
   frameRate(10);
}

void draw() {
   background(#ffffff);

   // Test if the cursor is over the box
   if (mouseX > bx-bs && mouseX < bx+bs &&        mouseY > by-bs && mouseY < by+bs) {
      bover = true;
   } else {
      bover = false;
   }

   translate(100, 100);
   rect(-40, -40, 80, 80);
}

void mousePressed() {
   if (bover) {
      if (clicked) {
         fill(#52b755);
      } else {
         fill(#f00ff0);
      }
      clicked = !clicked;
   }
}

Once Processing.js draws the square, it forgets about it. We want the color of the square to change when we click on it, but the script doesn’t know that, so we have to do all of the calculations ourselves. The draw function detects the mouse cursor’s position and does the math to determine whether it lies within the square.

The code is not too bad for the square, but our circle would need πr2. And more complex shapes such as ovals, curves and compound shapes would require even more math.

No Clear Winner

Each framework has its advantages. Between them, the features make for cool demos and even cooler applications.

Showing Off Paper.js

Paper.js excels at manipulating complex shapes. It can turn, twist and transform any object in hundreds of ways. These transforms make it easy to convert objects based on interactive gestures. The new Google Music Tour, which makes colored lines beat in time to music, shows how one can make complex changes on simple shapes.

The other wow factor in Paper.js is its support of raster graphics. Paper.js can completely change the way images are drawn — including by turning them into spirals and Q*bert boards.

Showing Off Processing.js

Processing.js’ biggest feature is speed, making it possible to draw complex animations on slower machines. Many examples are out there, but the fluidity of Processing.js animations shows up best in Ricardo Sánchez’s koi pond.

The swishing of the tails and waving of the bodies make the koi look very natural. Processing.js makes this easy, with support for curves and customized animations.

Processing.js also supports complex drawing elements such as shading, lighting and 3-D transforms. If you want to create complex animations in canvas very quickly, then Processing.js is the clear winner.

Showing Off Raphaël

The best feature of Raphaël is its support for Internet Explorer 7 and 8. If your application has to run on older browsers, then Raphaël is the only option.

The other big feature of Raphaël is its community. Raphaël is older than Paper.js and Processing.js and thus has had more time to build examples, tutorials and user support. It has built-in support for easing, animation transforms and the event handlers that we saw in the interaction example; it also has a comprehensive charting library.

Raphaël also has the best tooling support.

The Tools

If you’ve worked with Flash, the lack of tools for these frameworks will disappoint you. Many of the frameworks will edit SVG images, but none of them offer a drag-and-drop method for creating applications.

A few simple tools are out there, but they are more like proofs of concept than actual products. Adobe is working on a tool named Edge, but it has a long way to go.

If you want to drag and drop, then Web animations aren’t for you yet. Right now, this method of drawing is more like video-game programming. Writing code to draw a circle is tougher than clicking and dragging, but it scales to more complex applications and some fun stuff.

Let’s Build Something Real

So far, we’ve looked at some simple examples, seen the best features of each platform and looked at how to choose the right one. Each framework has pluses and minuses, but judging them is difficult until you create an actual application.

To compare each framework, I’ve drawn some gears. Each gear is made up of two circles, with a set of teeth around the outer circle.

When the shapes are all given the same color, they look just like a gear.

Every gear will rotate a little with each frame of the animation. The first gear will be given a speed, and the rest will move relative to it. The gears will arrange, mesh and rotate together with a crazy amount of trigonometry. Put them together and you’ve got a complex gear system.

Paper.js:

Processing.js:

Raphaël:

Well, that wasn’t quite Raphaël. The rotate function work different in Raphaël than it does in Paper.js and Processing.js. Raphaël doesn’t support rotation around a fixed point. Instead, the teeth of the gears are drawn and redrawn independently, and they fly through the air instead of rotating around the center. The only way to really turn the gear would be to draw the entire gear as a single path, and that takes more math than I’m willing to write. If anyone wants to give it a try, everything is open source.

The Future Of Web Drawing

We gamble on every new technology that we learn: we hope that it catches on and that our investment pays off. Technologies rise and fall on their respective merits, but other factors comes into play, such as vendor support and business uses. The future of our industry is almost a guessing game.

Right now, Flash looks like a bad investment. Flash has great tools, years of development and a large community, but even Adobe is moving away from it.

SVG is in a similar situation. Browsers support it now, but it isn’t getting a lot of attention.

Every browser vendor is working hard to render canvas faster, to use hardware acceleration and to better support libraries such as Paper.js and Processing.js. All mobile devices support canvas, and their developers are working to improve it.

(al)


© Zack Grossbart for Smashing Magazine, 2012.


Textured Web: Showcase of Textured & Patterned Website Designs


  

When it comes to design resources, textures and patterns are among some of the most popular tools on offer. And while we may never be able to get a single, definitive answer from the community as to why this is, one can surmise that their popularity is probably due to their extreme usefulness. Their ability to add such richness and depth to otherwise flat website designs with ease, may also factor into that equation.

In fact, one need only look around the web to find some stunning examples of these elements being deployed with fantastic results. Or one can look at the showcase we have assembled for you below. We have already done some of the leg work for you. The sites we gathered have all used textures or patterns in their website designs, and in such stylish fashion that we felt our spotlight should shine their way.

Textured Web

Rockatee is a dark design with a geometric patterned header and footer and two different textures. Both brilliantly installed in the background, one of the main content area, and a subtler one above the header.

Create Digital Media has a beautiful open, expansive website, and the minimal design is complemented by the light textured background.

Celebration Invitations has a large header that uses a light texture to really make the space pop and not feel at all underused. The patterned background adds an extra touch of style to the site.

Stedesign is a vintage styled site in which the design uses a number of textures to really pull the look off with flawless execution.

Stephanie Walter has a lovely design with a texture running all the way down and through the site. Subtle and stylish.

HD Live is another site with an extra subtle background texture that adds a richness to the open design.

The Threepenny Editor has a unique and stylistically retro look and feel, with the patterned background tying the design together in a light, graceful manner.

Alex Catalan has a site design that uses a slight patterned background to give the minimal, oversized style a depth that works wonderfully. The soft texture in the footer and the header also complement the website’s design.

Steely M Music Production uses a lined pattern to pull the somewhat unconventional layout together.

PunchTab has used a delicately textured background to set off the over-sized buttons and content areas. Very nicely paired with the rest of the design.

the Buffalo Lounge has a dark themed site with a wood grain patterned background that gives the entire design the perfect edge.

Adrian Tingstad Husby – Portfolio design is another expansive site layout that adds a touch of attitude and grunge to the otherwise clean style with a patterned background.

Decadent Cakes uses both a colorful pattern and an extremely subtle textured background to give the site a combination of class and vintage style.

Qasim Aziz Portfolio is a simple design with a lightly grained texture in the background for that added punch to the site’s look.

VUURR uses a pair of simple patterns in their website to pull off a design that is big and bold and anything but simple.

Rob Davis uses a delicate texture in both the header and footer, along with a slight patterned background to make this minimal design stand out from the pack.

Holistic Designs has a touch of grunge in their site via a textured background that really catches the eye, but does not steal away focus as the content scrolls across it. Perfectly balanced.

Launch Factory uses a combination of textures, in the background, throughout the content headers and titles, and more for a pitch perfect design full of grunge.

Agenciart has another big and bold design that is brilliantly complemented by the subtle texture in the background.

rtraction is the website for a creative design agency and their use of a light texture in the background works to set off the over-sized content and images. Though the areas where the texture is omitted ends up feeling somewhat less visually comfortable, though the colors could have something to do with that. However, it does seem the texture would soften their slightly harsh feel.

Chriswi is an example that stands out from the last, as it uses the texture down throughout the site (except for the footer) and the colors that might otherwise feel somewhat harsh on the eyes have a softness it seems the texture adds to them.

Valpo Creative uses a delicate texture in the background which does work nicely, though the site would seem better suited to have the content displayed against this lightly textured background rather than the box it sits in.

Danger Brain uses both a pattern for the background and a light texture in the header. The pattern seems like it could be visually overwhelming, but with the content box relegating it to a smaller perimeter it makes it very complementary to the tone of the site.

Open Hand Type has a couple of less than subtle textures employed in the somewhat compact design making their bold look stand out perfectly. Giving the site a certain character.

Oven Bits has a huge header whose open space is lightly textured giving it a softness and retro style. The footer has a matching texture that balances the site wonderfully.

That finishes off this showcase, but feel free to leave us your thoughts in the comment section below. Also drop us a link on a site that you feel we overlooked, and should have included in this collection if you are so inclined.

(rb)


  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress