Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
🎉
Celebrating 25 years of building open source tools

Karsten Schmidt postspectacular

🎉
Celebrating 25 years of building open source tools
View GitHub Profile
@postspectacular
postspectacular / hello-ast.js
Last active June 14, 2019 02:15
@thi.ng/shader-ast WIP codegen example w/ multiple output targets (GLSL & JS)
// // // //
// ///// // //// // //// ///// //// ///// //////
// // ///// // ///// // // // // ////// // // //
// //// // // ///// // // ////// // ///// //// //
// // // // // // // // // // // // // //
// ///// // // ///// ///// //// // ///// ///// ///
//
// Head over to thi.ng/shader-ast for more details
const ast = require("@thi.ng/shader-ast");
// deform code
vector4 planes[] = point(1, "planes", @id);
foreach(vector4 plane; planes) {
vector n = set(plane.x, plane.y, plane.z);
float d = dot(n, @P) + plane.w;
// check if point is "above" intersection plane
// since the plane normal always points away from each sphere's center
// this will select all points intersecting a neighbor sphere
if (d > 0) {
@postspectacular
postspectacular / sdf-svg-heatmap.ts
Last active June 23, 2020 16:43
Shroomania: SDF SVG heatmap
import { DisjointSet } from "@thi.ng/adjacency";
import { cosineColor, GRADIENTS } from "@thi.ng/color";
import { identity, partial } from "@thi.ng/compose";
import { serialize } from "@thi.ng/hiccup";
import { rect, svg, text } from "@thi.ng/hiccup-svg";
import { fitClamped, wrap } from "@thi.ng/math";
import { IRandom, Smush32 } from "@thi.ng/random";
import {
buildKernel2d,
comp,
@postspectacular
postspectacular / wolfram.js
Created March 10, 2019 15:18
Transducer based, branch-less 1D Wolfram automata (textmode)
const tx = require("@thi.ng/transducers");
const txb = require("@thi.ng/transducers-binary");
// ANSI clear screen esc seq
const CLEAR = "\x1b[2J\x1b[;H";
// CA dimensions
const WIDTH = 72;
const HEIGHT = 24;
@postspectacular
postspectacular / rulegen.ts
Last active March 4, 2018 19:25
@thi.ng/hiccup-css example to generate tachyons.css width & height rules incl. their media query versions
import * as fs from "fs";
import * as css from "@thi.ng/hiccup-css";
const mediaQueries = [
[""],
["-ns", "--breakpoint-no-small"],
["-m", "--breakpoint-medium"],
["-l", "--breakpoint-large"]
];

Keybase proof

I hereby claim:

  • I am postspectacular on github.
  • I am toxi (https://keybase.io/toxi) on keybase.
  • I have a public key ASChmJFjwANWhFE5SMqUl6TX65dPobiDLv4CtgE0WgIxIQo

To claim this, I am signing this object:

@postspectacular
postspectacular / compile.sh
Created July 3, 2016 02:48
STL mesh viewer & WebWorker example
lein do clean, cljsbuild once min && node postprocess.js
@postspectacular
postspectacular / core.cljs
Created July 3, 2016 02:11
STL mesh viewer & WebWorker example
(ns meshviewer.core
(:require-macros
[reagent.ratom :refer [reaction]])
(:require
[thi.ng.math.core :as m :refer [PI HALF_PI TWO_PI]]
[thi.ng.color.core :as col]
[thi.ng.geom.core :as g]
[thi.ng.geom.vector :as v]
[thi.ng.geom.matrix :as mat]
[thi.ng.geom.gl.core :as gl]
@postspectacular
postspectacular / meshworker.cljs
Last active August 19, 2020 01:47
STL mesh viewer & WebWorker example
;; base.js contains all of CLJS & thi.ng
(.importScripts js/self "base.js")
(ns meshworker
(:require-macros
[cljs-log.core :refer [debug info warn]])
(:require
[thi.ng.math.core :as m]
[thi.ng.geom.core :as g]
[thi.ng.geom.matrix :as mat]
@postspectacular
postspectacular / project.clj
Created July 3, 2016 01:49
STL mesh viewer & WebWorker example
(defproject stlmeshviewer "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.8.51"]
[thi.ng/geom "0.0.1178-SNAPSHOT"]
[reagent "0.5.1"]]
:plugins [[lein-cljsbuild "1.1.3" :exclusions [[org.clojure/clojure]]]]
:clean-targets ^{:protect false} ["resources/public/js" "target"]
:cljsbuild
{:builds
[{:source-paths ["src"]