Last active
October 6, 2015 15:11
-
-
Save aaizemberg/771a81700076ab3c0103 to your computer and use it in GitHub Desktop.
simultaneous contrast illusion (p5js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>simultaneous contrast illusion</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.13/p5.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.13/addons/p5.dom.min.js"></script> | |
<!-- no hace falta | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.13/addons/p5.sound.min.js"></script> | |
--> | |
<script> | |
function setup() { | |
var myCanvas = createCanvas(800, 400); | |
myCanvas.parent('p5js'); | |
fondo = document.getElementById("fondo"); | |
pos = document.getElementById("pos"); | |
noStroke(); | |
} | |
function draw() { | |
rectMode(CORNER); | |
fill( 1*fondo.value ); | |
rect(0,0,400,400) | |
fill(255 - fondo.value); | |
rect(400,0,400,400) | |
rectMode(CENTER); | |
fill(128); | |
rect(pos.value,200,100,100); | |
rect(800-pos.value,200,100,100); | |
} | |
</script> | |
</head> | |
<body> | |
<input type="range" id="fondo" min="0" max="255" value="64"> | |
<br> | |
<input type="range" id="pos" min="0" max="400" value="200"> | |
<div id="p5js"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment