Html5 canvas drawImage: how to apply antialiasing

Cause Some images are just very hard to down-sample and interpolate such as this one with curves when you want to go from a large size to a small. Browsers appear to typically use bi-linear (2×2 sampling) interpolation with the canvas element rather than bi-cubic (4×4 sampling) for (likely) performance reasons. If the step is … Read more

How to draw grid using HTML5 and canvas or SVG

SVG can do this nicely using patterns: <svg width=”100%” height=”100%” xmlns=”http://www.w3.org/2000/svg”> <defs> <pattern id=”smallGrid” width=”8″ height=”8″ patternUnits=”userSpaceOnUse”> <path d=”M 8 0 L 0 0 0 8″ fill=”none” stroke=”gray” stroke-width=”0.5″/> </pattern> <pattern id=”grid” width=”80″ height=”80″ patternUnits=”userSpaceOnUse”> <rect width=”80″ height=”80″ fill=”url(#smallGrid)”/> <path d=”M 80 0 L 0 0 0 80″ fill=”none” stroke=”gray” stroke-width=”1″/> </pattern> </defs> <rect width=”100%” … Read more

HTML5 Canvas Rotate Image

You can use canvas’ context.translate & context.rotate to do rotate your image Here’s a function to draw an image that is rotated by the specified degrees: function drawRotated(degrees){ context.clearRect(0,0,canvas.width,canvas.height); // save the unrotated context of the canvas so we can restore it later // the alternative is to untranslate & unrotate after drawing context.save(); // … Read more

Getting binary (base64) data from HTML5 Canvas (readAsBinaryString)

The canvas element provides a toDataURL method which returns a data: URL that includes the base64-encoded image data in a given format. For example: var jpegUrl = canvas.toDataURL(“image/jpeg”); var pngUrl = canvas.toDataURL(); // PNG is the default Although the return value is not just the base64 encoded binary data, it’s a simple matter to trim … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)