Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sugarlabs/musicblocks int…
Browse files Browse the repository at this point in the history
…o ES6_rhythmruler.js
  • Loading branch information
joykirat18 committed Jan 24, 2021
2 parents b2749cd + 0c9f855 commit 240e63e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 41 deletions.
13 changes: 5 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{
"parser": "babel-eslint",
"env": {
"es6": true,
"browser": true,
"node": true
"browser": true
},
"extends": ["eslint:recommended", "prettier"],
"rules": {
// "no-console": "warn",
"no-console": "warn",
"no-mixed-spaces-and-tabs": "warn",
// "no-unused-vars": "warn",
// "no-use-before-define": "error",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"prefer-const": [
"warn",
{
"destructuring": "any",
"ignoreReadBeforeAssign": true
}
],
"no-undef": "warn",
"no-unused-vars": "off",
"no-undef": "error",
"indent": ["warn", 4, { "SwitchCase": 1 }],
"quotes": ["warn", "double", { "avoidEscape": true }],
"semi": "error",
Expand Down
20 changes: 13 additions & 7 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"parser": "babel-eslint",
"env": { "es6": true, "browser": true, "node": true },
"env": { "es6": true, "browser": true },
"extends": ["eslint:recommended"],
"rules": {
# "no-console": "warn",
"no-console": "warn",
"no-mixed-spaces-and-tabs": "warn",
# "no-unused-vars": "warn",
# "no-use-before-define": "error",
"no-undef": "off",
"no-unused-vars": "off",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"prefer-const": [
"warn",
{
"destructuring": "any",
"ignoreReadBeforeAssign": true
}
],
"no-undef": "error",
"no-unused-vars": "warn",
"indent": ["warn", 4, { "SwitchCase": 1 }],
"quotes": ["warn", "double", { "avoidEscape": true }],
"semi": "error",
Expand Down
2 changes: 1 addition & 1 deletion js/turtle-painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ class Painter {
h
);

if (!WRAP || !out) {
if (!WRAP || !out || this._fillState) {
this._move(ox, oy, nx, ny, true);
turtles.refreshCanvas();
} else {
Expand Down
75 changes: 50 additions & 25 deletions js/widgets/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA

/**
* This widget makes displays the status of selected parameters and notes as they are being played.
/*
global logo, blocks, docById, _showHideAuxMenu, analyzeProject, runAnalytics, scoreToChartData,
getChartOptions, loading:writable, Chart
*/

/* exported StatsWindow, loading */

/** This widget displays the status of selected parameters and notes as they are being played. */
class StatsWindow {
constructor() {
this.isOpen = true;
Expand All @@ -27,54 +32,74 @@ class StatsWindow {
this.doAnalytics();

this.widgetWindow.sendToCenter();
};
}

/**
* Renders and carries out analysis of the MB project.
*/
/** Renders and carries out analysis of the MB project. */
doAnalytics() {
toolbar.closeAuxToolbar(_showHideAuxMenu);
blocks.activeBlock = null;
let myChart = docById("myChart");
const myChart = docById("myChart");

let ctx = myChart.getContext("2d");
const ctx = myChart.getContext("2d");
loading = true;
document.body.style.cursor = "wait";

let myRadarChart = null;
let scores = analyzeProject(blocks);
const scores = analyzeProject(blocks);
runAnalytics(logo);
let data = scoreToChartData(scores);
const data = scoreToChartData(scores);
const __callback = () => {
let imageData = myRadarChart.toBase64Image();
let img = new Image();
const imageData = myRadarChart.toBase64Image();
const img = new Image();
img.src = imageData;
img.width = 200;
this.widgetWindow.getWidgetBody().appendChild(img);
blocks.hideBlocks();
logo.showBlocksAfterRun = false;
document.body.style.cursor = "default";
};
let options = getChartOptions(__callback);
const options = getChartOptions(__callback);
myRadarChart = new Chart(ctx).Radar(data, options);

this.jsonObject = document.createElement("ul");
this.jsonObject.style.float = "left";
this.widgetWindow.getWidgetBody().appendChild(this.jsonObject);
};
}

displayInfo(stats) {
let lowHertz = stats["lowestNote"][2] + 0.5;
let highHertz = stats["highestNote"][2] + 0.5;
const lowHertz = stats["lowestNote"][2] + 0.5;
const highHertz = stats["highestNote"][2] + 0.5;
this.jsonObject.innerHTML =
'<li>duples: ' + stats["duples"] + '</li>' +
'<li>triplets: ' + stats["triplets"] + '</li>' +
'<li>quintuplets: ' + stats["quintuplets"] + '</li>' +
'<li>pitch names: ' + Array.from(stats["pitchNames"]) + '</li>' +
'<li>number of notes: ' + stats["numberOfNotes"] + '</li>' +
'<li>lowest note: ' + stats["lowestNote"][0] + " , " + lowHertz.toFixed(0) + 'Hz</li>' +
'<li>highest note: ' + stats["highestNote"][0] + " , " + highHertz.toFixed(0) + 'Hz</li>' +
'<li>rests used: ' + stats["rests"] + '</li>' +
'<li>ornaments used: ' + stats["ornaments"] + '</li>'
"<li>duples: " +
stats["duples"] +
"</li>" +
"<li>triplets: " +
stats["triplets"] +
"</li>" +
"<li>quintuplets: " +
stats["quintuplets"] +
"</li>" +
"<li>pitch names: " +
Array.from(stats["pitchNames"]) +
"</li>" +
"<li>number of notes: " +
stats["numberOfNotes"] +
"</li>" +
"<li>lowest note: " +
stats["lowestNote"][0] +
" , " +
lowHertz.toFixed(0) +
"Hz</li>" +
"<li>highest note: " +
stats["highestNote"][0] +
" , " +
highHertz.toFixed(0) +
"Hz</li>" +
"<li>rests used: " +
stats["rests"] +
"</li>" +
"<li>ornaments used: " +
stats["ornaments"] +
"</li>";
}
}

0 comments on commit 240e63e

Please sign in to comment.