Web Info & Tutorials

April 9th, 2008

CANVAS2IMAGE: SAVE OUT YOUR CANVAS DATA TO IMAGES

Ajax Canvas

More from Jacob Seidelin. He has created Canvas2Image, a library that takes <canvas> data and makes an image out of it. This means that you can create canvas images on the fly and then:

JAVASCRIPT:
  1.  
  2. var strDataURI = oCanvas.toDataURL()
  3. // returns "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACt..."
  4.  

See the full API in use here:

JAVASCRIPT:
  1.  
  2. /*
  3. * Canvas2Image.saveAsXXXX = function(oCanvasElement, bReturnImgElement, iWidth, iHeight) { ... }
  4. */
  5.  
  6. var oCanvas = document.getElementById("thecanvas");
  7.  
  8. Canvas2Image.saveAsPNG(oCanvas)// will prompt the user to save the image as PNG.
  9.  
  10. Canvas2Image.saveAsJPEG(oCanvas); // will prompt the user to save the image as JPEG.
  11.                                   // Only supported by Firefox.
  12.  
  13. Canvas2Image.saveAsBMP(oCanvas)// will prompt the user to save the image as BMP.
  14.  
  15.  
  16. // returns an <img /> element containing the converted PNG image
  17. var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true);   
  18.  
  19. // returns an <img /> element containing the converted JPEG image (Only supported by Firefox)
  20. var oImgJPEG = Canvas2Image.saveAsJPEG(oCanvas, true);
  21.                                                        
  22. // returns an <img /> element containing the converted BMP image
  23. var oImgBMP = Canvas2Image.saveAsBMP(oCanvas, true);
  24.  
  25.  
  26. // all the functions also takes width and height arguments.
  27. // These can be used to scale the resulting image:
  28.  
  29. // saves a PNG image scaled to 100x100
  30. Canvas2Image.saveAsPNG(oCanvas, false, 100, 100);
  31.  
April 9th, 2008

DOMASSISTANT 2.7 IS OUT, STRONG UNICODE SUPPORT AND ENHANCED PERFORMANCE

Now that DOMAssistant has a formal team behind it, the updates keep coming fast and furious. The team announced last night the release of DOMAssistant 2.7, with a host of new features and big improvements in CSS selector performance:

After a lot of hard work, we’re more pleased than ever to present the new version of DOMAssistant: faster, less code, better support and improved stability. And more features, of course.

While we have actually made the code file size smaller, at the same time we have added a number of useful features and improved CSS selector performance.

Along with several fixes, the team added a number of enhancements most notably strong support for Unicode and performance increases for Internet Explorer:

With this release, we wanted to target the world outside our English-speaking box, by adding Unicode support and a complete documentation in Chinese. When that was in place, improving CSS selector performance in Internet Explorer and adding well-needed and requested features was next on the bill.

Happily, we succeded as well as exceeded our goals!"

The newest features include:

  • Unicode support added, implying support for basically any source document language.
  • Method cssSelect added to the Core module, to allow CSS selections of an object reference's children.
  • Method ajax added for making more customized AJAX calls, with more options.
  • Method setStyle added to the CSS module.
  • Method setErrorHandling added to the DOMLoad module.
  • Method first added to get the first of any matches.
  • Added support for attribute selectors E[att|=val], E[att~=val], and pseudo-class :lang.
  • Added support for multiple pseudo-classes, eg. tr:nth-child(odd):not([id]).
  • Added support for nested pseudo-classes within :not, eg. tr:not(:first-of-type).
  • Added full compliance for the an+b expression in :nth-child and :nth-of-type, including negative a.
  • Significant CSS selector performance improvement in Internet Explorer.
  • Updated documentation in Chinese.

DOMAssistant 2.7 is available for download via SVN or HTTP and is released via MIT license.

April 9th, 2008

GETTING FEEDBACK TO THE IE 8 TEAM

The following email was sent out to Microsoft MVPs (read: friendly people :), but we should give them our honest feedback too:

Microsoft has recently released a public beta of IE8. Standards and security are of top importance in this release. To that end, the IE team is planning on releasing IE8 in full standards mode. Releasing in Full Standards Mode offers many benefits in the long term, but short term, could cause some end-user and developer issues. We would love to understand your thoughts around the impact of this specific issue and invite your suggestions on how we can best communicate it.

If you have thoughts and feedback on IE 8 releasing in full standards mode, please respond to the questions below and send your reply to jasontil@microsoft.com with “[IE8 Community Feedback]” in the subject line by this Friday, April 11th at Noon, PDT.

1) IE8 releasing in expected to release in “standards mode”.

(a) What do people in your communities space think about this decision?

(b) What do you predict the impact to be on the customer and/or Developer experience?

(c) Do you have a recommendations on how best to share this information?

2) Our current plan is to communicate this heavily with web site owners and developers. We will be contacting top sites directly, distributing developer FAQs, and writing Knowledge Base articles on authoring to these standards.

(a) Do you think that will be effective at improving the customer experience?

(b) Are there other suggestions do you could offer to transition web sites to be standards-based or to improve the experience for users?

3) Is there anything else you or those in your communities wish to tell us about this issue to improve how we react and respond as Internet Explorer advances to release?

April 9th, 2008

A WISHLIST FOR AJAX APIS

Following discussions at the Highland Fling conference with the audience and Gareth Rushgrove (whose excellent presentation on API design we featured here already) I sat down and came up with a wishlist for a great Ajax API.

As an example I used the Google translation API, pointed out its good points and explained what I'd love to see added to it. Specifically any JavaScript Ajax API to me should have the following:

  • Have a good documentation with immediate copy and paste examples backed up by a full class documentation
  • Build your APIs modular and allow the implementer to choose the version they want to have
  • Provide a hook to link the result of the API methods to the initial data entered. The easiest way is to repeat this data, more sophisticated is to allow for a connection ID.
  • Allow for multiple values to be sent through, it’ll save you API calls and the implementer hacking around the problem of unreliable order of returns.
  • Allow implementers to add an own object to send and get back to allow for namespacing and other data state retention.
  • Allow for a timeout, connections are not to be trusted.

Check out the full rationale and more detailed explanations on the blog: designing a great Ajax API.

April 9th, 2008

SUPER MARIO; 14KB OF JAVASCRIPT

Jacob Seidelin is doing enthusiastic work, and for something fun, he physique a example of Super Mario in meet 14KB of JavaScript:

Here’s an research in keepings things diminutive and confining to digit Javascript file. There are no outside ikon files or anything, everything is rendered with Javascript using either sheet elements or older fashioned div-making tactics (for IE). The sprites are stored in bespoken encoded section in a info that exclusive allows 4 colours for apiece sprite but in invoke exclusive takes up around 40-60 bytes per sprite.

We also hit protocol penalization embedded as base64-encoded data: URI’s. No penalization for IE, though, and it seems every the another browsers apiece hit different, secondary problems with it, but it variety of works.