background preloader

DEV

Facebook Twitter

Typescript - How do I store a reference to a constructor. A CoffeeScript class that parses and renders SVG paths to the <canvas> element. Faster Canvas Pixel Manipulation with Typed Arrays. Edit: See the section about Endiannes. Typed Arrays can significantly increase the pixel manipulation performance of your HTML5 2D canvas Web apps. This is of particular importance to developers looking to use HTML5 for making browser-based games. This is a guest post by Andrew J. Baker. Andrew is a professional software engineer currently working for Ibuildings UK where his time is divided equally between front- and back-end enterprise Web development. He is a principal member of the browser-based games channel #bbg on Freenode, spoke at the first HTML5 games conference in September 2011, and is a scout for Mozilla’s WebFWD innovation accelerator. Eschewing the higher-level methods available for drawing images and primitives to a canvas, we’re going to get down and dirty, manipulating pixels using ImageData.

Conventional 8-bit Pixel Manipulation The following example demonstrates pixel manipulation using image data to generate a greyscale moire pattern on the canvas. JSFiddle demo. Dealing with SVG images in mobile browsers - Adventures in WebKit land. When browsing the web with my retina iPad, I often see websites that could have used SVG for their cartoon-like graphics, but used PNG instead. It seems weird, because most likely those images have been created with some vector graphics editor and then exported or converted to bitmap images.

SVG has been supported in most browsers for years, but still it seems that developers are not yet comfortable with using SVG images on their websites. SVG is quite well-supported in mobile browsers. This means that you can link to a SVG file on your page in most mobile browsers and it just works. But… there is one big problem: Android versions under 3 don’t have any kind of support for SVG in the stock browser. Using SVG on older Android versions Todd Anglin wrote a very good post on Kendo UI blog a year ago on how to deal with the situation on Android 2.X. In his post he writes that according to Google’s stats 94% of the Android users use version 2.1, 2.2 or 2.3. Polyfilling SVG with Canvas demo. Arahaya (ARAKI Hayato) How to Speed Up A* Pathfinding With the Jump Point Search Algorithm.

Prism. Kitchensink | Fabric.js Demos. Intro.js | Better introductions for websites and features with a step-by-step guide for your projects. Code inComplete - Binary Tree Bin Packing Algorithm. FileSaver.js at master · eligrey/FileSaver.js. Typographic effects in canvas. My Background Ajaxian, describing the transformation matrix, inspired me to create my first Color Sphere (2007). Which immersed me into the world of colors, and graphic primitives; inspiring the creation of Sketchpad (2007-2008) in an effort to put together an application “better than Paint” in the browser. These experiments eventually led to the creation of the startup Mugtug with my long-time friend Charles Pritchard. We’re developing Darkroom in HTML5 <canvas>. Darkroom is a non-destructive photo-sharing app, combining the powers of pixel-based filters with vector-based typography and drawing.

Introduction <canvas> brings Javascript programmers full-control of the colors, vectors and pixels on their screens—the visual makeup of the monitor. The following examples deal with one area in <canvas> that hasn’t gotten much attention; creating text-effects. Text-Shadows in <canvas>. Neon-rainbow, zebra-reflection—chaining effects. Inner & outer shadows in <canvas> Spaceage—generative effect.

Evanw/glfx.js. Making Image Filters with Canvas. Introduction The HTML5 canvas element can be used to write image filters. What you need to do is draw an image onto a canvas, read back the canvas pixels, and run your filter on them. You can then write the result onto a new canvas (or heck, just reuse the old one.) Sounds simple? Processing pixels First, retrieve the image pixels: Filters = {};Filters.getPixels = function(img) { var c = this.getCanvas(img.width, img.height); var ctx = c.getContext('2d'); ctx.drawImage(img); return ctx.getImageData(0,0,c.width,c.height);}; Filters.getCanvas = function(w,h) { var c = document.createElement('canvas'); c.width = w; c.height = h; return c;}; Next, we need a way to filter images.

Filters.filterImage = function(filter, image, var_args) { var args = [this.getPixels(image)]; for (var i=2; i<arguments.length; i++) { args.push(arguments[i]); } return filter.apply(null, args);}; Running simple filters Now that we have the pixel processing pipeline put together, it's time to write some simple filters. Code inComplete - Binary Tree Bin Packing Algorithm.

I recently built a ruby gem for auto generating CSS Sprites. It’s simple and flexible, and can be used to generate sprites in either a horizontal or a vertical layout. This works great for most use cases, but has a couple of downsides: Very wide or tall images are not very human friendly, need to zoom and pan. With different sized sprites, it can leave whitespace bulking up your images. For example, you can see the difference between this: and this: In reality, neither of these issues are very critical. Or you can read on to find out… I started by looking up bin packing algorithms in the Algorithm Design Manual: “Even the most elementary-sounding bin-packing problems are NP-complete. Ok, fair enough. “Analytical and empirical results suggest that ‘first fit decreasing’ is the best heuristic. Now we’re getting somewhere. How to pack the sprites within a single bin. Lets tackle one problem at a time: Do this recursively in the form of a binary tree and you end up with a packed image:

Scale 25 | TheoryNine Interactive Development Labs. Formula.js. Codiad/Codiad. How to Create and Use Symlinks on a Mac. In my recent post about pairing SSD and HDD storage inside a MacBook Pro, I used a little-known command line feature to redirect some of my user folders from the SSD to the hard drive. I wanted OS X to still refer to the default locations of ~/Documents, ~/Downloads and so on for these folders, but I wanted to use the storage space on the big drive for these kinds of files.

Symbolic Links (symlinks) are a function of the UNIX underpinnings of OS X to create something like an alias, but at a low-level in the filesystem. Aliases Aliases were introduced in Mac OS System 7 and were then carried forward to Mac OS X. They are a pointer to a file or a folder somewhere else, even on a server. The alias is tied to the unique ID of that file and will continue to work even if you move the original file or folder because it stores this information (and more) in the resource fork of the alias file.

Symbolic Links (or symlinks) A Note on Hard Links The “ln” command below is used to create hard links. Gre/glsl.js. » Floyd-Steinberg dithering in JavaScript. There are many “smart” algorithms in 2D graphics and Floyd-Steinberg error diffusion is one of them. Attached demo demonstrates a dithering on webcam output (or Bucks Bunny video, when webcam is not available). Open demo in the new window What is the problem The problem is, that we have an image (table of pixels) in format, which uses lots of colors (hundreds, thousands, millions …) and we want to display it with less colors, and we already have both palettes.

There might be many reasons for doing that. Compression: instead of 24 bits for pixel we can use only 16, 8, 2 or even 1 bit per pixel. What is the solution The obvious solution is to round the color values from big palette to the “closest” values in the small palette. Dithering is a little different attitude. One way of doing dithering is error distribution. Floyd-Steinberg algorithm. The guide to implementing 2D platformers | Higher-Order Fun. Having previously been disappointed by the information available on the topic, this is my attempt at categorizing different ways to implement 2D platform games, list their strengths and weaknesses, and discuss some implementation details. The long-term goal is to make this an exhaustive and comprehensible guide to the implementation of 2D platform games.

If you have any sort of feedback, correction, request, or addition – please leave it in the comments! Disclaimer: some of the information presented here comes from reverse engineering the behavior of the game, not from its code or programmers. It’s possible that they are not ACTUALLY implemented in this way, and merely behave in an equivalent way. Also note that tile sizes are for the game logic, graphical tiles might be of a different size. I can think of four major ways in which a platform game can be implemented. Type #1: Tile-based (pure) Character movement is limited to tiles, so you can never stand halfway between two tiles.

Slopes. PhoneGap Android Plugin to Extract ZipFile. Hello Folks, Its about after 2 months I thought of writing a post. So here is it. I was thinking to extract a .zip file from PhoneGap on android and I ended up implementing a plugin for it. Include the below .java file with the same package mentioned. /* Author: Vishal Rajpal Filename: ExtractZipFilePlugin.java Date: 21-02-2012*/ package com.phonegap.plugin.ExtractZipFile; import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Enumeration;import java.util.zip.ZipEntry;import java.util.zip.ZipException;import java.util.zip.ZipFile;import org.json.JSONArray;import org.json.JSONException;import com.phonegap.api.Plugin;import com.phonegap.api.PluginResult; public class ExtractZipFilePlugin extends Plugin { Include the below .js file in your phonegap project. /* Author: Vishal Rajpal Filename: ZipPlugin.js Date: 21-02-2012*/ var ExtractZipFilePlugin=function(){}; Usage i.e. .html file.

Kinect

Android. Eclipse. KSWEB. Cache “nudger” | upshots. With web technologies generally, and flash specifically, managing cached assets can sometimes feel like walking a tightrope. If you’ve got a simple slideshow and have occasional updates to the image you want immediately reflected to the client, you’ll often see traditional “cache-busting” methods like appending a random number of the current UTC time to the end of an image. This has always felt a little heavy-handed to me (imagine a slideshow with 25 images, with a couple hundred page views per day – that’s a lot of downloads and a lot of files cached unnecessarily on the client). A little trick I use to “nudge” caching is to add the UTC time to the swf’s FlashVars (or preferably, just as a query string variable to the swiff’s path) at the time of any update: <object type="application/x-shockwave-flash" data="path/to/your.swf?

Updated=1325539300"><param name="movie" value="path/to/your.swf? Updated=1325539300" /> ...

Css

Rmhall/runway. iOS. Development Articles. Security. Resources. Github. Javascript. As3. Android. Html5. Php.