Quantcast

How to render text using HTML Canvas

I’ve been using HTML5 Canvas for a few web apps, and for the last year I’ve been avoiding rendering any text because Canvas lacks text support. Over the last year, several people have come up with workarounds.

  • Firefox decided to add a non-standard method called drawWindow(), which lets you composite a hidden iframe with html text.
  • The TextCanvas project adds a drawString method to the canvas api, which positions a HTML element on top of the canvas.
  • The Variable Width Canvas Fonts project pre-generates an image containing characters at known locations and then uses drawImage to display the necessary characters.
  • The very cool CanvasPaint project went nuts and implemented vector fonts in canvas! (more info here)
  • None of the above links work in Safari. Despite being the original developers of Canvas, Safari’s Canvas support is extremely buggy. Things work better with the nightly builds, but even then, many things are broken.

I’ve been thinking about giving up on supporting Safari completely, and maybe trying out dojo’s gfx 2D graphics API, which has text support but uses SVG/VML instead of Canvas. For the time being though, I found a silly workaround. Since I only need to display numbers, I can just create 10 pngs, one for each digit. Here is a bash script that creates the number pngs using ImageMagick:

for ((i=0;i<10;i++)); do 
     convert -size 75x100 xc:transparent -quality 100 -font Courier-Bold -pointsize 144 -fill green -draw "text -5,95 '$i'" g$i.png; 
done

Here’s a blurry screenshot of how it looks:
6.jpg

visual complexity

visualcomplexity.gif

I love this site! It’s a collection of visualizations of complex networks from all manner of disciplines – Art, Biology, Transportation, Music etc. A treasure trove for design / data visualization geeks. There’s even a downloadable poster at the bottom of this page over here.

Why I did not renew my subscription

“Exploring power, ownership, and equity in an early childhood classroom.” My dear nerds and geeks: do you feel that playing with Legos led you to become heartless, capitalist pigs? Or was it something else? Or do you deny being piggly altogether?

cover.jpg

I do find many problems with public educational methods these days. I teach in the Oakland public schools – a big mess. But I can’t even read this rag any more. It takes so much brain power to un-un-un-un-spin (alternatively, anti-un-re-de-construct) their flimsy arguments, that I end up more confused than when I started. And then there’s my very strong gut feeling that LEGOS are a force for good in a kid’s life. I’ll stick with that and stop paying for this kindling.

How Weird is ON for 2007!

An update to this post

How Weird is on for 2007, but this will be the last year on Howard Street:

Thank you for all the love and support we have received. This is going to be the best year yet, and our last year in our traditional location – on Howard Street between 11th and 12th Streets.

IMG_1464.JPG

cats in sinks

catInSink.jpg
So I’m not sure what’s up with all these cats in sinks…do cats really like hanging out in sinks??? I mean…it’s cold…and wet…and slimy. How could it be that they’ve got *thousands* of submissions and a book coming out at the end of the year?? (and if they’ve got thousands, what are we doing with a blog?! we should have a pineapples-in-sinks-site!! or something. admittedly pineapples are prickly and not as cute, but still.) Anyways, I bet all these cruel people are putting their cats in cold sinks just to get a cute photo…

…when really, I’m sure their kitty would rather be doing this.
gamerKitty.jpg

How Capital One Ruined my Saturday

Captial One is a crazy-ass bank. They send me a new credit card offer every few days. Mail from Capital One is more than half of all the junk mail I receive! I am always scared of identity theft, and the sheer volume means that every once in a while I have to set aside a few *hours* to deal with the pre-approved credit card offers they send me!

5 steps for dealing with Capital One Junk Mail

  • Open the envelopes and separate the contents.
  • Shred the credit card application, helpfully pre-filled with my name and address.
  • Compost the shredded applications.
  • Recycle the assorted paper and cellophane-window envelopes.
  • Trash the plastic fake credit cards and *magnets* that are glued to the applications. Why the fuck is Capital One sending me so many magents? This must be costing them a fortune!

Here is a picture of the three piles of bullshit that Capital One sent me. All this in just a few weeks! Next month I will have to spend another Saturday afternoon dealing with this crap…

IMG_3024.JPG

Wild Side West

I love Wild Side West. It’s my favorite bar in Bernal, and maybe my favorite bar in the world. When San Francisco gets cold and misty, I love their fireplace. When it’s hot and sunny I love the fabulous garden in the back. Whenever the evening plan seems a little lackluster (like on Friday), re-routing to the Wild Side is a good way to ensure a fun night!

IMG_3020.JPG

IMG_3013.JPG

Warning: Extremely Comfterbuls

Jess found this comfy red couch on craigslist for a hundred bucks:
IMG_3028.JPG

It goes well with our red Alice chairs, also from CL:
IMG_3029.JPG

We love craiglist! Here are some things we have gotten recently from CL:

  • our apartment
  • all our bedroom furniture
  • the red chairs
  • the red couch
  • the tikicrawler remote control system
  • the red pickup that we use to haul all this stuff around

they’re like banana peels

frogsOnRoad.jpg

Spotted while on my bike somewhere near Rodeo Beach today. I didn’t see any frogs though.

The Discordian License

Until 1989, a published work had to contain a valid copyright notice to receive protection under the copyright laws. But this requirement is no longer in force — works first published after March 1, 1989 need not include a copyright notice to gain protection under the law. –fairuse.stanford.edu

Under the current copyright regime, every scribble and doodle published on TikiRobot is automatically granted copyright protection. This is not a good thing. We want people to use our scribbles and doodles to make wonderful things.

What do to??? We could license our blog under one of the many Creative Commons licenses. While this would help support the Creative Commons, and a machine-readable CC-license helps artistic robots find our work, choosing the right CC license is difficult, and I’m now getting bored of contemplating the many choices.

We are all geeks and nerds here, so the GNU Free Documentation License might be appropriate, but it is very long, with eleven sections and an addendum, and I never finished reading it.

While searching for an appropriate license, I was reminded of a strange work I read long ago, The Principia Discordia, a manuscript of great wisdom and eloquence, which was released under a unique and strange license. The publishers of the book reversed the rites, and dedicated the book to Kallisti, The Prettiest One, and encouraged readers to reprint what they liked.

This is a great license. Five words long. No need to be complicated. Better than putting the blog in the public domain because the Discordian License contains a cool unicode character, Ⓚ, also machine-searchable by robots. We should use this for our blog!

San Francisco Ⓚ All Rites Reversed

license.png

Ⓚ2007, Planet Earth – All Rites Reversed – Reprint what you like

Scanned copies of the Principa Discordia available at fnord

Frances E. Allen wins ACM Turing Award



IBM Researcher Frances Allen won this year’s A. M. Turing Award, the ACM’s “most prestigious technical award.” The mainstream news story here is that Allen is the first woman to win the award although as
The Register notes

As Turing himself was famously gay, there are now relatively few inclusiveness milestones for the prestigious gong to pass.



An annoying property of these types of news stories is their bland and tasteless descriptions of a person’s important contributions to an academic field, to wit:

Her pioneering compiler work culminated in algorithms and technologies that are the basis for the theory of program optimization today and are widely used throughout the industry.

And that’s the detailed version, taken from Allen’s bio page.

Don’t hold back guys … where are the papers? I love seeing old scientific papers, thinking back to a time when techniques that are printed in thousands of textbooks we love to hate were just being invented.

I wish I could tell you what Allen did, but our stupid society keeps that information locked up. After over an hour of search, I found an early Allen paper called Control flow analysis … a hearty fuck you to the ACM (of which I used to be a member) for keeping this and all the rest of the Computer Science corpus locked up behind a password protected for-pay-only website. Scientific knowledge belongs to all of us.

Control flow analysis is my favorite topic from my favorite CS class, Compiling Techniques. Control flow is used by compilers to make my crappy code run faster. The idea is to build graph of the various execution paths that are possible in a given piece of code and then using graph traversal techniques to remove redundant code paths or introduce new paths that exploit hardware features. I also like it because debugging control flow (when you are making a compiler) involves making pretty pictures as in this comparison of three different control flow algorithms.

In Figure 5.5 the three approaches are compared using a method of medium size. The start block is marked dark gray, loop headers are red, blocks with loop depth greater than zero are orange and blocks without successors are drawn green. All other blocks are painted yellow. This way one can easily see the differences between the three algorithms.





Link to Frances Allen Turing Award on CNN

Tour of California

tourOfCalifornia.jpg
So I’m kind of bummed that I missed all the bikes that zipped through the Bay Area for the Tour of California last weekend (my mom was in town and it was Chinese New Year so there was family stuff to tend to) but I just discovered that I can follow all the other stages live from this nifty web app. I don’t actually follow cycling and have absolutely no idea what’s going on (there’s some information overload happening on this app)…but I like looking at photos of the landscape because it gets me psyched for June when I’ll hopefully make a similar (but shorter and muuuch slooooowwwer) trip down the coast. It also gets me psyched for the weekend so i can go on a bike ride!

Slide Listed #2 in Business 2.0′s “The Next Net 25″



Last year Business 2.0 published a new yearly listing called “The Next Net 25″. As corny as that sounds it’s a nice list to be on … last year’s list included Digg, Trulia, Technorati, JotSpot, Writely and …… YouTube.

I am reproducing the list here with my comments because apparently Business 2.0 doesn’t know how to use the UL tag.

It’s getting crowded on the Web 2.0 frontier, but there are still some startups that truly stand out. Business 2.0 Magazine identifies the ones most likely to strike gold in 2007.

Link to The Next Net 25 on Business 2.0

Pair Programming

dav.jpg
I never understood what pair programming was until now. Glad someone drew a picture for me. (found on Pivotal blabs).

How Weird Denied Permit! Save the Faire!

My favorite street fair in San Francisco has been denied its permits for 2007 :(

The How Weird Street Faire was denied its permits on Thursday Feb. 8th because of the emotional opposition of a few neighbors. We are appealing the decision, and have a hearing on Thursday Feb. 22, 2007. The public is invited to attend the hearing at 10am, located at 1 South Van Ness Avenue, on the 7th Floor

There are 2 ways you can help.

1. Take 10 minutes and send a letter to the City. See template below.

2. Take 1 minute and sign the Petition. Scroll down to the link below.

Link. Link to petition.

Podcasts for you to listen to…

I promised Peliom that I would post a list of my favorite podcasts, so here it is!

I also listen to non-music podcasts from Learn Hindi From Bollywood Movies, which always cracks me up, This American Life, and RadioLab, which is like This American Life but with a science bent.

Shouldn’t TR have a podcast?

Update: I forgot to mention that Mixmaster Morris and friends post mp3s of his shows on the MMM tribe. Also, i found this on jace’s above-linked blog and am still laughing..

The Camel Bookmobile

The Camel Bookmobile in Kenya is the best thing I’ve seen all day! Check out the pictures, video, donation info, and amazon wishlist. They need donations of books in English and Swahili. You can ship eleven pounds of your old books to them for $11.55. (via boingboing)

Photos from Dorkbot

I gave a short and silly opendork presentation at about TikiGraffiti last night. Here is a photo that Scott Beale of Laughing Squid took of me in front of Jonathan Moore’s and David Fine’s External Combustion Engine, an awesome machine made for monochrom’s Roböxotica festival.

Last night was awesome.. Dorkbot, monocrom, SRL, Electrum, Tamale Lady, Mooninites, Laughing Squid, robots that make music and robots that make tiki drinks…. Sometimes I love San Francisco!

Karen has a bunch of pictures, including a bunch from my opendork. Thanks to Karen Marcelo and Michael Shiloh for organizing, and thanks to all the awesome presenters :)

Learning how to read…

Did you know that Amit Gupta, who wrote the WP syntax highlighter that we use, also has a Hindi blog? Reading blogs is a fun way to practice Hindi.. I would start a Hindi blog too but typing in Devanagari is so hard!

To whoever drafted our current copyright laws…

BiteMeTee.gif

A while back, I designed this tshirt with the intention of giving it to a friend for her birthday, but I never got around to printing it. I found it on my computer a couple days ago and finally decided to get one made so I sent it to Zazzle (an online make-your-own-tshirt-or-whatever-else-you-want shop). Today I got an email from Zazzle that said

Unfortunately, your order has been cancelled because it contains content that is in violation of United States copyright and/or trademark laws. Specifically, your order contains a product(s) with a copyright-protected image of Pac Man.

This really bums me out :-(

Happy New Year!

pigs.jpg

alright, I’m a day late, but it’s the year of the pig. My aunt made these cute little pig ornaments. I think they are plotting my ruin for eating bacon today.

Hercules Hooks

A few months ago I randomly saw an informercial for Hercules Hooks on a TV somewhere, probably at a bar. It’s a bit like a Molly Bolt that doesn’t require any tools. I love it when this “as-seen-on-tv” schlock is actually useful. So I got a few to see what the deal is. I just noticed you can buy them on amazon instead of the the quaint but lame AsSeenOnTV website.

So the deal is they do work, and I think they work well. It’s got the strength of a Wall Hanger but the wall damage is just slightly more than a thumb tack. The problem is they *only* work on straight-up drywall with at least 3 inches of open space behind it. If you are hanging something and there is a stud behind the drywall, or a solid cement backing is the case for about 50% of my wallspace, you would get better results with scotch tape.

Link to Hercules Hooks on Amazon.com

Announcing the TikiGraffiti WordPress captcha Plugin!

I got sick of our SecureImage captcha. I couldn’t type in the correct code a third of the time, and it looked ugly. So I wrote a new hacked up our existing captcha plugin to show pictures of graffiti and street art instead of computer-generated text!

Please help me test it out by leaving a comment with a link to a picture of street art. I found some great ones in this Flickr set by Trois Tetes. You can also use Flickr Creative Commons search to “find content to modify, adapt, or build upon”. Please make sure that the image has a CC license!

I’ll add attribution for the images and then post the code if no one finds a bug!

Update: Get it here!

Pillow Fight

Arena and I got stuck in a pillow fight last night. Ouch. I got pummelled. (pillows hurt more than you’d think!) Here’s a wee video snippet i shot with my phone.

jacobus returns

Older Posts »