add two first examples

This commit is contained in:
Yannick7777 2025-04-02 10:54:03 +02:00
parent 982dfdde3b
commit 45d99d6580
12 changed files with 126 additions and 0 deletions

18
example_2/index.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sketch</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="libraries/p5.min.js"></script>
<script src="libraries/p5.sound.min.js"></script>
</head>
<body>
<script src="sketch.js"></script>
</body>
</html>

10
example_2/jsconfig.json Normal file
View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es6"
},
"include": [
"*.js",
"**/*.js",
"/home/melody/.vscode-oss/extensions/samplavigne.p5-vscode-1.2.16/p5types/global.d.ts"
]
}

2
example_2/libraries/p5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
example_2/libraries/p5.sound.min.js vendored Normal file

File diff suppressed because one or more lines are too long

16
example_2/sketch.js Normal file
View file

@ -0,0 +1,16 @@
function drawCanvasContent(){
createCanvas(windowWidth, windowHeight)
background(255)
for (let i = 0; i <= 50; i++) {
fill(0, 0, 0, 0)
square(random(width/2), random(height/2), random(width/8, width/2))
}
}
function setup() {
drawCanvasContent();
}
function mouseMoved() {
drawCanvasContent();
}

8
example_2/style.css Normal file
View file

@ -0,0 +1,8 @@
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}

18
example_4/index.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sketch</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="libraries/p5.min.js"></script>
<script src="libraries/p5.sound.min.js"></script>
</head>
<body>
<script src="sketch.js"></script>
</body>
</html>

10
example_4/jsconfig.json Normal file
View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es6"
},
"include": [
"*.js",
"**/*.js",
"/home/melody/.vscode-oss/extensions/samplavigne.p5-vscode-1.2.16/p5types/global.d.ts"
]
}

2
example_4/libraries/p5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
example_4/libraries/p5.sound.min.js vendored Normal file

File diff suppressed because one or more lines are too long

28
example_4/sketch.js Normal file
View file

@ -0,0 +1,28 @@
let randomnessSeed
function setup() {
randomnessSeed = random(100)
}
function draw() {
const size = 50
randomSeed(randomnessSeed)
createCanvas(windowWidth, windowHeight);
background(255)
noStroke()
for(let i = 0; i <= innerWidth; i += size){
for(let j = 0; j <= innerWidth; j += size){
colorMode(HSL)
fill(random(180) + mouseX / windowWidth * random(90) + mouseY / windowHeight * random(90),
keyIsPressed ? 0 : 100,
random(50) + mouseX / windowWidth * 25 + mouseY / windowHeight * 25
)
let randomsize = 0
do {
randomsize = randomGaussian(size / 20) * 20
}
while (randomsize >= size + size / 10 || randomsize < size / 10)
circle(i, j, randomsize / 2 + mouseY / windowHeight * 50)
}
}
}

8
example_4/style.css Normal file
View file

@ -0,0 +1,8 @@
html, body {
margin: 0;
padding: 0;
}
canvas {
display: block;
}