This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Finding contours in binary images and approximating polylines. | |
* Implements the same algorithms as OpenCV's findContours and approxPolyDP. | |
* <p> | |
* Made possible with support from The Frank-Ratchye STUDIO For Creative Inquiry | |
* At Carnegie Mellon University. http://studioforcreativeinquiry.org/ | |
* @author Lingdong Huang | |
*/ | |
var FindContours = new function(){let that = this; | |
let N_PIXEL_NEIGHBOR = 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ln.c | |
// | |
// simple, fast, accurate natural log approximation | |
// when without <math.h> | |
// featuring * floating point bit level hacking, | |
// * x=m*2^p => ln(x)=ln(m)+ln(2)p, | |
// * Remez algorithm | |
// by Lingdong Huang, 2020. Public domain. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// encode_anim_gif.js | |
// minimal code to make animated GIFs from arrays of pixels | |
// - no compression | |
// - supports 127 colors (127 shades of gray by default) | |
function encode_anim_gif(frames,w,h,delay=5){ | |
let bytes = []; | |
bytes.push(0x47,0x49,0x46,0x38,0x39,0x61); | |
bytes.push(w&0xff); | |
bytes.push((w>>8)&0xff); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* =============================================================================== | |
* triangulateMTX.ts | |
* TypeScript implementation of Mei-Tipper-Xu algorithm for polygon triangulation | |
* (c) Lingdong Huang 2020 (MIT License) | |
* =============================================================================== */ | |
namespace triangulateMTX{ | |
export function triangulate( | |
vertices : Array<[number,number]>, | |
params : {sliverThreshold? : number, | |
greedyHeuristic? : boolean, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npy-rw.js | |
// READ AND WRITE .NPY (NUMPY) FILES | |
// Lingdong Huang 2019 | |
// npy specs: https://numpy.org/devdocs/reference/generated/numpy.lib.format.html | |
// reference: https://gist.github.com/nvictus/88b3b5bfe587d32ac1ab519fd0009607 | |
const is_node = (typeof process !== 'undefined') | |
var npy = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
bsl124.py | |
(minimal) TI MSP430 1,2,4 Family BSL flasher | |
using pyserial, works on windows, mac, and linux | |
- implementation of slau319af.pdf | |
- programming MSP430 chips via USB-TTL / FTDI / ... | |
- supports Intel HEX format | |
- supports F1xx, F2xx, F4xx, G2xx3 chips |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// core_midi_synth.mm | |
// | |
// a barebones midi synthesizer demo that calls | |
// mac's low level API (CoreMIDI and CoreAudio) directly | |
// (because I can't be bothered to compile other people's libraries) | |
// | |
// with code fragments adapted from | |
// - https://stackoverflow.com/a/7964300 | |
// - https://github.com/thestk/rtmidi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
bmprw.h | |
tiny .BMP image reader/writer in C99 | |
with no memory allocations | |
reader supports: | |
- 1, 4, 8, 24, 32 bit depth, palette / no palette | |
- RLE4 / RLE8 compression / no compression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Poisson Filling for Processing | |
* Made possible with support from The Frank-Ratchye STUDIO For Creative Inquiry | |
* At Carnegie Mellon University. http://studioforcreativeinquiry.org/ | |
*/ | |
package poissonfill; | |
import processing.core.*; | |
import processing.opengl.*; | |
import java.util.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a bare minimum, non-compressing PNG writer in 80 lines | |
// | |
// - supports gray, gray+A, RGB, RGBA, bit depth: 8 (0-255) | |
// - uses "non-compressed blocks" of DEFLATE spec | |
// - writes IHDR, IDAT, IEND -- optional chunks can be | |
// passed as function argument to be encoded (see example) | |
// | |
// reference: | |
// - https://en.wikipedia.org/wiki/Portable_Network_Graphics | |
// - https://datatracker.ietf.org/doc/html/rfc1951 |
NewerOlder