canvas follow cursor

This commit is contained in:
Patricio Gonzalez Vivo 2015-05-29 12:18:49 -04:00
parent 0ee45e3204
commit 47251660db
6 changed files with 15 additions and 3 deletions

BIN
15/03.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

BIN
15/04.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
15/05.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -13,4 +13,6 @@
### PS Blending modes
<div class="codeAndCanvas" data="blend.frag" data-imgs="00.jpg,01.jpg"></div>
![](03.jpg)
<div class="codeAndCanvas" data="blend.frag" data-imgs="04.jpg,05.jpg"></div>

View File

@ -216,6 +216,7 @@ canvas {
.codeAndCanvas canvas {
float: right;
position: relative;
border-radius: 10px;
z-index: 1;
overflow: hidden;

View File

@ -208,8 +208,17 @@ function loadMarkdown(){
editor.id = id;
editor.on("cursorActivity", function(cm) {
var canvasToChange = document.getElementById(cm.id);
var height = cm.heightAtLine(cm.getCursor().line+1,'local')-canvasToChange.height;
if (height<0){
height = 0.0;
}
canvasToChange.style.top = (height).toString()+"px";
});
editor.on("change", function(cm, change) {
var canvasToChange = document.getElementById(cm.id)
var canvasToChange = document.getElementById(cm.id);
canvasToChange.setAttribute("data-fragment", cm.getValue());
loadShaders();
});
@ -248,7 +257,7 @@ function loadMarkdown(){
editor.id = id;
editor.on("change", function(cm, change) {
var canvasToChange = document.getElementById(cm.id)
var canvasToChange = document.getElementById(cm.id);
canvasToChange.setAttribute("data-fragment", preFunction+cm.getValue()+postFunction);
loadShaders();
});