mirror of
https://github.com/TomHodson/tomhodson.github.com.git
synced 2025-06-26 10:01:18 +02:00
updates
This commit is contained in:
parent
88829ac70c
commit
4db3165f64
BIN
HappyBirthdaySophie/.DS_Store
vendored
Normal file
BIN
HappyBirthdaySophie/.DS_Store
vendored
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
14
HappyBirthdaySophie/.ipynb_checkpoints/index-checkpoint.html
Normal file
14
HappyBirthdaySophie/.ipynb_checkpoints/index-checkpoint.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html><html lang="en"><head>
|
||||
<script src="p5.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<meta charset="utf-8">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<script src="sketch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sketch-holder">
|
||||
<!-- Our sketch will go here! -->
|
||||
</div>
|
||||
</body></html>
|
103
HappyBirthdaySophie/.ipynb_checkpoints/sketch-checkpoint.js
Normal file
103
HappyBirthdaySophie/.ipynb_checkpoints/sketch-checkpoint.js
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
let w = 200;
|
||||
let stepsize = 1;
|
||||
let Nwalkers = 300;
|
||||
let fr = 30;
|
||||
let beta = 0.1; //beta = 0 chooses infinite temperature, beta = inf forces the walkers to go only towards the gradient
|
||||
let betaslider;
|
||||
|
||||
let radio;
|
||||
|
||||
let cw = 500;
|
||||
let canvas, src, pg;
|
||||
|
||||
let walkerpos = []
|
||||
|
||||
let transparent;
|
||||
|
||||
|
||||
function proposal(pos) {}
|
||||
|
||||
let img;
|
||||
let distfield;
|
||||
function preload() {
|
||||
img = loadImage('birthday.png');
|
||||
distfield = loadImage('distfield.png');
|
||||
}
|
||||
|
||||
let dist, showdist, showtarget, showpaths, showwalkers;
|
||||
let step;
|
||||
let newpos;
|
||||
|
||||
function setup() {
|
||||
console.log('canvas has size: ', cw, cw);
|
||||
canvas = createCanvas(cw, cw);
|
||||
canvas.parent('sketch-holder');
|
||||
//pixelDensity(1);
|
||||
//let d = pixelDensity();
|
||||
frameRate(fr);
|
||||
|
||||
betaslider = createSlider(0, 1, 0.5, 0.0001);
|
||||
//betaslider.position(10, 10);
|
||||
betaslider.style('width', '80px');
|
||||
|
||||
showdist = createCheckbox('Show distance function', false);
|
||||
showtarget = createCheckbox('Show target image', false);
|
||||
showpaths = createCheckbox('Show paths', true);
|
||||
showwalkers = createCheckbox('Show walkers', true);
|
||||
|
||||
overlay = createGraphics(windowWidth, windowHeight);
|
||||
overlay.pixelDensity(1);
|
||||
overlay.background(color(0,0,0,0));
|
||||
|
||||
dist = function(pos) {
|
||||
return distfield.get(pos.x, pos.y)[0];
|
||||
}
|
||||
|
||||
colorMode(HSL);
|
||||
|
||||
walkers = [];
|
||||
for(let i = 0; i < Nwalkers; i += 1) {
|
||||
append(walkerpos, createVector(random(width), random(height)));
|
||||
}
|
||||
|
||||
step = createVector(0,0);
|
||||
}
|
||||
|
||||
let b;
|
||||
function draw() {
|
||||
background(255);
|
||||
if(showdist.checked()) image(distfield, 0, 0); //the min distance to the nearest non white pixel in the target image
|
||||
if(showtarget.checked()) image(img, 0, 0); //the target image
|
||||
if(showpaths.checked()) {
|
||||
//tint(255, 5e6 / frameCount / Nwalkers);
|
||||
image(overlay, 0, 0);
|
||||
}
|
||||
|
||||
//text(dist(createVector(mouseX, mouseY)), width/2, height/2);
|
||||
//text(overlay.get(mouseX, mouseY), width/2, height/2);
|
||||
|
||||
beta = betaslider.value();
|
||||
beta = beta / (1 - beta);
|
||||
|
||||
overlay.loadPixels();
|
||||
for(let i = 0; i < Nwalkers; i += 1) {
|
||||
//let debug = Math.sqrt((mouseX - walkerpos[i].x)**2 + (mouseY - walkerpos[i].y)**2) < 10;
|
||||
step.x = 2*stepsize*(random() - 0.5);
|
||||
step.y = 2*stepsize*(random() - 0.5);
|
||||
newpos = p5.Vector.add(walkerpos[i], step);
|
||||
let df = dist(newpos) - dist(walkerpos[i]);
|
||||
if(df > 0 | exp(beta * df) > random(1.0)) {
|
||||
walkerpos[i].add(step);
|
||||
}
|
||||
if(showwalkers.checked()) circle(walkerpos[i].x, walkerpos[i].y, 3);
|
||||
|
||||
// loop over
|
||||
index = 4 * (int(walkerpos[i].y) * overlay.width + int(walkerpos[i].x));
|
||||
b = overlay.pixels[index+3] + 5
|
||||
overlay.pixels[index+3] = b;
|
||||
}
|
||||
overlay.updatePixels();
|
||||
|
||||
|
||||
}
|
13
HappyBirthdaySophie/.ipynb_checkpoints/style-checkpoint.css
Normal file
13
HappyBirthdaySophie/.ipynb_checkpoints/style-checkpoint.css
Normal file
@ -0,0 +1,13 @@
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#sketch-holder {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
width: 500px;
|
||||
}
|
BIN
poem/.ipynb_checkpoints/CV_image-checkpoint.png
Normal file
BIN
poem/.ipynb_checkpoints/CV_image-checkpoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
929
poem/.ipynb_checkpoints/compute_distance_field-checkpoint.ipynb
Normal file
929
poem/.ipynb_checkpoints/compute_distance_field-checkpoint.ipynb
Normal file
File diff suppressed because one or more lines are too long
BIN
poem/.ipynb_checkpoints/distfield-checkpoint.png
Normal file
BIN
poem/.ipynb_checkpoints/distfield-checkpoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
BIN
poem/.ipynb_checkpoints/image-checkpoint.png
Normal file
BIN
poem/.ipynb_checkpoints/image-checkpoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
14
poem/.ipynb_checkpoints/index-checkpoint.html
Normal file
14
poem/.ipynb_checkpoints/index-checkpoint.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html><html lang="en"><head>
|
||||
<script src="p5.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<meta charset="utf-8">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<script src="sketch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sketch-holder">
|
||||
<!-- Our sketch will go here! -->
|
||||
</div>
|
||||
</body></html>
|
104
poem/.ipynb_checkpoints/sketch-checkpoint.js
Normal file
104
poem/.ipynb_checkpoints/sketch-checkpoint.js
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
let w = 200;
|
||||
let stepsize = 1;
|
||||
let Nwalkers = 300;
|
||||
let fr = 30;
|
||||
let beta = 0.1; //beta = 0 chooses infinite temperature, beta = inf forces the walkers to go only towards the gradient
|
||||
let betaslider;
|
||||
|
||||
let radio;
|
||||
|
||||
let cw = 500;
|
||||
let canvas, src, pg;
|
||||
|
||||
let walkerpos = []
|
||||
|
||||
let transparent;
|
||||
|
||||
|
||||
function proposal(pos) {}
|
||||
|
||||
let img;
|
||||
let distfield;
|
||||
function preload() {
|
||||
img = loadImage('CV_image.png');
|
||||
distfield = loadImage('CV_distfield.png');
|
||||
}
|
||||
|
||||
let dist, showdist, showtarget, showpaths, showwalkers;
|
||||
let step;
|
||||
let newpos;
|
||||
|
||||
function setup() {
|
||||
console.log('canvas has size: ', img.width, img.height);
|
||||
canvas = createCanvas(img.width, img.height);
|
||||
canvas.parent('sketch-holder');
|
||||
//pixelDensity(1);
|
||||
//let d = pixelDensity();
|
||||
frameRate(fr);
|
||||
|
||||
betaslider = createSlider(0, 1, 0.5, 0.0001);
|
||||
//betaslider.position(10, 10);
|
||||
betaslider.style('width', '80px');
|
||||
|
||||
showdist = createCheckbox('Show distance function', false);
|
||||
showtarget = createCheckbox('Show target image', false);
|
||||
showpaths = createCheckbox('Show paths', true);
|
||||
showwalkers = createCheckbox('Show walkers', true);
|
||||
|
||||
overlay = createGraphics(windowWidth, windowHeight);
|
||||
overlay.pixelDensity(1);
|
||||
overlay.background(color(0,0,0,0));
|
||||
|
||||
dist = function(pos) {
|
||||
return distfield.get(pos.x, pos.y)[0];
|
||||
}
|
||||
|
||||
colorMode(HSL);
|
||||
|
||||
walkers = [];
|
||||
for(let i = 0; i < Nwalkers; i += 1) {
|
||||
append(walkerpos, createVector(random(width), random(height)));
|
||||
}
|
||||
|
||||
step = createVector(0,0);
|
||||
}
|
||||
|
||||
let b;
|
||||
function draw() {
|
||||
background(255);
|
||||
if(showdist.checked()) image(distfield, 0, 0); //the min distance to the nearest non white pixel in the target image
|
||||
if(showtarget.checked()) image(img, 0, 0); //the target image
|
||||
if(showpaths.checked()) {
|
||||
//tint(255, 5e6 / frameCount / Nwalkers);
|
||||
image(overlay, 0, 0);
|
||||
}
|
||||
|
||||
//text(dist(createVector(mouseX, mouseY)), width/2, height/2);
|
||||
//text(overlay.get(mouseX, mouseY), width/2, height/2);
|
||||
|
||||
beta = betaslider.value();
|
||||
beta = beta / (1 - beta);
|
||||
|
||||
overlay.loadPixels();
|
||||
for(let i = 0; i < Nwalkers; i += 1) {
|
||||
//let debug = Math.sqrt((mouseX - walkerpos[i].x)**2 + (mouseY - walkerpos[i].y)**2) < 10;
|
||||
step.x = 2*stepsize*(random() - 0.5);
|
||||
step.y = 2*stepsize*(random() - 0.5);
|
||||
newpos = p5.Vector.add(walkerpos[i], step);
|
||||
let df = dist(newpos) - dist(walkerpos[i]);
|
||||
if(df > 0 | exp(beta * df) > random(1.0)) {
|
||||
walkerpos[i].add(step);
|
||||
}
|
||||
//if(showwalkers.checked()) circle(walkerpos[i].x, walkerpos[i].y, 3);
|
||||
if(showwalkers.checked()) set(walkerpos[i].x, walkerpos[i].y);
|
||||
|
||||
// loop over
|
||||
index = 4 * (int(walkerpos[i].y) * overlay.width + int(walkerpos[i].x));
|
||||
b = overlay.pixels[index+3] + 5
|
||||
overlay.pixels[index+3] = b;
|
||||
}
|
||||
overlay.updatePixels();
|
||||
|
||||
|
||||
}
|
13
poem/.ipynb_checkpoints/style-checkpoint.css
Normal file
13
poem/.ipynb_checkpoints/style-checkpoint.css
Normal file
@ -0,0 +1,13 @@
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#sketch-holder {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
width: 500px;
|
||||
}
|
BIN
poem/CV_distfield.png
Normal file
BIN
poem/CV_distfield.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
poem/CV_image.png
Normal file
BIN
poem/CV_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
File diff suppressed because one or more lines are too long
@ -21,8 +21,8 @@ function proposal(pos) {}
|
||||
let img;
|
||||
let distfield;
|
||||
function preload() {
|
||||
img = loadImage('image.png');
|
||||
distfield = loadImage('distfield.png');
|
||||
img = loadImage('CV_image.png');
|
||||
distfield = loadImage('CV_distfield.png');
|
||||
}
|
||||
|
||||
let dist, showdist, showtarget, showpaths, showwalkers;
|
||||
@ -30,8 +30,8 @@ let step;
|
||||
let newpos;
|
||||
|
||||
function setup() {
|
||||
console.log('canvas has size: ', cw, cw);
|
||||
canvas = createCanvas(cw, cw);
|
||||
console.log('canvas has size: ', img.width, img.height);
|
||||
canvas = createCanvas(img.width, img.height);
|
||||
canvas.parent('sketch-holder');
|
||||
//pixelDensity(1);
|
||||
//let d = pixelDensity();
|
||||
@ -90,7 +90,8 @@ function draw() {
|
||||
if(df > 0 | exp(beta * df) > random(1.0)) {
|
||||
walkerpos[i].add(step);
|
||||
}
|
||||
if(showwalkers.checked()) circle(walkerpos[i].x, walkerpos[i].y, 3);
|
||||
//if(showwalkers.checked()) circle(walkerpos[i].x, walkerpos[i].y, 3);
|
||||
if(showwalkers.checked()) set(walkerpos[i].x, walkerpos[i].y);
|
||||
|
||||
// loop over
|
||||
index = 4 * (int(walkerpos[i].y) * overlay.width + int(walkerpos[i].x));
|
||||
|
Loading…
x
Reference in New Issue
Block a user