Skip to content

Instantly share code, notes, and snippets.

@tildebyte
tildebyte / TwentyfiveSquares.pyde
Created July 29, 2014 19:44
Example Python mode sketch using HYPE.
# PDE:
add_library('hype')
# processing.py:
# from hype.core.util import H
# from hype.core.interfaces import HCallback
# from hype.extended.behavior import HOscillator
# from hype.extended.drawable import HCanvas
# from hype.extended.drawable import HRect
# from hype.extended.layout import HGridLayout
# from hype.extended.util import HDrawablePool
@tildebyte
tildebyte / ex00_methodChaining.pde
Created August 19, 2014 19:14
Simple HYPE example, Java & Python.
import hype.core.util.*;
import hype.extended.drawable.*;
void setup() {
size(640,640);
H.init(this);
HRect rect1 = new HRect(100);
rect1.fill(#FF6600) // set fill color
.stroke(#000000, 150) // set stroke color and alpha
@tildebyte
tildebyte / whale.js
Created December 2, 2014 20:18
A gibber.audio synth.
AudioContext = require('web-audio-api').AudioContext
Gibber = require('gibber.audio.lib/build/gibber.audio.lib.js')
// I want something truly random which can give a uniform distribution of integers
Random = require('random-js')
random = Random(Random.engines.browserCrypto)
// random.integer(30, 41)
Gibber.init()
Clock.bpm = 96 // 2500ms/whole, 625ms/quarter, 19.53ms/128th
@tildebyte
tildebyte / gist:2f7b815d22d36ab80d17
Last active August 29, 2015 14:10
gibber.audio ST3 livecoding
On Mon, Dec 1, 2014 at 9:55 AM, Ben <[email protected]> wrote:
> Question: how hard would it be to integrate gibber.audio.lib running under
> node with Sublime 3?
LOL, I was already looking into this. Right now, I'm dead in the water.
The best thing I know of is SublimeREPL, but with ST3 under Win7 x64, I'm
getting OSError: [WinError 6] The handle is invalid every time I try to send
anything to Node. I've Googled around a bit, but I haven't found anything like
a solution yet.
@tildebyte
tildebyte / Explicit global
Created February 5, 2015 16:33
Globals style
import array
def setup():
global vertexes
vertexes = array.array('f', (0,) * 12)
def draw():
# drawing stuff here
def updateGeometry():
@tildebyte
tildebyte / Tentacles.pyde
Last active August 29, 2015 14:18
Tentacles sketch
'''A sketch inspired by (a radical misinterpretation of) the math from the
JS1K segment of Steven Wittens' "Making Things With Maths" video. Really,
everything is mine except the math in `segment.py`. See also
http://acko.net/blog/js1k-demo-the-making-of
Implemented in Processing.py/Processing 2.1 by Ben Alkov 11-16 Sept 2014.
'''
class Segment(object):
'''A Segment, which encapsulates its own position and color, and can draw
@tildebyte
tildebyte / pypyjs_demo.html
Last active August 29, 2015 14:20
PyPy.js/p5.js experiment
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible">
<title>PyPy.js experiment</title>
<script src="http://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script>
<!-- shim for ES6 `Promise` builtin -->
<script src="./lib/Promise.min.js" type="text/javascript"></script>
@tildebyte
tildebyte / config.cson
Created December 3, 2015 03:06
atom config.cson
"*":
"exception-reporting":
userId: ""
welcome:
showOnStartup: false
"sync-settings":
_analyticsUserId: ""
analytics: false
personalAccessToken: ""
gistId: ""
@tildebyte
tildebyte / range.js
Last active November 11, 2016 22:51
Damn good JS implementation of Python's `range`, using ES6 Generator.
let range = function * (start = 0, end = null, step = 1) {
if (end === null) {
end = start
start = 0
}
let value = start
while (value < end || end < value) {
yield value
value += step
}
@tildebyte
tildebyte / utils
Last active February 27, 2022 03:21
ES6 utility functions for Codepen
// Return a value from a given range, which avoids zero, within a given tolerance.
function avoidZero(range, tolerance) {
// Return a random value in the range from `-range` to strictly less than
// `range`, excluding the inner range +/-`tolerance` (and, logically, zero as
// well).
let value = _.random(-range, range)
while (-tolerance < value && value < tolerance) {
value = _.random(-range, range)
}
return value