Skip to content

Commit 18c7be6

Browse files
committed
Block errors are highlighted in matching color.
- Upgrade to latest version of Snap - Color math to tell Snap what color we want. This is not really the end of this work. It demonstrates that we have enough flexibility to do what we want. But we probably still need to think about the error color palette in Pyret and how it should work with the semantic color palette of the Blocks world.
1 parent 720fe40 commit 18c7be6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/web/js/output-ui.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
return converter([74, a, b]);
4242
}
4343

44+
// Snap wants colors specified as "r,g,b(,a)" where each is [0-255]
45+
var snapConverter = $.colorspaces.converter('CIELAB', 'sRGB')
46+
function hueToSnapColor(hue) {
47+
var a = 40*Math.cos(hue);
48+
var b = 40*Math.sin(hue)
49+
return snapConverter([74, a, b]).map(x => Math.floor(x * 255)).join(",")
50+
}
51+
4452
var goldenAngle = 2.39996322972865332;
4553
var lastHue = 0;
4654

@@ -1079,9 +1087,12 @@
10791087
// Blocks editor case
10801088
if(CPO.blocksIDE) {
10811089
if(positions.length > 0) {
1090+
var snapColor = hueToSnapColor(color);
10821091
CPO.blocksIDE.flashSpriteScripts(
10831092
positions[0].from.line + 1, // CPO is 0-based, Snap is 1-based
1084-
positions[0].to.line + 1);
1093+
positions[0].to.line + 1,
1094+
undefined,
1095+
snapColor);
10851096
}
10861097
} else {
10871098
if (positions[0] !== undefined)

0 commit comments

Comments
 (0)