“Over the map _g” by yokoul
https://openprocessing.org/sketch/1929407
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of Over the map _f by yokoul
CC Attribution NonCommercial ShareAlike
Over the map _g
xxxxxxxxxx
let easycam;
let terrain = [];
let rows, cols;
let scl = 20;
let w = 500;
let h = 500;
let octaves = 9;
let persistence = 0.5;
let lacunarity = 5;
let currentRow = 0;
let currentParticle = 0;
let displaySpeed = 0.5;
let particles = [];
let partSize = 20;
let partSizeB = 5;
let partSizeC = 15;
let colorScale = chroma.scale(['#00429d', '#4771b2', '#73a2c6',
'#a5d5d8', '#ffffe0', '#ffbcaf',
'#f4777f', '#cf3759', '#93003a']).domain([-100, 100]);
let colorScale1 = chroma.scale(['#A6DA87', '#72DC61', '#35C059',
'#34DF69', '#ffffe0', '#955F54',
'#985D60', '#966671', '#93003a']).domain([-100, 100]);
let colorScale2 = chroma.scale(['#4F7098', '#74C3D8', '#7C99CB', '#76A3E7', '#FFFFFF']).domain([-50, 50]);
let colorScale3 = chroma.scale(['#FFCA41', '#F4FD74', '#F7FDC8']).domain([-50, 50]);
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
setAttributes('antialias', true);
//console.log(Dw.EasyCam.INFO);
// easycam = createEasyCam({distance: 1000, center: [0,-300,0],rotation: [QUARTER_PI*0.8,-QUARTER_PI,PI/12,PI/12]});
easycam = createEasyCam({distance: 900, center: [0,0,0],rotation: [0.4,-0.75,0,0]});
rows = h / scl;
cols = w / scl;
//randomSeed(56789);
for (let x = 0; x < cols; x++) {
terrain[x] = [];
}
centerX = cols / 2;
centerY = rows / 2;
radius = Math.min(rows, cols) / 2;
generateTerrain();
createParticles();
ambientLight(60);
pointLight(255,255,255,100,100,100);
}
function draw() {
//perspective(60 * PI/180, width/height, 1, 5000);
background(20);
translate(-w / 2, -h / 2);
stroke(0);
updateParticles();
drawParticles();
drawParticlesB();
drawParticlesC();
}
function generateTerrain() {
let yoff = 0;
for (let y = 0; y < rows; y++) {
let xoff = 0;
for (let x = 0; x < cols; x++) {
terrain[x][y] = map(fBm(xoff, yoff), 0, 1, -100, 100);
xoff += 0.1;
}
yoff += 0.1;
}
}
function fBm(x, y) {
let sum = 0;
let amplitude = 1;
let frequency = 1;
let maxValue = 0;
for (let i = 0; i < octaves; i++) {
sum += amplitude * noise(x * frequency, y * frequency);
maxValue += amplitude;
amplitude *= persistence;
frequency *= lacunarity;
}
return sum / maxValue;
}
function createParticles() {
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
let particle = {
x: x * scl * random(0.97, 1.03),
y: y * scl,
z: -300,
targetZ: terrain[x][y],
hatchPattern: createHatchPatternA(colorScale(terrain[x][y]).hex())
};
particles.push(particle);
}
}
}
function updateParticles() {
for (let i = 0; i < particles.length; i++) {
let x = particles[i].x / scl;
let y = particles[i].y / scl;
let updateRange = 5;
let lowerBound = (currentRow - updateRange + rows) % rows;
let upperBound = (currentRow + updateRange) % rows;
if (lowerBound <= upperBound) {
if (y >= lowerBound && y <= upperBound) {
particles[i].z = lerp(particles[i].z, particles[i].targetZ, 0.1);
}
} else {
if (y >= lowerBound || y <= upperBound) {
particles[i].z = lerp(particles[i].z, particles[i].targetZ, 0.1);
}
}
}
currentRow = (currentRow + displaySpeed) % rows;
}
function drawParticles() {
for (let i = 0; i < particles.length; i++) {
push();
texture(particles[i].hatchPattern);
translate(particles[i].x, particles[i].y, particles[i].z);
box(partSize);
pop();
}
}
function drawParticlesB() {
for (let i = 0; i < particles.length; i++) {
push();
texture(particles[i].hatchPattern);
//fill(colorScale3(particles[i].targetZ).hex());
stroke(colorScale3(particles[i].targetZ).lab());
translate(particles[i].x * 0.3, particles[i].y * 0.3, particles[i].z * 3);
translate(350,300,-100);
noStroke();
//strokeWeight(0.5);
sphere(partSizeB);
pop();
}
}
function drawParticlesC() {
let particleIndex = 0;
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
let dx = x - centerX;
let dy = y - centerY;
//let distance = Math.sqrt(dx * dx + dy * dy);
let distance = Math.sqrt((dx * dx) * (dy * dy));
//let distance = Math.sqrt((dx * cos(TWO_PI / 5.0)) + (dy * sin(TWO_PI / 45.0)));
if (distance < radius) {
push();
texture(particles[particleIndex].hatchPattern);
//fill(colorScale1(particles[particleIndex].targetZ).hex());
translate(particles[particleIndex].x, particles[particleIndex].y, particles[particleIndex].z * 1.2);
//noStroke();
//stroke(colorScale2(particles[particleIndex].targetZ).lab());
//strokeWeight(0.3);
translate(-50,-50,-20);
rotateX(HALF_PI);
cylinder(partSizeC,partSizeC*2, 8, 8);
pop();
}
particleIndex++;
}
}
}
See More Shortcuts