This file contains hidden or 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
// refactor from https://openprocessing.org/sketch/1491377 | |
import java.util.*; | |
final int maxSpirals = 500; | |
final float angleMax = 4 * PI; | |
final float angleStep = 0.1; | |
final float minR = 8; | |
final float distScale = 1.5; |
This file contains hidden or 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
class PoissonSampling { | |
constructor(width, height, r, start, k = 30) { | |
this.r = r; | |
this.k = k; | |
this.w = r / sqrt(2); | |
let rows = floor(height / this.w); | |
let columns = floor(width / this.w); | |
this.grid = []; |
This file contains hidden or 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
class PoissonSampling { | |
constructor(width, height, r, start, k = 30) { | |
this.r = r; | |
this.k = k; | |
this.w = r / sqrt(2); | |
let rows = floor(height / this.w); | |
let columns = floor(width / this.w); | |
This file contains hidden or 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 Disc Sampling | |
// https://www.youtube.com/watch?v=flQgnCUxHlw | |
class PoissonSampling { | |
constructor(width, height, r, start, k = 30) { | |
this.r = r; | |
this.k = k; | |
this.w = r / sqrt(2); | |
let rows = floor(height / this.w); |
This file contains hidden or 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
const n_start = 200; | |
let circles = []; | |
function setup() { | |
createCanvas(640, 480); | |
noFill(); | |
strokeWeight(1.5); | |
stroke(5); |
This file contains hidden or 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
// Differential line growth with p5.js | |
// refactored from http://www.codeplastic.com/2017/07/22/differential-line-growth-with-processing/ | |
const maxNodeNumbers = 400; | |
const nodesStart = 15; | |
const rayStart = 15; | |
let diffLine; | |
function setup() { | |
createCanvas(300, 300); |
This file contains hidden or 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
package main | |
import "fmt" | |
type Indicable interface { | |
Len() int | |
Idx(i int) any | |
} | |
type AnySlice []any |
This file contains hidden or 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
package main | |
import "fmt" | |
func Map[T any](arr []T, fn func(T) T) []T { | |
newArr := make([]T, len(arr)) | |
for i := 0; i < len(arr); i++ { | |
newArr[i] = fn(arr[i]) | |
} | |
return newArr |
This file contains hidden or 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
package cc.openhome; | |
import java.util.Arrays; | |
sealed interface List permits Nil, Cons { | |
default Integer head() { return null; } | |
default List tail() { return null; } | |
default Integer sum() { | |
return switch(this) { |
This file contains hidden or 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
package ; | |
import java.util.Arrays; | |
sealed interface List permits Nil, Cons { | |
default Integer head() { return null; } | |
default List tail() { return null; } | |
Integer sum(); | |
} |
NewerOlder