Added w12-promises

This commit is contained in:
Andrea Bianchi 2025-05-12 08:57:34 +09:00
parent 2856dedb68
commit 8827db575b
7 changed files with 90097 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,4 +4,5 @@ node_modules/**
.DS_Store
todo
*/*_solution*
*_solution*
TODO/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

20
w12_promises/index.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script src="js/p5.js"></script>
<script src="js/p5.dom.min.js"></script>
<script src="js/p5.sound.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<meta charset="utf-8" />
</head>
<script defer src="sketch.js"></script>
<body></body>
</html>

3
w12_promises/js/p5.dom.min.js vendored Normal file

File diff suppressed because one or more lines are too long

90025
w12_promises/js/p5.js Normal file

File diff suppressed because one or more lines are too long

28
w12_promises/js/p5.sound.min.js vendored Normal file

File diff suppressed because one or more lines are too long

20
w12_promises/sketch.js Normal file
View File

@ -0,0 +1,20 @@
let img;
let imgWidth = 100;
let imgHeight = 0;
function setup() {
createCanvas(400, 300);
imageMode(CENTER);
// Promisify this function
img = loadImage('assets/light.jpg', (loadedImage) => {
const ratio = loadedImage.height / loadedImage.width;
loadedImage.height = imgWidth * ratio;
loadedImage.width = imgWidth;
});
}
function draw() {
background(255);
if (img) image(img, width / 2, height / 2);
}