Martini Lab Blog

June 7th, 2009 | Tags: , , , , ,

Thanks, Lisa!

Scribbr is a tiny web app for drawing and posting to twitter. With jQuery, the user can control the color, size, opacity of the cursor to draw on the canvas element 320 x 320 in size.

Last summer, I had the opportunity to work with Eisner Award winning cartoonist Scott Kurtz of PVP. During one conversation we had, he came up with a punch-line to what we were talking about. I don’t remember what the subject was, but the punch-line involved a mock editorial cartoon. He grabbed a 2″ x 2″ sticky note pad and drew the cartoon. We had a laugh.

This would never happen online. At least, not in any convenient, simple, method that I was aware of.

Right now, it’s very crude. The controls are, admittedly, non-intuitive. There is no ‘Undo’ other than clearing the canvas and starting over. It doesn’t support older browsers either.

I’m actually quite okay with that last part. This site was immensely fun to build. Getting it to work on IE6 would have taken away from that. Right now, I know that it works on FireFox 3.0, Safari 4.0b (or WebKit nightly build), and Google Chrome 2.0.

Zeus Comics

Zeus Comics new design went live Thursday

If for no other reason than finally consolidating the past five years of css style changes into some semblance of organization, this redesign was a long time coming.

Zeus Comics and Collectibles is an award-winning comic book retail store in Dallas, Texas. For almost nine years, Zeus has been serving the needs of the comic book reading community in the DFW area in the only manner one can expect from a locally gay-owned business – fabulously!
Read more…

May 21st, 2009 | Tags: , , , ,
Twitterific -> YouTube -> Fail

Twitterific -> YouTube -> Fail

Just how long does it take for a YouTube video to become available on the YouTube iPhone app?

Seriously, if YouTube accepts .wmv, .avi, .mkv, .mov, .mpeg, .mp4, .flv, .ogg, 3gp and outputs to multiple .flv, mp4, 3gp… OMG, why then is the link I just tapped not available?

I understand that once uploaded, videos take time to convert for display. Having uploaded some from my own iMovie library, waiting for YouTube to do its magic without a progress bar is torture. But once it’s done and properly playing on the website, the video still has to become available for HD (if available), mobile, etc.

As we become more connected on more networks on new devices, our content experience should become more homogeneous. Websites should get closer to looking the same on our desktop computers as they do our mobile devices. Instead, because of mobile phones and netbooks (more specifically, their wireless connectivity) web designers, who once enjoyed building for higher display resolutions and bigger bandwidth, find themselves thrown back into building sites that are “dial-up” friendly. It’s a whole new browser war sans Netscape Navigator.

Which brings me back to YouTube on the iPhone. Video codec H.264, briefly put, is designed for both high-def and small bandwidth playback. Since YouTube offers multiple versions of the same video, it has to take the original video upload and convert it several times. And since the only way to view YouTube on Apple TV or the iPhone is with h.264, YouTube needs to make additional conversions/transcodings.

In the end, content for the web isn’t just for the browser. It includes phones, game consoles, dvr (TiVo), and any future devices we don’t yet know we need. And all of them need the same content in their own specific formats.

All of this means that the next time I see something along the lines of “@amboy00: too funny! http://tinyurl.com/pqhugm,” I’ll probably have to wait until I get back to my desk to see the funny.

May 15th, 2009 | Tags: , , ,
Queen Album Cover

Killer WebKit

As a follow up to yesterday’s woeful tale of using WebKit’s proprietary css properties, I wanted to follow up with a couple examples of how one can use these features without getting all “bevel-ly”

The only benefit of text-shadow is not downloading graphics for what can be expressed in css. The same goes for -webkit-border-image, -webkit-gradient, -moz-border-radius, anything that keeps a web designer from having to launch Photoshop is a boon to bandwidth.

Here are two examples of using some WebKit css gradients.*

Update: You must have the Chrome 2.0 or Safari 4.b for these to work.

Example 1. is brought to you by “Killer Queen”

This similar looking display to that of the iPhone album display uses a radial gradient (opposed to a linear) as the background for the track names. The overall effect is a dim light. The odd numbered tracks also use a gradient to take advantage of -webkit-gradient’s support of alpha values.

Example 2. is a css calendar.

This one combines linear gradients and javascript arrays. Because -webkit-gradient can use rbga formatting in place of the usual hexadecimal value, calculating the values from color to another was much easier.

The drawback to these browser specific properties are, well, browser specific. While adding a gradient value to your div id=wrapper might give it a groovy drop shadow effect on Safari, nothing is happening on either Firefox, and much less for IE.

The workaround at this point is to browser detect.

1
2
3
4
5
6
if(jQuery.browser.safari) {
$('#wrapper').addClass('problem-solved');
}
else {
	$('#wrapper').addClass('wah-wah-wah');
}

Or whatever.

May 14th, 2009 | Tags: ,
Specimen 7

Specimen 7

Someday, all the nifty Photoshop Blending options will be available as CSS properties. Mark my words! In the mean time, we’re kind of stuck with drop shadows, and now gradients (and text strokes) for WebKit browsers. Too bad you can’t use them together.

In order to take advantage of the background clipping, the color needs to be transparent. First off, that pretty much ruins any other browser from displaying text. So this is only useful to Safari users (not even the iPhone currently supports it). In Photoshop, you can get around having a transparent color and still having a drop shadow by setting that layers Fill Opacity to 0% while the layers opacity at 100%.

Also, using this technique has some odd behavior with padding. In my example, I couldn’t set padding to the parent div without the effect inheriting that padding. Restating the padding didn’t affect it either.

Here is the example: webkit-background-clip.html

Now, you can add the -webkit-text-stroke and that will work with text-shadow, but only on the stroke and not the text. I’ve yet to find an example that uses all three without looking like one of Superjail’s Doctor’s genetic experiments.

Perhaps it is for the best, getting these to work together might have been the next blink.

May 7th, 2009 | Tags: , ,

twitter tee shirt caption
Some of the things best left unsaid, yet said anyway, have ways of coming back to haunt you. But at least you get a $1 commision from it.

Twitshirts by Amboy00 (that’s me!)

Safari’s WebKit has a funny behavior of displaying animated gif files at a lower frame rate than Firefox. From what I can tell, WebKit (including Google Chrome) caps the animated gif frame rates at 10fps. While it may be faster than some IE6 browsers, it’s not exactly helpful for those files with higher frame rates.

For example, the popular ajax loader file that hails from Apple’s own asynchronous progress indicator, has 12 points and loops around once a second. Well, for one thing, 12fps is really choppy (so I’ve made the fading spokes a little more smoother at 24pfs), but it already plays slower on Apple’s nifty browser.

jQuery to the rescue

Did you know that jQuery can control css background positions? Are you thinking what I’m thinking?
Read more…

April 8th, 2009 | Tags: , ,

Getting the Mouse position in jQuery is very simple. However, getting the position from within an element take some extra steps.

Normally, a javascript event such as onmousemove would use event.layerX and event.layerY to get the coordinates of our mouse when it moves.

For jQuery, pageX and pageY will return values from the top left of the page and not the layer. Unless the element you’re working with is left-aligned, you need to calculate the offset of that element as well. Not only that (unless there is a better way to do this) the offset values returned doesn’t include the offset values of the parent tag.

In this example, I have two divs.

1
2
3
<div id="frame">
	<div id="content"></div>
</div>

And you can imagine that #frame is centered and has padding. Getting #content’s offset won’t include anything outside of the frame so $(#content).offset().left; would only get you the distance of itself and its parent.

Get your layerX for jQuery

For this example, we are using a known set of divs so we can just write out each div in this script.

1
2
3
4
5
6
7
8
9
10
11
12
13
<script src="js/jquery-1.3.2.min.js"></script>
 
<script>
$(document).ready(function(){
	$('#canvasForeground').mousemove(function(e){
		var myLayerX = $('#content').offset().left + $('#frame').offset().left;
		var myLayerY = $('#content').offset().top + $('#frame').offset().top;
		var x = 0, y = 0;
		x = e.pageX - myLayerX;
		y = e.pageY - myLayerY;
	});
});
</script>

The variables are declared inside the event function to handle window resizing. Now were this a more complicated page and the element in question has deeply nested or even dynamically generated, writing our all the parent tags wouldn’t necessarily work (or be very efficient).* But the approach would remain the same. That’s it!

*standard apology for poor code writing skills

April 1st, 2009 | Tags: ,

My previous how-to showed a new way to look at the slider function featured at the Apple.com/mac site. This one goes to Apple once again and their bucket ads shown in the iTunes Music Store (screen shot). The buckets are what I’m calling them. They are the three spots at the top of the music store which rotate graphics like the slideshow functions of many galleries. The difference is that these three take turns.

I was able to replicate this function using Scriptaculous on our beloved comic shop website (latest screen shot). But after a few years of constantly adding duct tape to the site, it was time to move everything to a single framework. And that mean making this triptych banner script run on jQuery. Hopefully without a lot of html recoding.
Read more…

March 25th, 2009 | Tags: , , ,

If you haven’t seen Apple’s product slider in action, you must check it out. It’s a horizontal gallery of their products with horizontal slider controlled with javascript. I believe they are using the scriptaculous motion for this, but there should be a way to build this in jQuery.

Truth be told, I was a die-hard fanatic for scriptaculous/prototype, but after ExpressionEngine announce their adoption of jQuery for EE 2.0, it was time to grow beyond the one framework pony.

Luckily, someone already set out to build the slider in jQuery. And major hat’s off to Remy Sharp for a great approach to this. If you looking for a way to build your own slider, start there first.
Read more…