|
41 | 41 | return converter([74, a, b]); |
42 | 42 | } |
43 | 43 |
|
| 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 | + |
44 | 52 | var goldenAngle = 2.39996322972865332; |
45 | 53 | var lastHue = 0; |
46 | 54 |
|
|
1075 | 1083 | window.requestAnimationFrame(function() { |
1076 | 1084 | logger.log("highlight_anchor_hover", |
1077 | 1085 | { error_id: context, anchor_id: id }); |
1078 | | - if (positions[0] !== undefined) |
1079 | | - positions[0].hint(); |
| 1086 | + |
| 1087 | + if (positions[0] !== undefined) { |
| 1088 | + if(CPO.blocksIDE) { |
| 1089 | + // Blocks editor case |
| 1090 | + var snapColor = hueToSnapColor(color); |
| 1091 | + CPO.blocksIDE.flashSpriteScriptAt( |
| 1092 | + locsArray[0].dict['start-char'] + 1, |
| 1093 | + undefined, |
| 1094 | + snapColor); |
| 1095 | + } else { |
| 1096 | + // Non-Blocks editor |
| 1097 | + positions[0].hint(); |
| 1098 | + } |
| 1099 | + } |
1080 | 1100 | emphasize(color); |
1081 | 1101 | }); |
1082 | 1102 | }); |
1083 | 1103 | anchor.on("mouseleave", function () { |
1084 | 1104 | logger.log("highlight_anchor_mouseleave", |
1085 | 1105 | { error_id: context, anchor_id: id }); |
1086 | 1106 | window.requestAnimationFrame(function() { |
1087 | | - unhintLoc(); |
| 1107 | + // Blocks editor case |
| 1108 | + if(CPO.blocksIDE) { |
| 1109 | + if(positions.length > 0) { |
| 1110 | + CPO.blocksIDE.unflashSpriteScripts(); |
| 1111 | + } |
| 1112 | + } else { |
| 1113 | + unhintLoc(); |
| 1114 | + } |
1088 | 1115 | demphasize(color); |
1089 | 1116 | }); |
1090 | 1117 | }); |
|
0 commit comments