@@ -62,6 +62,9 @@ <h2>📝 Editor</h2>
6262</ div >
6363
6464< script >
65+ const savedCode = localStorage . getItem ( 'plotter_code' ) ;
66+ if ( savedCode !== null && savedCode . length >= 6 ) { document . getElementById ( 'code' ) . value = savedCode ; }
67+
6568const canvas = document . getElementById ( 'c' ) ;
6669const ctx = canvas . getContext ( '2d' ) ;
6770let scale = 50 , cx = 0 , cy = 0 ;
@@ -149,6 +152,7 @@ <h2>📝 Editor</h2>
149152function cadd ( z , w ) { return z . add ( w ) ; }
150153function cmul ( z , w ) { return z . mul ( w ) ; }
151154function csin ( z ) { return complex ( sin ( z . x ) * cosh ( z . y ) , cos ( z . x ) * sinh ( z . y ) ) ; }
155+ function cpow ( z , w ) { return cexp ( w . mul ( clog ( z ) ) ) ; }
152156
153157function cgamma_right ( z ) {
154158 const w = complex ( z . x - 1.0 , z . y ) ;
@@ -337,14 +341,18 @@ <h2>📝 Editor</h2>
337341
338342function runCode ( ) {
339343 const code = document . getElementById ( 'code' ) . value ;
344+ try {
345+ localStorage . setItem ( 'plotter_code' , code ) ;
346+ } catch ( e ) { }
340347 graphs = [ ] ;
341348 try {
342349 const fn = new Function ( 'draw' , 'randomColor' , 'sin' , 'cos' , 'tan' , 'log' , 'ln' , 'log2' , 'log10' ,
343350 'sqrt' , 'abs' , 'exp' , 'pow' , 'PI' , 'E' , 'asin' , 'acos' , 'atan' , 'atan2' ,
344- 'sinh' , 'cosh' , 'tanh' , 'floor' , 'ceil' , 'round' , 'sign' , 'min' , 'max' , 'random' , 'primes' , 'pix' , 'li' , 'complex' , 'gamma' , 'csin' , 'cexp' , 'clog' ,
351+ 'sinh' , 'cosh' , 'tanh' , 'floor' , 'ceil' , 'round' , 'sign' , 'min' , 'max' , 'random' , 'primes' , 'pix' , 'li' , 'complex' ,
352+ 'cgamma' , 'csin' , 'cexp' , 'clog' , 'cinv' , 'cpow' ,
345353 code ) ;
346354 fn ( draw , randomColor , sin , cos , tan , log , log , log2 , log10 , sqrt , abs , exp , pow , PI , E ,
347- asin , acos , atan , atan2 , sinh , cosh , tanh , floor , ceil , round , sign , min , max , random , primes , pix , li , complex , cgamma , csin , cexp , clog ) ;
355+ asin , acos , atan , atan2 , sinh , cosh , tanh , floor , ceil , round , sign , min , max , random , primes , pix , li , complex , cgamma , csin , cexp , clog , cinv , cpow ) ;
348356 document . getElementById ( 'cnt' ) . textContent = graphs . length ;
349357 render ( ) ;
350358 showMsg ( `✓ Build: ${ graphs . length } ` , 'ok' ) ;
0 commit comments