Skip to content

Instantly share code, notes, and snippets.

View talltyler's full-sized avatar

Tyler Larson talltyler

View GitHub Profile
@talltyler
talltyler / gist:5345894
Created April 9, 2013 14:01
This code gives the HTML canvas element JavaScript support for letter spacing. Don't confuse letter spacing with kerning http://en.wikipedia.org/wiki/Kerning This code is basically from http://stackoverflow.com/a/15509006
(function(){
var _fillText,
__slice = [].slice;
_fillText = CanvasRenderingContext2D.prototype.fillText;
CanvasRenderingContext2D.prototype.fillText = function() {
var args, offset, previousLetter, str, x, y,
_this = this;
@talltyler
talltyler / parseFnt.js
Created September 17, 2018 21:42
FNT AngleCode font parser
const lines = data.split('\n');
function parseObject(args) {
const result = {};
for(let i=0;i<args.length;i++){
const arg = args[i].split('=');
const val = arg[1];
result[arg[0]] = ~val.indexOf('"') ? val.substr(1,val.length-2) : parseFloat(val,10);
}
return result;
let http = require("http"),
raspivid = require('raspivid');
http.createServer(function (req, res) {
if (req.url != "/movie.mp4") {
res.writeHead(200, { "Content-Type": "text/html" });
res.end('<video src="http://localhost:8888/movie.mp4"></video>');
} else {
res.writeHead(200, {
"Content-Type": "video/mp4"
{
"item" : "asdf test"
}
@talltyler
talltyler / gist:5346400
Last active December 16, 2015 00:19
The HTML Canvas element is a work in progress that isn't really ready in many cases. I've started a running list of the busted things that I have found so far with links to more information about them and fixes if I have them.
@talltyler
talltyler / gist:5345959
Last active December 16, 2015 00:10
In most browsers the ctx.measureText() method returns an object with only a width property on it. actualBoundingBoxAscent & actualBoundingBoxDescent are in the spec but not implemented yet by any browser. because of this only fonts of normal proportions will have correct height values, things like condensed fonts will be off. We measure the widt…
var measureText = function (ctx,font,text) {
ctx.font = font;
var width = ctx.measureText(text).width;
var metrics = ctx.measureText('M');
return {width:width, height: metrics.width + (metrics.actualBoundingBoxAscent||0) + (metrics.actualBoundingBoxDescent||0)};
};
@talltyler
talltyler / gist:1671133
Created January 24, 2012 16:59
NYCoders Meeting Topics?
LiveCode
Unity3d publishing to flash
Liquid Flexible layouts and different screen sizes
Drawing in Flash
jQuery & jQuery.animation
Dreamweaver (what's new, are people using it?)
iOS flex & air
flex
OOP (states, events, organization and why)
frameworks (ActionScript,JavaScript)
@talltyler
talltyler / Main.as
Created April 28, 2011 14:58
ActionScript Spell Checking
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
public class Main extends Sprite
{
public function Main():void
{
package com.paperlesspost.components.coverflow
{
import com.paperlesspost.components.coverflow.renderers.IItemRenderer;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
// import flash.geom.PerspectiveProjection;
import flash.geom.Point;
import flash.geom.Rectangle;