Skip to content

Instantly share code, notes, and snippets.

--flickering lights
function setup()
--set up dark area covered by shader
SS_Dark.setup(WIDTH,600,true)
--add an unblinking light that can be moved
L1Pos=vec2(150,175) --initial pos of light1
L1=SS_Dark.AddLight(L1Pos.x,L1Pos.y,150,0)
--add a flickering light (30% flicker)
L2=SS_Dark.AddLight(600,125,150,0.3)
--another light with a bigger flicker
@Techdojo
Techdojo / Gradient Library
Last active August 29, 2015 14:09
Codea gradient example
--# Gradient
-- Gradient
-- A utility class to take a table of color stops (in the range 0-1) and returns an image that can be used as a texture
Gradient = class()
function Gradient:init(params)
params = params or { height=100, stops = {
{0, 255, 0, 0,255},
{0.2, 0,255, 0,128},
@Techdojo
Techdojo / Raster Bars
Last active August 29, 2015 14:09
Codea gradient demo (requires the gradient library)
--# Main
-- RasterBars
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN)
centerX = WIDTH * 0.5
centerY = HEIGHT * 0.5
barImg = Gradient({ height=100, stops = {{0, 0,0,0,0},{0.5,255,255,255,255},{1,0,0,0,0}}}):getImage()
--# Clouds
Clouds = class()
function Clouds:init(x)
local s = shader([[
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;
--# Main
function setup()
parameter.boolean("FILL")
parameter.integer("RANGE", 1,20,3)
parameter.boolean("LINE")
parameter.boolean("FOV")
parameter.boolean("MOVE")
hs = Hexagons():createMesh():set(0,0,color(207, 67, 67))
u = Unit(hs:pos(0,0))
--# Main
-- Infinite Grid
function setup()
displayMode(FULLSCREEN)
g = Grid()
end
@Techdojo
Techdojo / Terrain2.lua
Last active August 29, 2015 14:09 — forked from tnlogy/Terrain2.lua
--# Main
-- Terrain
function setup()
displayMode(FULLSCREEN)
forward, right, up = vec3(0,0,1), vec3(-1,0,0), vec3(0,1,0)
pos = vec3(0,100,0)
t = Terrain()
A = 0
@Techdojo
Techdojo / Terrain.lua
Last active August 29, 2015 14:09 — forked from tnlogy/Terrain.lua
--# Main
-- Terrain
function setup()
displayMode(FULLSCREEN)
forward, right, up = vec3(0,0,1), vec3(-1,0,0), vec3(0,1,0)
t = Terrain()
A = 0
end
@Techdojo
Techdojo / 3D touch.lua
Last active August 29, 2015 14:09 — forked from tnlogy/3D touch.lua
--# Main
function setup()
displayMode(FULLSCREEN)
sky = Skybox()
forward, right, up = vec3(0,0,-1), vec3(1,0,0), vec3(0,1,0)
rays = {}
-- creating some random triangles to hit
tris = {}
@Techdojo
Techdojo / ImageTools.h
Last active August 29, 2015 14:09 — forked from tnlogy/ImageTools.h
//
// ImageTools.h
// FaceDetection
//
// Created by Tobias Teleman on fredag 12 april 2013
// Copyright (c) Tobias Teleman. All rights reserved.
//
#import <Foundation/Foundation.h>