@@ -93,6 +93,13 @@ class Panel {
9393 this . buffer . line ( this . plotLeft , this . plotBottom , this . plotRight , this . plotBottom ) ;
9494 }
9595
96+ repaint ( ) {
97+ // Draw loop callback function
98+ this . buffer . background ( this . background ) ;
99+ this . drawPanel ( ) ;
100+ this . drawBorder ( ) ;
101+ }
102+
96103 drawPanel ( ) { }
97104
98105 calculateNumImages ( ) {
@@ -168,7 +175,6 @@ class Panel {
168175 this . buffer . text ( text , tickEnd + 2 , height - this . tickTextSize / 2 , this . buffer . width , height + this . tickTextSize / 2 ) ;
169176 } else {
170177 this . buffer . text ( text , 0 , height - this . tickTextSize / 2 , tickStart , height + this . tickTextSize / 2 ) ;
171-
172178 }
173179
174180 this . buffer . strokeWeight ( this . strokeWeight ) ;
@@ -342,7 +348,6 @@ class FreqPanel extends Panel{
342348 let num_bins = Math . round ( this . plotWidth / pixels_per_bin ) ;
343349 let normalize = 4 / fft . length ;
344350
345- this . buffer . background ( this . background ) ;
346351 this . buffer . stroke ( this . stroke ) ;
347352 this . drawPassBand ( ) ;
348353 this . buffer . beginShape ( ) ;
@@ -356,8 +361,7 @@ class FreqPanel extends Panel{
356361 this . buffer . endShape ( this . buffer . CLOSE ) ;
357362 this . buffer . strokeWeight ( this . strokeWeight ) ;
358363 this . buffer . stroke ( this . stroke ) ;
359- this . drawBorder ( ) ;
360- this . drawName ( ) ;
364+ this . drawName ( ) ;
361365 if ( tick === 'dirac' )
362366 this . drawDiracDashes ( ) ;
363367 else
@@ -375,13 +379,11 @@ class InputSigUnfilteredPanel extends Panel {
375379 }
376380
377381 drawPanel ( ) {
378- this . buffer . background ( this . background ) ;
379382 this . drawSignal ( this . settings . buffers . originalUnfiltered . display ) ;
380383 this . drawMidLine ( this ) ;
381384 this . drawName ( ) ;
382385 this . drawSignalAmplitudeTicks ( this , this . plotHeight / 2 , 4 ) ;
383386 this . drawTimeTicks ( this , this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
384- this . drawBorder ( ) ;
385387 }
386388}
387389
@@ -394,13 +396,11 @@ class FilterKernelPanel extends Panel {
394396 }
395397
396398 drawPanel ( ) {
397- this . buffer . background ( this . background ) ;
398399 this . drawSignal ( this . settings . buffers . filterKernel . display ) ;
399400 this . drawMidLine ( ) ;
400401 this . drawName ( ) ;
401402 this . drawSignalAmplitudeTicks ( this , this . plotHeight / 2 , 4 ) ;
402403 this . drawTimeTicks ( this , this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
403- this . drawBorder ( ) ;
404404 }
405405}
406406
@@ -413,14 +413,12 @@ class InputSigPanel extends Panel {
413413 }
414414
415415 drawPanel ( ) {
416- this . buffer . background ( this . background ) ;
417416 this . drawSignal ( this . settings . buffers . original . display ) ;
418417 this . drawMidLine ( ) ;
419418 this . drawName ( ) ;
420419 this . drawSignalAmplitudeTicks ( this , this . plotHeight / 2 , 4 ) ;
421420 this . drawTimeTicks ( this , this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
422- this . drawBorder ( ) ;
423- }
421+ }
424422}
425423
426424class DeltaModPanel extends Panel {
@@ -432,7 +430,6 @@ class DeltaModPanel extends Panel {
432430 }
433431
434432 drawPanel ( ) {
435- this . buffer . background ( this . background ) ;
436433 this . buffer . stroke ( [ 150 , 150 , 150 ] ) ;
437434 this . drawSignal ( this . settings . buffers . originalUnfiltered . display ) ;
438435 this . buffer . stroke ( [ 0 , 0 , 0 ] ) ;
@@ -441,8 +438,7 @@ class DeltaModPanel extends Panel {
441438 this . drawName ( ) ;
442439 this . drawSignalAmplitudeTicks ( this , this . plotHeight / 2 , 4 ) ;
443440 this . drawTimeTicks ( this , this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
444- this . drawBorder ( ) ;
445- }
441+ }
446442}
447443
448444
@@ -455,14 +451,12 @@ class ReconstructedSigPanel extends Panel {
455451 }
456452
457453 drawPanel ( ) {
458- this . buffer . background ( this . background ) ;
459454 this . drawSignal ( this . settings . buffers . reconstructed . display ) ;
460455 this . drawMidLine ( ) ;
461456 this . drawName ( ) ;
462457 this . drawSignalAmplitudeTicks ( this , this . plotHeight / 2 , 4 ) ;
463458 this . drawTimeTicks ( this , this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
464- this . drawBorder ( ) ;
465- }
459+ }
466460}
467461
468462class InputSigFreqPanel extends FreqPanel {
@@ -474,7 +468,6 @@ class InputSigFreqPanel extends FreqPanel {
474468 }
475469
476470 drawPanel ( ) {
477- this . buffer . background ( this . background ) ;
478471 let pixels_per_hz = this . plotWidth / this . settings . maxVisibleFrequency ;
479472 this . drawPassBand ( ) ;
480473 // let harmInc = 1;
@@ -494,8 +487,7 @@ class InputSigFreqPanel extends FreqPanel {
494487 }
495488
496489
497- this . drawBorder ( ) ;
498- this . drawFreqTicks ( this , this . numFreqTicks , pixels_per_hz ) ;
490+ this . drawFreqTicks ( this , this . numFreqTicks , pixels_per_hz ) ;
499491 this . drawFreqAmplitudeTicks ( this , this . plotHeight , 9 ) ;
500492 this . drawName ( ) ;
501493 }
@@ -573,8 +565,6 @@ class ImpulsePanel extends Panel {
573565 drawPanel ( ) {
574566 let base = this . plotBottom ;
575567 let ytop = this . plotTop + 10 ;
576- this . buffer . background ( this . background ) ;
577- this . drawBorder ( ) ;
578568
579569 let visibleSamples = Math . floor ( this . plotWidth / this . settings . downsamplingFactor / this . settings . timeZoom + 1 ) ;
580570 for ( let x = 0 ; x < visibleSamples ; x ++ ) {
@@ -615,8 +605,7 @@ class ImpulseFreqPanel extends FreqPanel {
615605 }
616606
617607 this . drawFreqAmplitudeTicks ( this . plotHeight , 9 ) ;
618- this . drawBorder ( ) ;
619- this . drawName ( ) ;
608+ this . drawName ( ) ;
620609 }
621610}
622611
@@ -630,16 +619,14 @@ class SampledInputPanel extends Panel{
630619 }
631620
632621 drawPanel ( ) {
633- this . buffer . background ( this . background ) ;
634622 this . drawDiscreteSignal ( this . settings . buffers . downsampled . display )
635623 this . drawMidLine ( ) ;
636624 this . drawName ( ) ;
637625 this . drawSignalAmplitudeTicks ( this . plotHeight / 2 , 4 ) ;
638626 this . drawSignalBinaryScaling ( this . plotHeight / 2 , 16 , this . settings ) ;
639627
640628 this . drawTimeTicks ( this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
641- this . drawBorder ( ) ;
642- }
629+ }
643630}
644631
645632const passband_doc = 'The frequency range below the nyquist frequency is highlighted by a light grey background. ' ;
@@ -653,7 +640,6 @@ class SampledInputFreqPanel extends FreqPanel{
653640 }
654641
655642 drawPanel ( ) {
656- this . buffer . background ( this . background ) ;
657643 this . buffer . stroke ( this . stroke ) ;
658644 this . drawPassBand ( ) ;
659645 this . drawDiracDashes ( ) ;
@@ -685,8 +671,7 @@ class SampledInputFreqPanel extends FreqPanel{
685671 }
686672 }
687673
688- this . drawBorder ( ) ;
689- this . drawFreqAmplitudeTicks ( this . plotHeight , 9 ) ;
674+ this . drawFreqAmplitudeTicks ( this . plotHeight , 9 ) ;
690675 this . drawName ( ) ;
691676 }
692677}
@@ -701,14 +686,12 @@ class QuantNoisePanel extends Panel{
701686 + time_ticks_doc + amp_ticks_doc + midline_doc ;
702687 }
703688 drawPanel ( ) {
704- this . buffer . background ( this . background ) ;
705689 this . drawDiscreteSignal ( this . settings . buffers . quantNoise . display ) ;
706690 this . drawMidLine ( ) ;
707691 this . drawName ( ) ;
708692 this . drawSignalAmplitudeTicks ( this . plotHeight / 2 , 4 ) ;
709693 this . drawTimeTicks ( this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
710- this . drawBorder ( ) ;
711- }
694+ }
712695}
713696
714697class QuantNoiseFFTPanel extends FreqPanel {
@@ -735,9 +718,7 @@ class DitherDistributionHistogramPanel extends Panel{
735718 }
736719
737720 drawPanel ( ) {
738- this . buffer . background ( this . background ) ;
739- this . drawBorder ( ) ;
740- this . drawName ( ) ;
721+ this . drawName ( ) ;
741722 const x_axis_low = - 1.2 ;
742723 const x_axis_high = 1.2 ;
743724 for ( let i = x_axis_low ; i <= x_axis_high ; i += 0.2 ) {
@@ -770,7 +751,6 @@ class InputPlusSampledPanel extends Panel {
770751 }
771752
772753 drawPanel ( ) {
773- this . buffer . background ( this . background ) ;
774754 this . drawDiscreteSignal ( this . settings . buffers . downsampled . display )
775755 this . buffer . stroke ( "gray" ) ;
776756 this . drawSignal ( this . settings . buffers . original . display ) ;
@@ -779,8 +759,7 @@ class InputPlusSampledPanel extends Panel {
779759 this . drawSignalAmplitudeTicks ( this . plotHeight / 2 , 4 ) ;
780760 this . drawSignalBinaryScaling ( this . plotHeight / 2 , 16 , this . settings ) ;
781761 this . drawTimeTicks ( this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
782- this . drawBorder ( ) ;
783- }
762+ }
784763}
785764
786765class AllSignalsPanel extends Panel {
@@ -793,7 +772,6 @@ class AllSignalsPanel extends Panel {
793772 }
794773
795774 drawPanel ( ) {
796- this . buffer . background ( this . background ) ;
797775 this . drawDiscreteSignal ( this . settings . buffers . downsampled . display ) ;
798776 this . drawSignal ( this . settings . buffers . originalUnfiltered . display ) ;
799777 this . buffer . drawingContext . setLineDash ( [ 5 , 5 ] ) ;
@@ -803,6 +781,5 @@ class AllSignalsPanel extends Panel {
803781 this . drawName ( ) ;
804782 this . drawSignalAmplitudeTicks ( this . plotHeight / 2 , 4 ) ;
805783 this . drawTimeTicks ( this . numTimeTicks / this . settings . timeZoom , 1 / ( this . settings . timeZoom * this . settings . sampleRate ) ) ;
806- this . drawBorder ( ) ;
807- }
784+ }
808785}
0 commit comments