Experimenting with CSS Exclusions

Okay, this is going to be scattered and on the cutting edge side, so buckle in. Adobe has been hard at work making the web a little bit richer when it comes to how type is displayed. A great example of that is CSS Regions, which let you create linked islands that text can flow between so you have a lot of control over how text gets laid out on the screen. That’s currently in the “Canary” builds of Chrome and if you go to about://flags and turn on “CSS Regions” you’ll be able to view the demos. The other thing we’ve been working on is a bit further out, but it’s in the same vein. It’s called CSS exclusions. It essentially lets you create more interesting islands of text in the form of shapes that text will flow around. At this stage it’s still very, very early. In fact, the only way to test CSS exclusions content is with a special build of WebKit that’s available on Adobe Labs.

The Backstory

A lot of the demos associated with these features are associated with magazines, and especially with the iPad 3 coming out, it’s going to be critical to be able to build expressive content that scales. Since magazines are mostly text, expressive text will be a big deal. I’ve been mulling over doing a beer-related magazine and figured it would be cool to try out some of the CSS demos to create something that might look unique and fit in a beer magazine. So I thought “hey, I could create shapes of different beer glasses and run text through those!” That was the basic premise. As I dug in, I found a couple of caveats. Most I’ll get to throughout the post, but the biggest one is that there currently isn’t a version of WebKit that has both CSS Exclusions and support for flowing across CSS Regions. So my original idea ran into a small roadblock but I’ll be able to fix that down the road.

Creating regions

The CSS Exclusions spec supports SVG’s basic shapes. That includes circles, rectangles, and polygons. At this point it can’t do arbitrary path data but you will be able to use SVG data according to the spec. So I started with creating the various types of beer glasses in Illustrator with the polygon tool. Then I had to set up the glasses on the page and make text flow correctly. The standard method seems to be to create two CSS classes, one for the properties that every region or shape will have, and another class for the specific region, in this case, glass type. I called my main region container and it looks like this:

     .container{
          position:absolute;
          height:500px;
          width:300px;
          text-align:justify;
          margin-top:0px;
          font-size:10px;
 
          -webkit-wrap-shape-mode: content;
          -webkit-render-wrap-shape: none;
          -webkit-hyphens:auto;
     }

The main properties are those three on the bottom. The first one tells the browser what I’m doing, and that’s wrapping the content within a shape. I think the other option here is around, which would make the shape an exclusion but I don’t think that’s working in my build of WebKit (or I’m doing it wrong). The render-wrap-shape is good for debugging as it shows you an outline of the shape so you can see how it’s appearing. I found this incredibly helpful as I laid objects out on the page. The last one, hyphens, lets you tell the browser how you want it to break up text. If you go for none there, it will only flow full words within the content. Otherwise it fills the content as much as it can before breaking words with a hyphen. For fuller-looking shapes, go with hyphens set to auto.

Next I had to set up the specific glass shapes. The hardest part for me was lining things up correctly. The way I created the polygons I think made it tougher to lay out. It also doesn’t change as you resize the page because I’m not using percentages (if that’s even possible with polygon objects). It looks kind of ugly but to define a shape we just have to use webkit-wrap-shape and give it the values. Here are a couple I did.

     #irishpint1 {
          padding-left:0px;
     }
 
    .irishpint {
          -webkit-wrap-shape: polygon(157px,473px 106px,472px 93px,453px 91px,432px 87px,401px 84px,368px 78px,332px 70px,294px 61px,255px 57px,225px 55px,191px 55px,165px 57px,128px 63px,118px 165px,118px 274px,120px 279px,128px 282px,164px 282px,190px 282px,226px 274px,263px 267px,296px 257px,337px 253px,368px 250px,397px 246px,427px 244px,453px 233px,473px 173px,473px);
     }
 
 
     #weissbierflute1 {
          padding-left:250px;    
     }
 
     .weissbierflute {
          -webkit-wrap-shape:  polygon(104px,470px 82px,459px 81px,439px 89px,400px 105px,344px 102px,294px 86px,238px 72px,183px 66px,128px 62px,77px 59px,39px 58px,17px 57px,0 280px,0 279px,17px 278px,41px 276px,74px 271px,128px 265px,182px 251px,238px 234px,299px 232px,344px 248px,400px 255px,434px 252px,463px 215px,473px);
     }

So they’re some semi-complex polygons. I also used the div tags to set up padding and lay things out. One of the things I learned is that CSS regions/shapes can only be applied through classes, you can’t define the properties based on id’s. But that may change.

So with all of those glass polygons, it looks like this:

What the page looks like in a browser that supports CSS Exclusions

What the page looks like in a browser that supports CSS Exclusions

That page is up on GitHub but you won’t be able to view it in your browser so you’ll have to be looking at it with the special browser from Adobe labs.

Making it More Interesting

After this I thought it would be cool to do a bit more with the shapes. Beer has a rating scale for color called the SRM scale. Types of beer have a general range of SRM scales and since some glasses roughly correspond to specific types of beers I wanted to see about creating a background for each shape that would correspond to the SRM scale. But even more than that I wanted it to change with the glass so as the glass got narrower, the background would become more transparent just like a real beer glass. Unfortunately it didn’t work quite the way I wanted, but I learned a bit about using CSS shapes along the way. Originally I just started by giving the div a background:

     #irishpint1 {
          padding-left:0px;
          background: -webkit-gradient(linear, left top, left bottom,
                                             color-stop(.8, rgba(152,83,54,1)),
                                             color-stop(.2, rgba(152,83,54,.7)));
     }

But the CSS shapes/exclusions don’t actually change the shape of the div, they’re only worried about wrapping the text within the div. So my page just looked like this:

What the div tag looked like when trying to set the background

What the div tag looked like when trying to set the background

Luckily webkit-mask-image came to the rescue. With that, I could create a mask based on a file, in my case an SVG file, and use that to mask a block element like a div tag. So I went through and created an SVG file for every glass shape and then used those as the mask and set the background accordingly with rbga() properties in a gradient. The final version looks like this:

And here’s a clean(ish) version without the backgrounds. I kind of like this one better.

Update: If you have a browser that supports exclusions you can check out the demo here.

Final Thoughts

It’s really, really early for CSS Exclusions but there is a LOT of potential there and even the stuff that works now is a lot of fun to use. This was just an initial dive into the feature to kick the tires, and because it’s so new, there are a lot of gaps both in my knowledge and what I was able to do. One of the things I tried was using CSS3 transitions to animate the -webkit-wrap-shape property. That didn’t seem to work, it could be on the roadmap.

It’s a fun feature and it’s really fun to be able to give it a shot while it’s still in the early stages. For magazines or any kind of rich text content, exclusions are going to be a fantastic way to make stuff pop. If you want, you can check out the project on Github. I’ll probably be modifying it and improving it as the spec evolves.

Beer and Cheese Pairings with A Dopple-Weizen, a Dubbel, and a Stout

I know this isn’t a tech post, but I’m working on getting back to blogging like no one’s reading. So bear with me and hopefully it adds a bit of personality.

I’ve been experimenting lately with cheese and beer pairings. I’m obviously a little bit biased, but I think the diversity of beer makes it a fantastic compliment to cheese. It’s not a new thing, but especially in America, which has taken the wine and cheese pairing route, it’s a bit of a niche. Which leaves lots of room for exploration which in turn leaves lots of room for exploration.

For this particular round I took 3 different beers and 3 different cheeses. The picture has 4 beers, but we didn’t get to the IPA. Kind of a bummer because IPAs make for some really interesting beer pairing, but alas, some beer has to be saved for later. Our beers were:

  • Lagunitas Dopple Weizen – A surprisingly crisp and tangy beer. They use yeast from Bavaria which I think gives the beer a really interesting flavor that mixes nicely with the crisp malt profile of the Dopple. Still retains a lot of the wheat character of the beer making it a mix of flavors that opened up a lot o cheese possibilities.

  • Full Sail Sanctuary 2011 – This beer deserves a year or two of conditioning in the bottle, but desperate times and all that. A great example of the dubbel style; bready, carmely malt goodness mixed with the banana, spicy belgian yeast. Slight hops to round out the beer, but basically a very drinkable Dubbel all around.
  • Alaskan Perseverance Ale – I can’t get enough of this beer. It’s a typical stout but brewed with birch syrup and fireweed honey. Both give the beer a very bitter sweetness which is a great compliment to the standard stout. It adds just a slight bit of extra to it that makes it stand out and makes it a very complex and fun to drink beer. It’s a 25th anniversary beer so grab some while you can.

Now, on to the cheeses:

  • Cypress Grove Chevre Truffle Tremor – Tangy, truffle goodness. Has a very sour, almost yeasty flavor to it. It’s an aged goat cheese, so the texture plays games with the beer a bit, but the truffle flavor makes it a unique pairing.
  • Willamette Valley Farmstead Gouda – I find Gouda to be a great beer pairing cheese. It’s got a creamy, nutty flavor that mixes really well with a lot of the more Belgian beers ends up bringing out some great flavors. This is an excellent (and Northwest local) Gouda to be the pairee.
  • Sartori Romano (grated) – Tangy, earthy, nutty with a nice finish. I find the italian hard cheeses kind of tough to do pairings with, but we had this for another part of the meal, so I gave it a shot. Not a major success, but no cheese is bad.

On to the pairings!

Lagunitas Bavarian Style Dopple-Weizen

The best pairing on the Lagunitas was with the Gouda. The earthy flavors of the Gouda really highlighted the estery parts of the Bavarian yeast in the Lagunitas. Taking a bite of the Gouda and a sip of the Lagunitas together was almost like an entirely new beer. The wheat and yeast flavors were enhanced and it really complimented the sour, tang of the beer. Probably my favorite pairing of the night. The Chevre didn’t really add a ton to this beer. Both were good but there wasn’t the interplay of flavors that I got with the Gouda. It was the same with the Romano. The two definitely worked together, especially the more nutty parts of the Romano, but it didnt’ quite dance in the same way as the Lagunitas and the Gouda did.

Full Sail Sanctuary 2011

The Full Sail and the Gouda actually weren’t as great a pairing as I was hoping. The flavors generally worked together, and some of the earthy notes of the Gouda played off the bready malts of the Full Sail but I was kind of disappointed with the overall result. The Truffle on the other hand, was much more interesting. The earthy, musky flavors of the truffle really did great things to the Full Sail. I think that the banana/spice notes in the Dubbel brought made a great contrast to the earthy, almost bitter parts of the Chevre. It’s kind of like the Truffle added some distinct bitterness that might usually come from hops in another style of beer, but in a way that was completely complimentary to the Full Sail. Great stuff. The Romano was a bit of a dud. Again, not a bad combination, just not one that had a ton of impact on the beer.

Alaskan Perserverance Ale

By far the hardest beer of the night to pair was the Perseverance. I find stouts hard enough to pair with cheeses, but with birch syrup and the just-off-center sweetness makes it even tougher. The Truffle stood up pretty well here. The truffell flavors didn’t exactly compliment the birch syrup sweetness, but it was kind of an interesting juxtaposition. The combination of that very tart aftertaste with the lingering bitter sweetness tickles the tongue a bit. Sadly, the Gouda didn’t stand much of a chance. It’s flavors just got overwhelmed by the beer. The salty/creamy parts of the Gouda were great, but in order to stand up to a big beer like a Stout, you have to have it in spades. Some Beecher’s Flagship might have been really interesting here. By this time we were out of Romano. It might have held up okay, but I have reservations. The Perseverance is a beer that stands on its own in a big way, so a cheese pairing is tough.

The winner was the Lagunitas and the Gouda. Just a really great mingling of flavors and a fantastic compliment. Second was actually the Truffle and the Perseverance. Maybe because I was three big beers in at that point, but the Truffle with it’s very tangy and creamy texture kind of held its own against the chocolate and bitterly sweet onslaught of the Perseverance. Surprising but tasty.

Beer List for Flash Camp 2011

Most of you know that I’m a pretty serious beer person. And since we have a fantastic beer store, City Beer, just up the street from the SF office, it makes it easy to get good beer for events like Flash Camp. I just finalized the list and we’ve got some great beers. At this point you should have no excuse; it doesn’t get better than mobile development and great beer.

We’ve got some great sessions, the product teams are coming to help answer questions, and it will be a lot of fun to show off the Flex mobile story in person.

Flash Camp San Francisco – April 30th

I am really excited to announce that this weekend we’re going to have a free, all day FlashCamp in San Francisco to celebrate the launch of Flex 4.5 and Flash Builder 4.5 starting at 9:00 AM, on April 30th. This will be a little bit different from some of our past Flash Camps that we have held, because it is during the day. However, this allows us to do some more hands on sessions as well as holding a coding session and contest for Flex 4.5 mobile application development

In the morning we’re going to have sessions covering all aspects of the mobile workflow. We’ve got a keynote from VP of Developer Tools, Ed Rowe, then Deepa Subramaniam, Flex Product Manager and Andrew Shorten, Group Product manager for Flex, are going to be doing an overview of the new mobile-specific features in Flex 4.5. We’ll also have 3 separate tracks to help you dive a little deeper:

  • Flash Builder for PHP
  • iOS and PlayBook development
  • UX design for mobile devices

In the afternoon we’ll bring out the tables and let you guys get to work building mobile apps. The Flex and Flash Builder teams will be on hand to help answer questions and help provide feedback.

The beer is being provided by City Beer Store, and I’m still nailing down the list, but we should have some fantastic craft beer at the event as well as pizza provided by Amici’s to help fuel the end of the day coding before we start giving away prizes and showing off mobile applications.

The Contest

One of the unique things about this Flash Camp is that after the hands-on session we’ll be giving away some prizes for people who have built a mobile application that afternoon. We’ll have a bunch of categories including most interesting use of Flex, most useful application, and most-well designed application. And you can win software, devices, an Xbox Kinect, and more, so there’s a ton of potential loot for you to take away.

You can also feel free to form teams, so if you are a designer-type, bring along your developer friends to fill out the team and you can show off the application as a team at the end of the day.

It’s going to be a lot of fun and I can’t wait to see what you guys put together. So register and come learn about mobile development with Flash and Flex, drink some great beer, and win prizes.

Untappd – Down with Mobile Apps

Update: This was recently the topic of a post by Fred Wilson, a very well known VC. I’m riffing on it now because I had an example today that drove it home for me.

I hate that mobile apps have taken the world by storm. I hate not being able to access something because I have an Android phone and all that the site has is an iPhone app. As a developer I hate having to build for a crap-ton of different platforms to make sure my users have access to my content. If only there was some global phenomenon that was accessible on a mobile device and was completely cross-platform. Oh wait, there is, it’s called THE WEB.

Why in the hell are we building native mobile applications when we can just build a web application to accomplish the same thing? Now, I understand that there are some requirements, like camera, that force us into the native realm. But if you aren’t using the camera or some other device-specific API, you should be building a web app.

This is why I love Untappd so much. Untappd is essentially Foursquare for beer. Instead of checking into a location, you can “check-in” what beer you’re drinking. Instead of doing the native app thing, they built a mobile site. I can access it from any device. It uses the browser-based GPS API to get my location so I can attach that to my beer, and there’s no stupid install needed. Just a wonderful web app with all of the functionality I need accessible from anywhere.

I realize there are some caveats beyond the device-specific APIs, but there has to be ways around them. One of the biggies is responsiveness. I think this one is kind of a cop-out because a great web app will be able to create a UI in such a way that it feels just as responsive as a native app. jQuery mobile and Sencha Touch are great at this. The biggest thing is monetization. Currently it’s really hard to monetize web apps and it’s very easy to monetize native mobile applications. This is one of the reasons I’m so jazzed on the idea of the Chrome web store. Being able to make money on web apps could (I think) help change the tide and encourage more developers to go the web app route.

It’s a shame that we’re able to do such cool stuff on the web but that developers are jumping through hoops to lock down their content to specific devices. We’ve got technologies like PhoneGap in the interim, but the sooner we get back to the web, the better.

P.S. My username on Untappd is ryanstewart.