Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks error highlighting #502

Merged
merged 8 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Then you can run
```
$ npm run local-install
$ ln -s node_modules/pyret-lang pyret
$ git submodule init
$ git submodule update
$ npm run build
```

Expand Down
33 changes: 30 additions & 3 deletions src/web/js/output-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
return converter([74, a, b]);
}

// Snap wants colors specified as "r,g,b(,a)" where each is [0-255]
var snapConverter = $.colorspaces.converter('CIELAB', 'sRGB')
function hueToSnapColor(hue) {
var a = 40*Math.cos(hue);
var b = 40*Math.sin(hue)
return snapConverter([74, a, b]).map(x => Math.floor(x * 255)).join(",")
}

var goldenAngle = 2.39996322972865332;
var lastHue = 0;

Expand Down Expand Up @@ -1075,16 +1083,35 @@
window.requestAnimationFrame(function() {
logger.log("highlight_anchor_hover",
{ error_id: context, anchor_id: id });
if (positions[0] !== undefined)
positions[0].hint();

if (positions[0] !== undefined) {
if(CPO.blocksIDE) {
// Blocks editor case
var snapColor = hueToSnapColor(color);
CPO.blocksIDE.flashSpriteScriptAt(
locsArray[0].dict['start-char'] + 1,
undefined,
snapColor);
} else {
// Non-Blocks editor
positions[0].hint();
}
}
emphasize(color);
});
});
anchor.on("mouseleave", function () {
logger.log("highlight_anchor_mouseleave",
{ error_id: context, anchor_id: id });
window.requestAnimationFrame(function() {
unhintLoc();
// Blocks editor case
if(CPO.blocksIDE) {
if(positions.length > 0) {
CPO.blocksIDE.unflashSpriteScripts();
}
} else {
unhintLoc();
}
demphasize(color);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/web/js/snap
Submodule snap updated 8 files
+33 −0 HISTORY.md
+5 −2 docs/API.md
+4 −4 snap.html
+3 −17 src/api.js
+18 −2 src/blocks.js
+36 −4 src/gui.js
+4 −2 src/morphic.js
+1 −1 sw.js