-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
268 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let desertIslands = new p5((sk) => { | ||
const width = 150; | ||
const height = 150; | ||
|
||
const threshold = 0.55; | ||
const sf = 25; | ||
|
||
function getColour(noiseVal){ | ||
if(noiseVal > threshold){ | ||
return sk.color(239, 221, 111); // sandy yellow (island) | ||
}else{ | ||
return sk.color(0, 157, 196); // ocean blue | ||
} | ||
} | ||
|
||
function drawMap(){ | ||
sk.background(255,255,255); | ||
sk.noiseSeed(Math.random()*1000); | ||
|
||
for(let x = 0; x < width; x++){ | ||
for(let y = 0; y < height; y++){ | ||
let c = getColour(sk.noise(x/sf, y/sf)); | ||
sk.stroke(c); | ||
sk.point(x,y); | ||
} | ||
} | ||
} | ||
|
||
sk.setup = () => { | ||
let cnv = sk.createCanvas(width, height); | ||
cnv.parent("DesertIslands"); | ||
|
||
sk.describe("Click to generate desert islands!"); | ||
|
||
drawMap(); | ||
} | ||
|
||
function onSim(){ | ||
return ((sk.mouseX >= 0) && (sk.mouseX <= width) && (sk.mouseY >= 0) && (sk.mouseY <= height)); | ||
} | ||
|
||
sk.mouseClicked = () => { | ||
if(onSim()){ | ||
drawMap(); | ||
} | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
let DetailedDesertMap = new p5((sk) => { | ||
const width = 150; | ||
const height = 150; | ||
|
||
const sf = 25; | ||
|
||
// I love having hardcoded threshold values | ||
function getColour(noiseVal){ | ||
if (noiseVal > 0.7){ | ||
return sk.color(209, 191, 81); // darker yellow | ||
} else if (noiseVal > 0.55){ | ||
return sk.color(239, 221, 111); // sandy yellow (island) | ||
} else if (noiseVal > 0.4){ | ||
return sk.color(0, 157, 196); // ocean blue | ||
} else{ | ||
return sk.color(0, 127, 166); // deeper blue | ||
} | ||
} | ||
|
||
function drawMap(){ | ||
sk.background(255,255,255); | ||
sk.noiseSeed(Math.random()*1000); | ||
|
||
for(let x = 0; x < width; x++){ | ||
for(let y = 0; y < height; y++){ | ||
sk.stroke(getColour(sk.noise(x/sf, y/sf))); | ||
sk.point(x,y); | ||
} | ||
} | ||
} | ||
|
||
sk.setup = () => { | ||
let cnv = sk.createCanvas(width, height); | ||
cnv.parent("DetailedDesertIslands"); | ||
|
||
sk.noiseDetail(8, 0.5); | ||
sk.describe("Click to generate new Perlin Noise threshold map!"); | ||
|
||
drawMap(); | ||
} | ||
|
||
function onSim(){ | ||
return ((sk.mouseX >= 0) && (sk.mouseX <= width) && (sk.mouseY >= 0) && (sk.mouseY <= height)); | ||
} | ||
|
||
sk.mouseClicked = () => { | ||
if(onSim()){ | ||
drawMap(); | ||
} | ||
} | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
let smoothNoiseHM = new p5((sk) => { | ||
const width = 150; | ||
const height = 150; | ||
const sf = 30; | ||
|
||
function drawMap(){ | ||
sk.background(255,255,255); | ||
sk.noiseSeed(Math.random()*1000); | ||
|
||
for(let x = 0; x < width; x++){ | ||
for(let y = 0; y < height; y++){ | ||
let c = sk.noise(x/sf, y/sf)*255; | ||
sk.stroke(c); | ||
sk.point(x,y); | ||
} | ||
} | ||
} | ||
|
||
sk.setup = () => { | ||
let cnv = sk.createCanvas(width, height); | ||
cnv.parent("SmoothNoiseHeightMap"); | ||
|
||
sk.describe("Click to generate new Perlin Noise heightmap!"); | ||
|
||
drawMap(); | ||
} | ||
|
||
function onSim(){ | ||
return ((sk.mouseX >= 0) && (sk.mouseX <= width) && (sk.mouseY >= 0) && (sk.mouseY <= height)); | ||
} | ||
|
||
sk.mouseClicked = () => { | ||
if(onSim()){ | ||
drawMap(); | ||
} | ||
} | ||
}); |