@@ -42,7 +42,7 @@ class ContourDrawingDemo implements DemoInstance {
4242
4343 // Configuration
4444 private axisRange = { min : - 5 , max : 5 } ;
45- private samplePointCount = 32 ;
45+ private samplePointCount = 256 ;
4646 private frameDelay = 10 ;
4747 private closeThresholdPixels = 8 ; // Auto-close if within this many pixels of start (marker radius 7 + border 1)
4848 private readonly VECTOR_COLORS = [
@@ -59,13 +59,13 @@ class ContourDrawingDemo implements DemoInstance {
5959 private pointsDisplay ! : InfoDisplay ;
6060 private nInput ! : HTMLInputElement ;
6161 private nError ! : HTMLSpanElement ;
62- private kCoefficients = 32 ;
62+ private kCoefficients = 64 ;
6363 private kInput ! : HTMLInputElement ;
6464 private kError ! : HTMLSpanElement ;
6565 private delayInput ! : HTMLInputElement ;
6666 private delayError ! : HTMLSpanElement ;
67- private hideOriginal : boolean = false ;
68- private hideOriginalContainer : HTMLElement | null = null ;
67+ private showOriginal : boolean = true ;
68+ private showOriginalContainer : HTMLElement | null = null ;
6969 private progressive : boolean = false ;
7070 private progressiveContainer : HTMLElement | null = null ;
7171 private progressiveN : number = 2 ;
@@ -191,13 +191,13 @@ class ContourDrawingDemo implements DemoInstance {
191191 instructions2 . style . fontSize = '0.85em' ;
192192 instructions2 . style . opacity = '0.7' ;
193193
194- // Hide original checkbox (hidden until contour closes)
195- this . hideOriginalContainer = createCheckbox (
196- 'Hide original' ,
197- this . hideOriginal ,
198- ( checked : boolean ) => { this . hideOriginal = checked ; }
194+ // Show original checkbox (hidden until contour closes)
195+ this . showOriginalContainer = createCheckbox (
196+ 'Show original' ,
197+ this . showOriginal ,
198+ ( checked : boolean ) => { this . showOriginal = checked ; }
199199 ) ;
200- this . hideOriginalContainer . style . display = 'none' ;
200+ this . showOriginalContainer . style . display = 'none' ;
201201
202202 // Progressive checkbox (hidden until contour closes)
203203 this . progressiveContainer = createCheckbox (
@@ -217,7 +217,7 @@ class ContourDrawingDemo implements DemoInstance {
217217 const row1 = createControlRow ( [ this . resetButton , this . pointsDisplay . element ] ) ;
218218 const row2 = createControlRow ( [ this . nInput . parentElement ! , nNote , this . nError , this . kInput . parentElement ! , kNote , this . kError ] ) ;
219219 const row2a = createControlRow ( [ this . delayInput . parentElement ! , this . delayError ] ) ;
220- const row2b = createControlRow ( [ this . hideOriginalContainer , this . progressiveContainer , shareButtonContainer ] ) ;
220+ const row2b = createControlRow ( [ this . showOriginalContainer , this . progressiveContainer , shareButtonContainer ] ) ;
221221 const row3 = createControlRow ( [ instructions1 ] ) ;
222222 const row4 = createControlRow ( [ instructions2 ] ) ;
223223
@@ -303,46 +303,49 @@ class ContourDrawingDemo implements DemoInstance {
303303 ctx . fillStyle = this . isDark ? 'rgba(30, 30, 30, 0.9)' : 'rgba(255, 255, 255, 0.95)' ;
304304 ctx . fillRect ( 0 , 0 , width , height ) ;
305305
306- // Grid lines
307- const gridColor = this . isDark ? 'rgba(255, 255, 255, 0.15)' : 'rgba(0, 0, 0, 0.1)' ;
308- ctx . strokeStyle = gridColor ;
309- ctx . lineWidth = 1 ;
310- for ( let i = this . axisRange . min ; i <= this . axisRange . max ; i ++ ) {
311- if ( i === 0 ) continue ; // Skip zero lines, drawn separately
312- const { x } = this . plotToCanvas ( { x : i , y : 0 } ) ;
313- const { y } = this . plotToCanvas ( { x : 0 , y : i } ) ;
314- // Vertical line
306+ // Only show grid/axes when showOriginal is enabled or contour is not closed yet
307+ const showOriginalAndGrid = this . showOriginal || this . state !== 'closed' ;
308+
309+ if ( showOriginalAndGrid ) {
310+ // Grid lines
311+ const gridColor = this . isDark ? 'rgba(255, 255, 255, 0.15)' : 'rgba(0, 0, 0, 0.1)' ;
312+ ctx . strokeStyle = gridColor ;
313+ ctx . lineWidth = 1 ;
314+ for ( let i = this . axisRange . min ; i <= this . axisRange . max ; i ++ ) {
315+ if ( i === 0 ) continue ; // Skip zero lines, drawn separately
316+ const { x } = this . plotToCanvas ( { x : i , y : 0 } ) ;
317+ const { y } = this . plotToCanvas ( { x : 0 , y : i } ) ;
318+ // Vertical line
319+ ctx . beginPath ( ) ;
320+ ctx . moveTo ( x , 0 ) ;
321+ ctx . lineTo ( x , height ) ;
322+ ctx . stroke ( ) ;
323+ // Horizontal line
324+ ctx . beginPath ( ) ;
325+ ctx . moveTo ( 0 , y ) ;
326+ ctx . lineTo ( width , y ) ;
327+ ctx . stroke ( ) ;
328+ }
329+
330+ // Zero lines (axes)
331+ const zerolineColor = this . isDark ? 'rgba(255, 255, 255, 0.6)' : 'rgba(0, 0, 0, 0.6)' ;
332+ ctx . strokeStyle = zerolineColor ;
333+ ctx . lineWidth = 2 ;
334+ const origin = this . plotToCanvas ( { x : 0 , y : 0 } ) ;
335+ // X-axis
315336 ctx . beginPath ( ) ;
316- ctx . moveTo ( x , 0 ) ;
317- ctx . lineTo ( x , height ) ;
337+ ctx . moveTo ( 0 , origin . y ) ;
338+ ctx . lineTo ( width , origin . y ) ;
318339 ctx . stroke ( ) ;
319- // Horizontal line
340+ // Y-axis
320341 ctx . beginPath ( ) ;
321- ctx . moveTo ( 0 , y ) ;
322- ctx . lineTo ( width , y ) ;
342+ ctx . moveTo ( origin . x , 0 ) ;
343+ ctx . lineTo ( origin . x , height ) ;
323344 ctx . stroke ( ) ;
324345 }
325346
326- // Zero lines (axes)
327- const zerolineColor = this . isDark ? 'rgba(255, 255, 255, 0.6)' : 'rgba(0, 0, 0, 0.6)' ;
328- ctx . strokeStyle = zerolineColor ;
329- ctx . lineWidth = 2 ;
330- const origin = this . plotToCanvas ( { x : 0 , y : 0 } ) ;
331- // X-axis
332- ctx . beginPath ( ) ;
333- ctx . moveTo ( 0 , origin . y ) ;
334- ctx . lineTo ( width , origin . y ) ;
335- ctx . stroke ( ) ;
336- // Y-axis
337- ctx . beginPath ( ) ;
338- ctx . moveTo ( origin . x , 0 ) ;
339- ctx . lineTo ( origin . x , height ) ;
340- ctx . stroke ( ) ;
341-
342347 // Contour path (draw first so trail appears on top)
343- // Skip drawing original when hideOriginal is enabled and contour is closed
344- const showOriginal = ! this . hideOriginal || this . state !== 'closed' ;
345- if ( this . points . length > 0 && showOriginal ) {
348+ if ( this . points . length > 0 && showOriginalAndGrid ) {
346349 const lineColor = this . state === 'closed' ? cssColors . warning : cssColors . error ;
347350 ctx . strokeStyle = lineColor ;
348351 ctx . lineWidth = 3 ;
@@ -646,9 +649,13 @@ class ContourDrawingDemo implements DemoInstance {
646649 this . statusDisplay . update ( 'Contour closed' ) ;
647650 this . pointsDisplay . update ( String ( this . points . length ) ) ;
648651
649- // Show the hide original, progressive checkboxes, and copy link button
650- if ( this . hideOriginalContainer ) {
651- this . hideOriginalContainer . style . display = '' ;
652+ // Show the show original, progressive checkboxes, and copy link button
653+ // Uncheck show original by default when contour completes
654+ this . showOriginal = false ;
655+ if ( this . showOriginalContainer ) {
656+ this . showOriginalContainer . style . display = '' ;
657+ const checkbox = this . showOriginalContainer . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
658+ if ( checkbox ) checkbox . checked = false ;
652659 }
653660 if ( this . progressiveContainer ) {
654661 this . progressiveContainer . style . display = '' ;
@@ -714,12 +721,12 @@ class ContourDrawingDemo implements DemoInstance {
714721 this . state = 'closed' ;
715722 this . points = [ ] ; // No original path
716723
717- // Set up hide original mode (there's nothing to show anyway)
718- this . hideOriginal = true ;
719- if ( this . hideOriginalContainer ) {
720- this . hideOriginalContainer . style . display = '' ;
721- const checkbox = this . hideOriginalContainer . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
722- if ( checkbox ) checkbox . checked = true ;
724+ // Hide original (there's nothing to show anyway for URL-loaded )
725+ this . showOriginal = false ;
726+ if ( this . showOriginalContainer ) {
727+ this . showOriginalContainer . style . display = '' ;
728+ const checkbox = this . showOriginalContainer . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
729+ if ( checkbox ) checkbox . checked = false ;
723730 }
724731
725732 // Set up progressive mode starting at K=2
@@ -883,12 +890,12 @@ class ContourDrawingDemo implements DemoInstance {
883890 this . statusDisplay . update ( this . INITIAL_STATUS ) ;
884891 this . pointsDisplay . update ( '0' ) ;
885892
886- // Hide and reset the hide original checkbox
887- this . hideOriginal = false ;
888- if ( this . hideOriginalContainer ) {
889- this . hideOriginalContainer . style . display = 'none' ;
890- const checkbox = this . hideOriginalContainer . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
891- if ( checkbox ) checkbox . checked = false ;
893+ // Hide and reset the show original checkbox
894+ this . showOriginal = true ;
895+ if ( this . showOriginalContainer ) {
896+ this . showOriginalContainer . style . display = 'none' ;
897+ const checkbox = this . showOriginalContainer . querySelector ( 'input[type="checkbox"]' ) as HTMLInputElement ;
898+ if ( checkbox ) checkbox . checked = true ;
892899 }
893900
894901 // Hide and reset the progressive checkbox
@@ -914,11 +921,11 @@ class ContourDrawingDemo implements DemoInstance {
914921 }
915922
916923 // Reset N and K to defaults
917- this . samplePointCount = 32 ;
918- this . nInput . value = '32 ' ;
924+ this . samplePointCount = 256 ;
925+ this . nInput . value = '256 ' ;
919926 this . nError . style . display = 'none' ;
920- this . kCoefficients = 32 ;
921- this . kInput . value = '32 ' ;
927+ this . kCoefficients = 64 ;
928+ this . kInput . value = '64 ' ;
922929 this . kError . style . display = 'none' ;
923930
924931 this . render ( ) ;
0 commit comments