Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hackclub/blot
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Apr 25, 2024
2 parents 6187a0f + 2c7bf2e commit b854559
Show file tree
Hide file tree
Showing 15 changed files with 545 additions and 0 deletions.
238 changes: 238 additions & 0 deletions art/DesertSunset-Augustin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
/*
@title: Desert Sunset
@author: Augustin Z
@snapshot: desert2.png
*/
const width = 125
const height = 125
setDocDimensions(width, height);

const randx = bt.randIntInRange(0, 10)
//I thought the changing y-values looked nauseous when you run it continuously
const randy = bt.randIntInRange(32, 32)

const birdLines = []
const birdleft = [
bt.nurbs([
[0,0],
[3,6],
[6,0]
])
]
const birdright = [
bt.nurbs([
[6,0],
[10,6],
[12,0]
])
]
const birdleft1 = [
bt.nurbs([
[15,0],
[18,6],
[21,0]
])
]
const birdright1 = [
bt.nurbs([
[21,0],
[25,6],
[27,0]
])
]

const birdleft2 = [
bt.nurbs([
[9,5],
[12,11],
[15,5]
])
]
const birdright2 = [
bt.nurbs([
[15,5],
[19,11],
[21,5]
])
]

bt.join(birdLines, birdleft, birdright, birdleft1, birdright1, birdleft2, birdright2)
const randinsky = bt.randIntInRange(75,115)
const randinskx = bt.randIntInRange(0,96)
bt.translate(birdLines, [randinskx,randinsky], [0,0])
bt.copy(birdLines)



const sun = [
bt.nurbs([
[32.5, randy + 20],
[32.5, randy + 45],
[62.5, randy + 63],
[92.5, randy + 45],
[92.5, randy + 20]
])
]

const cactus = [
bt.nurbs([
[10, 0],
[10, 20],
[0, 30],
[0, 40],
[3, 50],
[5, 35],
[7, 32],
[8, 60],
[10, 65],
[12, 60],
[13, 28],
[14, 26],
[15, 27],
[16, 35],
[17, 37],
[18, 34],
[19, 30],
[19, 25],
[13, 16],
[14, 0]
])
]


const road = [
[
[15, 0],
[57.5, randy + 20],
[67.5, randy + 20],
[110, 0]
]
]

const land = [
[
[0, randy + 20],
[125, randy + 20],
[125, 0],
[0, 0]
]
]

const sky = [
[
[0, randy + 20],
[125, randy + 20],
[125, height],
[0, height]
]
]

/*for (let i = 0; i < 51; i++) {
t.forward(i);
}
*/
const randomnum = bt.randIntInRange(10, 50)
const randomnum2 = bt.randIntInRange(10, 50)
const finalLines = [];

const leftmount = [
bt.nurbs([
[0, randy + 20],
[randomnum, 79],
[randomnum, 60],
[57.5, randy + 20]
])
]

const rightmount = [
bt.nurbs([
[67.5, randy + 20],
[randomnum2 + 70, 76],
[randomnum2 + 70, 55],
[width, randy + 20]
])
]

bt.iteratePoints(rightmount, (pt, t) => {
const [x, y] = pt;
const freq = 0.85;
const dy = bt.noise(t * 25, { octaves: 3 }) * 10 * (t === 0 || t === 1 ? 0 : 1)
return [x, y + dy]
})
bt.join(finalLines, rightmount);

bt.iteratePoints(leftmount, (pt, t) => {
const [x, y] = pt;
const freq = 3.58;
const dy = bt.noise(t * 25, { octaves: 3 }) * 10 * (t === 0 || t === 1 ? 0 : 1)
return [x, y + dy]
})
bt.join(finalLines, leftmount);

//shadows

const rightshadow = [
bt.nurbs([
[67.5, randy + 20],
[randomnum2 + 70, 45],
[randomnum2 + 70, 55],
[width, randy + 20]
])
]

bt.iteratePoints(rightshadow, (pt, t) => {
const [x, y] = pt;
const freq = 0.85;
const dy = bt.noise(t * 25, { octaves: 3 }) * -17 * (t === 0 || t === 1 ? 0 : 1)
return [x, y + dy]
})

const leftshadow = [
bt.nurbs([
[0, randy + 20],
[randomnum, 40],
[randomnum, 50],
[57.5, randy + 20]
])
]

bt.iteratePoints(leftshadow, (pt, t) => {
const [x, y] = pt;
const freq = 0.85;
const dy = bt.noise(t * 25, { octaves: 3 }) * -17 * (t === 0 || t === 1 ? 0 : 1)
return [x, y + dy]
})




//road lines
const t = new bt.Turtle();
for (let i = 0; i < 3; i++) {
t.jump([62 - i, randy + 20 - 6 * i * (i + 1 / 2)])
t.forward(2 * (i + 1))
t.right(80)
t.forward(5 * (i + 1))
t.left(-100)
t.forward(4 * (i + 1))
t.right(100)
t.forward(5 * (i + 1))
t.right(-100)
t.right(180)
}




// draw it

drawLines(sky, { fill: "Tomato" });
drawLines(land, { fill: "Peru" });
drawLines(sun, { fill: "orange" });
drawLines(finalLines, { fill: "Black" });
drawLines(leftshadow, { fill: "Sienna" });
drawLines(rightshadow, { fill: "Sienna" });
drawLines(road, { fill: "gray" });
drawLines(t.lines(), { fill: "yellow" });
drawLines(cactus, { fill: "YellowGreen" });
drawLines(birdLines);
Binary file added art/DesertSunset-Augustin/snapshots/desert1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/DesertSunset-Augustin/snapshots/desert2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/DesertSunset-Augustin/snapshots/desert3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions art/SineArt-Ruben/imagegenerator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Byte array generator</title>
<style>
body {
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
* {
text-align: center;
font-family: 'Courier New', Courier, monospace;
}

#img {
background-color: #DDDDDD;
padding: 5mm;
width: 40%;
border-radius: 15px;

}

#width {
background-color: #DDDDDD;
padding: 5mm;
border-radius: 15px;
width: 40%;
border: none;
}
#width:focus {
outline: none;
}

#out {
background-color: #DDDDDD;
padding: 5mm;
border-radius: 15px;
width: 40%;
border: none;
text-wrap: wrap;
}
#out:focus {
outline: none;

}

</style>
</head>
<body>
<input placeholder="width" id="width" autocomplete="off" />
<br />
<input placeholder="image" type="file" accept="image/*" id="img" />
<br />
<input id="out" value="results here. click to copy"/>

<script>
let image_src_input = document.getElementById("img");
let width = document.getElementById("width");
let out = document.getElementById("out");

out.onclick = () => {
out.select();
navigator.clipboard.writeText(out.value);
alert("Copied!")
}

image_src_input.addEventListener("change", (e) => {
if (width.value == "") {
alert("Enter valid width")
return;
}
if (e.target.files) {
let file = e.target.files[0];
let reader = new FileReader();
reader.onload = (e) => {
let image = new Image();
let output_array = [];
image.onload = () => {
let canvas = document.createElement("canvas");
let ctx = canvas.getContext("2d");
canvas.width = Number(width.value);
let height = (image.height * canvas.width) / image.width;
canvas.height = height;

ctx.drawImage(image, 0, 0, canvas.width, height);
let pixels = ctx.getImageData(0, 0, canvas.width, height).data;
for (let y = 0; y < height; y++) {
output_array.push([]);
for (let x = 0; x < canvas.width; x++) {
let pixel_index = (canvas.width * y + x) * 4;
let r = pixels[pixel_index];
let g = pixels[pixel_index + 1];
let b = pixels[pixel_index + 2];
let avg = (r + g + b) / 3;
output_array[y].push(pixels[pixel_index]);
}
}
output_array.pop();
console.log(output_array);
let output_string = "let image = [";
for (let row of output_array) {
output_string += "[";
output_string += row.join(", ");
output_string += "],";
}
output_string = output_string.slice(0, -1);
output_string += "]"
out.value = output_string;
console.log(output_string);
};
image.src = e.target.result;
};
reader.readAsDataURL(file);
}
});
</script>
</body>
</html>
66 changes: 66 additions & 0 deletions art/SineArt-Ruben/index.js

Large diffs are not rendered by default.

Binary file added art/SineArt-Ruben/snapshots/bird.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/SineArt-Ruben/snapshots/lion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/SineArt-Ruben/snapshots/tiger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b854559

Please sign in to comment.