Skip to content

Instantly share code, notes, and snippets.

@remy
remy / trim-canvas.js
Last active June 21, 2024 09:07
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
@zachstronaut
zachstronaut / gist:1184900
Created August 31, 2011 22:22
Stretch HTML5 canvas to fill window, preserving aspect ratio
/**
* fullscreenify()
* Stretch canvas to size of window.
*
* Zachary Johnson
* http://www.zachstronaut.com/
*
* See also: https://gist.github.com/1178522
*/
@marcus-downing
marcus-downing / list_used_fonts.jsx
Created May 23, 2012 22:43
List the fonts used in all the Illustrator files in a folder
/*
List the fonts
This shows you all the fonts used in all the Illustrator files in a folder,
even if the fonts aren't installed on your system.
You can then replace them with this script: https://gist.github.com/2778305
*/
function getAllFiles(folder) {
var fileList = [];
function recurse (folder) {
@marcus-downing
marcus-downing / replace_fonts.jsx
Created May 23, 2012 22:45
Replace fonts in all the Illustrator files in a folder
/*
Replace fonts in all the Illustrator files in a folder
Edit the array at the top to your own substitutions
Find the font names to replace using: https://gist.github.com/2778294
*/
// fonts to replace
var substitutions = [
['BellGothic BT', 'Bold', 'Roboto', 'Condensed'],
['BellGothic Blk BT', 'Black', 'Roboto', 'Bold Condensed'],
@geekgonecrazy
geekgonecrazy / ExportPNGs.jsx
Created March 7, 2013 22:35
From illustrator CS5 and above. It prompts for a folder, then will go through all .ai files in the folder and create's 2 png's from the artboard. One that is 145px and one that is 300px
/*
@author: Aaron Ogle
Script to Export Illustrator files as PNG's then make a thumbnail.
Runs in CS5 only due to a missing function. Haven't found a work around yet.
*/
// Disable Alerts. We want this to be as unobtrusive as possible.
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;