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
function roundrectpoly(x, y, w, h, r, n) | |
-- required args | |
assert(x ~= nil and type(x) == "number") | |
assert(y ~= nil and type(y) == "number") | |
assert(w ~= nil and type(w) == "number") | |
assert(h ~= nil and type(h) == "number") | |
-- optional args | |
assert(r == nil or type(r) == "number") |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
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
// ------- | |
// Globals | |
// ------- | |
pagewidth = 50rem | |
hgap = 1rem | |
vgap = 1rem | |
// ---------------- | |
// Utlity Functions |
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
// Visualization of Shirley and Chui's Concentric Mapping | |
// projected onto a hemisphere -- e.g. for irradiance tracing. | |
// The points are drawn to the window and C code is output to the console. | |
// This import is needed since Processing 4. | |
// In Processing complains about it not finding it: | |
// In the menubar go to to sketch -> import library -> add library, | |
// enter javafx in the searchbox and download it. | |
import processing.javafx.*; |
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
double fib(int n) { | |
const double sqrt5 = sqrt(5); | |
const double phi_a = (1 + sqrt5)/2; | |
const double phi_b = (1 - sqrt5)/2; | |
return (pow(phi_a, n) - pow(phi_b, n))/sqrt5; | |
} |
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
PVector clickPos = new PVector(0, 0); | |
PVector clickRadi = new PVector(100, 100); | |
void angler( | |
PVector arcPos, float arcRadi, float arcTurn, PVector arcDir, | |
float stepSize, boolean fixStep) { | |
float halfAngle = PI*arcTurn; | |
float totalAngle = TAU*arcTurn; | |
float totalSteps = totalAngle*arcRadi/stepSize; |
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
// Makes text funky. | |
"use strict"; | |
function funkyType(selector, args) { | |
function limitDecimals(n, decimals) { | |
decimals = Math.pow(10, decimals); | |
return Math.trunc(n * decimals) / decimals; | |
} |
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
// sRGB to/from linear-space conversions, by Ian Taylor | |
// source: http://chilliant.blogspot.be/2012/08/srgb-approximations-for-hlsl.html | |
// Alternate LinearToGamma(), without pow(): | |
// srgb = 0.585122381 * sqrt(linear) + | |
// 0.783140355 * sqrt(sqrt(linear)) - | |
// 0.368262736 * sqrt(sqrt(sqrt(linear))); | |
vec3 LinearToGamma(in vec3 linear) { | |
return max(1.055f * pow3(linear, 0.416666667f) - 0.055f, 0); |
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
// Crosstalk makes HDR highlights tend towards white. | |
// This is more realistic and maintains definition in overexposed areas. | |
// -- | |
// Threshold is the point at which the desaturation kicks in. | |
// Shallowness is the rate at which the color reaches pure white. | |
// Higher Shallowness values create a slower rise. | |
vec3 Crosstalk(vec3 color, float threshold, float shallowness) { | |
// Luminosity | |
float luma = color.r * 0.299 + color.g * 0.587 + color.b * 0.114; |
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
float PhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) { | |
return max(-dot(viewdir, reflect(lightdir, normal)), 0.0); | |
} | |
// Analytic specular without ambient specular might look better like this. | |
float HalfPhongBase(vec3 viewdir, vec3 lightdir, vec3 normal) { | |
return -dot(viewdir, reflect(lightdir, normal)) / 2 + 0.5; | |
} | |
// Something to approximate the longer tail |
NewerOlder