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

Oscilloscope: Error Fix and UI modification #2855

Merged
merged 3 commits into from
Feb 24, 2021
Merged
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
28 changes: 20 additions & 8 deletions js/widgets/oscilloscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@
*/

/* global _, SMALLERBUTTON, BIGGERBUTTON, Tone, instruments */

/*
Globals location
- js/artwork.js
SMALLERBUTTON,BIGGERBUTTON
- js/utils/utils.js
_
- js/activity.js
Tone
- js/utils/synthutils.js
instruments

*/
/* exported Oscilloscope */

/**
* @class
* @classdesc pertains to setting up all features of the Oscilloscope Widget.
*/
class Oscilloscope {
static ICONSIZE = 32;
static ICONSIZE = 40;
static analyserSize = 8192;
/**
* @constructor
Expand Down Expand Up @@ -54,27 +65,28 @@ class Oscilloscope {
this.pitchAnalysers = {};
widgetWindow.destroy();
};

document.getElementsByClassName("wfbToolbar")[0].style.backgroundColor = "#e8e8e8";
document.getElementsByClassName("wfbWidget")[0].style.backgroundColor = "#FFFFFF";
const step = 10;
this.zoomFactor = 40.0;
this.verticalOffset = 0;
const zoomInButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("ZOOM IN"));
const zoomInButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("Zoom In"));

zoomInButton.onclick = () => {
this.zoomFactor += step;
};
zoomInButton.children[0].src = `data:image/svg+xml;base64,${window.btoa(
unescape(encodeURIComponent(SMALLERBUTTON))
unescape(encodeURIComponent(BIGGERBUTTON))
)}`;

const zoomOutButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("ZOOM OUT"));
const zoomOutButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("Zoom Out"));

zoomOutButton.onclick = () => {
this.zoomFactor -= step;
};

zoomOutButton.children[0].src = `data:image/svg+xml;base64,${window.btoa(
unescape(encodeURIComponent(BIGGERBUTTON))
unescape(encodeURIComponent(SMALLERBUTTON))
)}`;

widgetWindow.sendToCenter();
Expand Down Expand Up @@ -132,7 +144,7 @@ class Oscilloscope {
this.drawVisualIDs[turtleIdx] = requestAnimationFrame(draw);
if (!turtle.running) return;

canvasCtx.fillStyle = "rgb(200, 200, 200)";
canvasCtx.fillStyle = "#FFFFFF";
const dataArray = this.pitchAnalysers[turtleIdx].getValue();
const bufferLength = dataArray.length;
canvasCtx.fillRect(0, 0, width, height);
Expand Down