@@ -3,9 +3,10 @@ require "common"
33require " colors"
44local luv = require " colors_luv"
55-- local size_mult=0.25
6- -- __set_window_size(2560*size_mult,1440*size_mult)
7- __set_window_size (1280 ,720 )
8- local aspect_ratio = 1280 / 720
6+ local win_w = 1024 -- 2560
7+ local win_h = 1024 -- 1440
8+ __set_window_size (win_w ,win_h )
9+ local aspect_ratio = win_w / win_h
910local size = STATE .size
1011local max_palette_size = 50
1112local sample_count = 50000
@@ -422,23 +423,6 @@ function gen_palette( )
422423 end
423424 end
424425 palette .generators [palette .current_gen ][2 ](ret ,hue_range ,sat_range ,lit_range )
425-
426- --[[ complementary
427- gen_shades(ret,h1,s,l,0.15,5)
428- gen_shades(ret,1-h1,s,0.15,l,5)
429- --]]
430- --[[ triadic
431- gen_shades(ret,h1,s,l,0.2,5)
432- gen_shades(ret,math.fmod(h1+0.33,1),s,0.2,l/2,5)
433- gen_shades(ret,math.fmod(h1+0.66,1),s,l/2,l,3)
434- --]]
435- --[[ anologous
436- gen_shades(ret,h1,s,0.2,l,3)
437- gen_shades(ret,math.fmod(h1+0.05,1),s,0.2,l,3)
438- gen_shades(ret,math.fmod(h1+0.1,1),s/2,l,0,3)
439- gen_shades(ret,math.fmod(h1+0.15,1),s/2,l,0,3)
440- gen_shades(ret,math.fmod(h1+0.2,1),s,l,0,3)
441- --]]
442426end
443427function palette_chooser ()
444428 if imgui .RadioButton (" Show palette" ,palette .show ) then
@@ -567,6 +551,29 @@ function rand_weighted(tbl)
567551 end
568552 end
569553end
554+ function replace_random ( s ,substr ,rep )
555+ local num_match = 0
556+ local function count ( )
557+ num_match = num_match + 1
558+ return false
559+ end
560+ string.gsub (s ,substr ,count )
561+ print (" input:" ,s ," found:" ,count )
562+ num_rep = math.random (0 ,num_match - 1 )
563+ print (" replacing:" ,num_rep )
564+ function rep_one ( )
565+ if num_rep == 0 then
566+ num_rep = num_rep - 1
567+ return rep ()
568+ else
569+ num_rep = num_rep - 1
570+ return false
571+ end
572+ end
573+ local ret = string.gsub (s ,substr ,rep_one )
574+ print (" returning:" ,ret )
575+ return ret
576+ end
570577function random_math ( steps ,seed )
571578 local cur_string = seed or " R"
572579
@@ -578,11 +585,12 @@ function random_math( steps,seed )
578585 end
579586
580587 for i = 1 ,steps do
581- cur_string = string.gsub (cur_string ," R" ,M )
588+ cur_string = replace_random (cur_string ," R" ,M )
582589 end
583590 cur_string = string.gsub (cur_string ," R" ,MT )
584591 return cur_string
585592end
593+
586594function random_math_fourier ( steps ,complications ,seed )
587595 local cur_string = seed or " (R)/2"
588596 for i = 1 ,steps do
@@ -650,33 +658,33 @@ function gui()
650658 end
651659 rand_complexity = rand_complexity or 3
652660 if imgui .Button (" Rand function" ) then
653- -- str_x=random_math(rand_complexity)
654- -- str_y=random_math(rand_complexity)
655- -- str_x=random_math_fourier(4 ,rand_complexity)
661+ str_x = random_math (rand_complexity )
662+ str_y = random_math (rand_complexity )
663+ -- str_x=random_math_fourier(2 ,rand_complexity)
656664 -- str_y=random_math_fourier(4,rand_complexity)
657665
658- str_x = random_math_power (3 ,rand_complexity )
659- str_y = random_math_power (3 ,rand_complexity )
666+ -- str_x=random_math_power(3,rand_complexity)
667+ -- str_y=random_math_power(3,rand_complexity)
660668 -- str_x="s.x"
661669 -- str_y="s.y"
662670
663671 -- str_y="-"..str_x
664- -- str_x=random_math(6 ,"cos(R)*R")
665- -- str_y=random_math(6 ,"sin(R)*R")
672+ -- str_x=random_math(rand_complexity ,"cos(R)*R")
673+ -- str_y=random_math(rand_complexity ,"sin(R)*R")
666674 -- str_y="sin("..str_x..")"
667675 -- str_x="cos("..str_x..")"
668676 -- str_x=random_math_power(2,rand_complexity).."/"..random_math_power(2,rand_complexity)
669677 -- str_y=random_math_fourier(2,rand_complexity).."/"..str_x
670678 str_preamble = " "
671679 str_postamble = " "
672- --[[ offset
673- str_preamble=str_preamble.."s+=params;"
680+ -- [[ offset
681+ str_preamble = str_preamble .. " s+=params.xy ;"
674682 -- ]]
675- -- [[ normed-like
683+ --[[ normed-like
676684 str_preamble=str_preamble.."float l=length(s);"
677685 str_postamble=str_postamble.."s/=l;s*=move_dist;"
678686 --]]
679- --[[ normed-like2
687+ -- [[ normed-like2
680688 str_preamble = str_preamble .. " "
681689 str_postamble = str_postamble .. " s/=length(s);s*=move_dist;s+=p;"
682690 -- ]]
0 commit comments