Skip to content

Instantly share code, notes, and snippets.

View bortels's full-sized avatar

Tom Bortels bortels

  • Simi Valley, CA, USA
View GitHub Profile
There's a bug in the "Gravity" example for Codify (as of Oct 27, 2011) - the arrowhead doesn't point the right direction in the upper left quadrant.
To fix:
Change line 34 to:
down = vec2(1,0)
And change lines 44-45 to:
@bortels
bortels / gist:1325166
Created October 29, 2011 22:20
messing with custom spritepack in Codify
watch("t")
watch("r")
watch("s")
watch("aa")
-- Use this function to perform your initial setup
function setup()
origin = vec2(1,0)
w2 = WIDTH/2
h2 = HEIGHT/2
@bortels
bortels / bgr.pl
Created October 29, 2011 22:43
Use ImageMagick to convert PNG background to transparent alpha
#!/usr/bin/perl
$img = shift @ARGV;
$corner = `convert $img -format '%[pixel:s.p{0,0}]' info:`;
chomp $corner;
print "corner color is $corner\n";
@r = split(/\./, $img);
$ext = pop @r;
$name = join('.', @r); $name = $name . "_new." . $ext;
print "Saving to $name\n";
@bortels
bortels / simplexfont.lua
Created October 31, 2011 17:13
Data for the Hershey Simplex font
function drawchar(c, ox, oy)
ax=-1
ay=-1
bx=-1
by=-1
stroke(255,0,21,255)
strokewidth(3)
ch = font[c]
for p=1, ch.points do
ax=bx
-- Use this function to perform your initial setup
function setup()
fontinfo={}
fontinfo["#"] = { points=11, width=21, ascii=35,
data={ 11,25,4,-7,-1,-1,17,25,10,-7,-1,-1,4,12,18,12,-1,-1,3,6,17,6 } }
end
-- This function gets called once every frame
function draw()
@bortels
bortels / Main.lua
Created November 1, 2011 17:26
Hershey Roman Simplex font using packed data for Codea
-- This works, but is obsolete - go to https://github.com/bortels/HersheyCodea for the newest version
-- Just a "Main" tab for Codea to demo the class
function setup()
   f=Font()
   f:init()
   frame=1
   offset = 0
   stroke_width=2
@bortels
bortels / 3dcube.lua
Created November 2, 2011 20:28
3d Wireframe Cube demo for Codea
-- Classic 3d wireframe cube demo in LUA
-- based on version for PSP by Nils - ventoline.com
-- modified for Codea - Tom Bortels November 2011
function setup()
--focal length to determine perspective scaling
focalLength = 300
-- here we set up a function to make an object with
-- x, y and z properties to represent a 3D point.
@bortels
bortels / starfield.js
Created November 7, 2011 06:06
Javascript Starfield
function StarField(canvas_id, width, height, num_stars) {
var width = width ? width : 3000,
height = height ? height : 1500,
origin_x = width / 2,
origin_y = height / 2,
stars = [],
num_stars = num_stars ? num_stars : 80,
canvas_id = canvas_id;
function create_star() {
@bortels
bortels / convert.pl
Created November 22, 2011 17:43
convert font data for codify
#!/usr/bin/perl
# This is ugly - I disavow all knowledge of it's existence. It was a one-off, so there are NO
# attempts to make it clean or understandable. HERE THERE BE DRAGONS.
use MIME::Base64;
#font = {
# " " = { name="space", symbol=" ", width=16, ascii=32,
# data={} }
@bortels
bortels / gist:1388116
Created November 23, 2011 07:34
Keyboard for Codea
Keyboard = class()
function Keyboard:init()
self.keyinfo = {
one = { chr="1", glyph="1", schr="!", sglyph="!", row=4, col=2 },
two = { chr="2", glyph="2", schr="@", sglyph="@", row=4, col=3 },
three = { chr="3", glyph="3", schr="#", sglyph="#", row=4, col=4 },
four = { chr="4", glyph="4", schr="$", sglyph="$", row=4, col=5 },
five = { chr="5", glyph="5", schr="%", sglyph="%", row=4, col=6 },
six= { chr="6", glyph="6", schr="^", sglyph="^", row=4, col=7 },