Bob Ippolito (@etrepum) on Haskell, Python, Erlang, JavaScript, etc.

Round those corners with MochiKit.Visual


MochiKit received its first "third party" contribution today: MochiKit.Visual. Kevin Dangoor deserves some mad props for this!

Currently, the only spiffy thing MochiKit.Visual does is provide a method to round the corners of HTML elements (demo). Originally it was a port of the Rico code to do the same, but the current implementation bears little similarity to its ancestor.

Three big things (read: almost everything) have changed from the Rico implementation:

  • The API to round the corners of an element is a function, roundElement. Not some crazy construct-an-object-just-for-the-side-effects new RoundCorners. Man, some of the JavaScript out there (that people actually use!) should really be making more appearances on the The Daily WTF.
  • The Color object is no longer mutable. Again, WTF? I re-engineered the whole thing, so now it really bears more resemblence to AppKit's NSColor. Including the convenient Color.whiteColor(), etc. The Color object also supports a whole lot more stuff than the Rico version; it should be able to handle any color expression in CSS3 (including alpha support and HSL)! Oh, and it has tests, so you know it's not b0rked.
  • MochiKit.Visual has documentation.

Come on guys, JavaScript code is fugly. Write some documentation already. I think that if more people wrote docs, they'd realize how bad their APIs are. We've got plenty of docs. In fact, we have complete doc coverage. That's right, everything in MochiKit has documentation you can read without looking at the source!