Skip to content

Commit

Permalink
feat: Reveal the cat
Browse files Browse the repository at this point in the history
  • Loading branch information
ff6347 committed Nov 18, 2024
1 parent c8dfa7a commit 3b5c767
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ <h1>Directory Tree</h1> <a href="/"></a><br>
│   ├── <a href="/p5js/relative-helpers/">relative-helpers</a><br>
│   │   ├── <a href="/p5js/relative-helpers/index.html">index.html</a><br>
│   │   └── <a href="/p5js/relative-helpers/index.js">index.js</a><br>
│   ├── <a href="/p5js/reveal-the-cat/">reveal-the-cat</a><br>
│   │   ├── <a href="/p5js/reveal-the-cat/data/">data</a><br>
│   │   │   └── <a href="/p5js/reveal-the-cat/data/kitten-300-200.jpg">kitten-300-200.jpg</a><br>
│   │   ├── <a href="/p5js/reveal-the-cat/index.html">index.html</a><br>
│   │   └── <a href="/p5js/reveal-the-cat/index.js">index.js</a><br>
│   ├── <a href="/p5js/sound-reactive/">sound-reactive</a><br>
│   │   ├── <a href="/p5js/sound-reactive/LICENSE">LICENSE</a><br>
│   │   ├── <a href="/p5js/sound-reactive/README.md">README.md</a><br>
Expand Down Expand Up @@ -276,7 +281,7 @@ <h1>Directory Tree</h1> <a href="/"></a><br>
&nbsp;&nbsp;&nbsp; └── <a href="/typescript/random-groups.ts">random-groups.ts</a><br>
<br><br><p>

62 directories, 188 files
64 directories, 191 files

</p>
<p>
Expand Down
Binary file added p5js/reveal-the-cat/data/kitten-300-200.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions p5js/reveal-the-cat/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

<link rel="stylesheet" href="/public/css/reset.css">

<style>
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
</style>
<script src="/public/js/p5.min.js"></script>
<script src="index.js"></script>

</head>

<body>
<div id="sketch"></div>

</body>

</html>
21 changes: 21 additions & 0 deletions p5js/reveal-the-cat/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let img;

function preload() {
img = loadImage('data/kitten-300-200.jpg');
}
function setup() {
createCanvas(300, 200);
rectMode(CENTER);
// imageMode(CENTER)
}

function draw() {
image(img, 0, 0);
// Get a region of the image.
let c = get(mouseX - 15, mouseY - 15, 15, 15);
noStroke;
fill('black');
rect(width / 2, height / 2, width, height);
// Display the region.
image(c, mouseX - 15, mouseY - 15);
}

0 comments on commit 3b5c767

Please sign in to comment.