From 852a1eed90c709bc9b5cdb7766d1c5ede3f03602 Mon Sep 17 00:00:00 2001 From: Alex Bruce Date: Tue, 1 Nov 2022 11:16:49 -0700 Subject: [PATCH] Initial commit of my past work with cfdg --- .gitignore | 3 + colorhills/isohills.cfdg | 79 ++++++++++++++ colorhills/squarefrag.cfdg | 76 +++++++++++++ danil/base.cfdg | 154 +++++++++++++++++++++++++++ danil/danil.cfdg | 189 +++++++++++++++++++++++++++++++++ fletching/fletching-tyler.cfdg | 30 ++++++ fletching/fletching.cfdg | 78 ++++++++++++++ fletching/my-frac-noise.cfdg | 43 ++++++++ flows/flows.cfdg | 39 +++++++ flows/flows2.cfdg | 41 +++++++ flows/flows3.cfdg | 44 ++++++++ flows/flows4.cfdg | 44 ++++++++ flows/flows5.cfdg | 86 +++++++++++++++ flows/flows6.cfdg | 135 +++++++++++++++++++++++ flows/my-frac-noise.cfdg | 43 ++++++++ hexs/hexs.cfdg | 26 +++++ isohills/isohills.cfdg | 79 ++++++++++++++ isohills/squarefrag.cfdg | 76 +++++++++++++ perlin.cfdg | 83 +++++++++++++++ reference/ancient.cfdg | 94 ++++++++++++++++ reference/gradient.bmp | Bin 0 -> 8044 bytes reference/gradient.cfdg | 16 +++ reference/pile-of-code.cfdg | 13 +++ reference/sines.cfdg | 7 ++ reference/sponge.cfdg | 55 ++++++++++ 25 files changed, 1533 insertions(+) create mode 100644 .gitignore create mode 100644 colorhills/isohills.cfdg create mode 100644 colorhills/squarefrag.cfdg create mode 100644 danil/base.cfdg create mode 100644 danil/danil.cfdg create mode 100644 fletching/fletching-tyler.cfdg create mode 100644 fletching/fletching.cfdg create mode 100644 fletching/my-frac-noise.cfdg create mode 100644 flows/flows.cfdg create mode 100644 flows/flows2.cfdg create mode 100644 flows/flows3.cfdg create mode 100644 flows/flows4.cfdg create mode 100644 flows/flows5.cfdg create mode 100644 flows/flows6.cfdg create mode 100644 flows/my-frac-noise.cfdg create mode 100644 hexs/hexs.cfdg create mode 100644 isohills/isohills.cfdg create mode 100644 isohills/squarefrag.cfdg create mode 100644 perlin.cfdg create mode 100644 reference/ancient.cfdg create mode 100644 reference/gradient.bmp create mode 100644 reference/gradient.cfdg create mode 100644 reference/pile-of-code.cfdg create mode 100644 reference/sines.cfdg create mode 100644 reference/sponge.cfdg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a30149a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +**.png +**.jpg +**.svg diff --git a/colorhills/isohills.cfdg b/colorhills/isohills.cfdg new file mode 100644 index 0000000..39dffbb --- /dev/null +++ b/colorhills/isohills.cfdg @@ -0,0 +1,79 @@ +// Chris Coyne, copyright 2006 +// Creative Commons licensed: Creative Commons Attribution 3.0 Unported +CF::Background = [b 1 0.5] +CF::MinimumSize = 0.1 +CF::Impure = 1 +CF::Size = [s 1.7 1.7] + +strokeWidth=0.0025 + +startshape isoGrid() + +shape isoGrid { + loop yi = 50 [ y (0.5/(-50/2)) z 500] + loop xi = 50 [ x (1 /( 50/2))] + if (rand(0,1) <= 0.1) iso() [x -1 0.5 z randint(0,499)] +} + +shape iso { + isoTop() [] + isoFill() [z -0.01 h 1 (60*randint(0,6)) sat 1 0.75 b 1 0.6 ] + SQUARE [trans 0 0 -1 -0.5 0 -1 b 1 z -0.2 y -0.5] +} + +shape isoFill +rule 0.5 { + isoFillDown(select(rand(4),200,100,50,25)) [] + isoFillDown(select(rand(3),100,50,25)) [f 90] +} +rule 0.25 { + isoFillDown(select(rand(4),200,100,50,25)) [] +} +rule 0.25 { + isoFillDown(select(rand(3),100,50,25)) [f 90] +} +rule { + isoFillLeft(select(rand(3),100,50,25)) [] +} +rule { + isoFillLeft(select(rand(3),100,50,25)) [f 90] +} +rule { + isoFillWide(select(rand(4),100,50,25,12.5)) [] +} +rule {} + +shape isoFillDown(n) { + loop n [x (1/n) (-0.5/n)] isoDown() [] +} + +path isoDown { + LINETO(0,-1) + STROKE(strokeWidth)[] +} + +shape isoFillLeft(n) { + loop n-1 [x (-1/n) (-0.5/n)] isoLeft() [x (-1/n) (-0.5/n)] +} + +path isoLeft { + LINETO(1,-0.5) + STROKE(strokeWidth)[] +} + +shape isoFillWide(n) { + loop w=n-1 [] isoWide(w/(n)) [] +} + +path isoWide(w) { + MOVETO(-w,-w/2) + LINETO(w,-w/2) + STROKE(strokeWidth)[] +} + +path isoTop { + MOVETO(-1,-0.5) + LINETO(0,0) + LINETO(1,-0.5) + STROKE(strokeWidth)[] +} diff --git a/colorhills/squarefrag.cfdg b/colorhills/squarefrag.cfdg new file mode 100644 index 0000000..cb49dbf --- /dev/null +++ b/colorhills/squarefrag.cfdg @@ -0,0 +1,76 @@ +// Chris Coyne, copyright 2006 +// Creative Commons licensed: Creative Commons Attribution 3.0 Unported +CF::Background = [b 1 0.5] +CF::MinimumSize = 0.1 +CF::Impure = 1 +CF::Size = [s 10 10 x -12 y -12] + +strokeWidth=0.01 + +startshape boxGrid() [] + +shape boxGrid { + n=200 + loop n [ y sqrt(0.02) z -1000 b 0.05 ] + loop n [ x sqrt(0.02) ] + if(randint(0,5)==0) box() [r (45 + randint(0,4)*90) z -randint(0,999)] +} + +shape box { + hueColor=(randint(6)*60) + SQUARE [b 1 1 z -0.2] + fill() [b 1 0.6 sat 1 0.7 h 1 hueColor z -0.1] + outline() [h 1 hueColor sat 1 0.7 b 1 0.6] +} + +shape fill + rule { + squareFill()[] + } + rule { + downFill()[] + } + rule { + diagFill()[] + } + rule 0.2 { + + } + +shape squareFill { + n=select(randint(3),10,20,40) + loop xi = n [ x (1/n) ] + loop yi = n [ y (1/n) ] + if(mod((xi+yi),2)) SQUARE [s (1/n) x (-(n/2-0.5)/n) (-(n/2-0.5)/n) ] +} + +path downFill { + n=select(randint(3),10,20,40) + loop n-1 [x (1/n)]{ + MOVETO((-(n/2-1)/n),0.5 ) + LINETO((-(n/2-1)/n),-0.5) + } + STROKE(strokeWidth, CF::SquareCap) [] +} + +shape diagFill { + n=select(randint(3),10,20,40) + loop i=n [] diagFillLine(i/n)[] + loop i=n [] diagFillLine(i/n)[f -45] +} + +path diagFillLine(w) { + MOVETO(-0.5 + w, 0.5 ) + LINETO( 0.5 ,-0.5 + w) + STROKE(strokeWidth) [] +} + +path outline { + MOVETO( 0.5, 0.5) + LINETO( 0.5,-0.5) + LINETO(-0.5,-0.5) + LINETO(-0.5, 0.5) + LINETO( 0.5, 0.5) + STROKE(strokeWidth, CF::SquareCap)[] +} + diff --git a/danil/base.cfdg b/danil/base.cfdg new file mode 100644 index 0000000..af6c4ac --- /dev/null +++ b/danil/base.cfdg @@ -0,0 +1,154 @@ +// Chris Coyne, copyright 2006 +// Creative Commons licensed: Creative Commons Attribution 3.0 Unported +CF::Background = [b 1] +CF::MinimumSize = 0.5 + +startshape split(0) + baseSpace = 0.003 + spaceIncrease = 1.5 + maxDepth = 8 + +shape split(natural depth) { + spacing = baseSpace*(spaceIncrease)^depth + scale = 0.5 - spacing + shift = 0.25 + spacing/2 + + leaf(=) [x shift y -shift s scale r (randint(4)*90)] + leaf(=) [x -shift y -shift s scale r (randint(4)*90)] + leaf(=) [x -shift y shift s scale r (randint(4)*90)] + leaf(=) [x shift y shift s scale r (randint(4)*90)] +} + +path donut_bit(natural depth) { + spacing = baseSpace*(spaceIncrease)^depth + MOVETO(0+spacing, 0.5) + LINETO(0.5, 0.5) + ARCTO(-0.5, -0.5, 1, CF::ArcCW) + LINETO(-0.5, 0-spacing) + ARCTO(0+spacing, 0.5, 0.5) + CLOSEPOLY() + FILL[] +} + +shape grid3(vector9 g){ + loop xz = 3 [ x (1/3) ] + loop yz = 3 [ y (1/3) ] + if (g[xz + yz*3]) SQUARE [s (1/3) x (-1/3) y (-1/3) ] +} + +shape grid5(vector25 g){ + loop xz = 5 [ x (1/5) ] + loop yz = 5 [ y (1/5) ] + if (g[xz + yz*5]) SQUARE [s (1/5) x (-2/5) y (-2/5) ] +} + +path dStripe(start, stop){ + MOVETO(-0.5,-0.5+start) + LINETO(-0.5, stop-0.5) + LINETO( stop-0.5,-0.5) + LINETO(-0.5+start,-0.5) + CLOSEPOLY() + FILL[] +} + +shape hazard2 { + n = 2 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape hazard3 { + n = 3 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape hazard4 { + n = 4 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape leaf(natural depth) + rule { + figure(depth +1) [] + } + rule 1.7 { + if (depth < maxDepth) split(depth + 1) [] + if (depth >= maxDepth) figure(depth + 1) [] + } + +shape figure(natural depth) + rule { + SQUARE [] + } + rule { + SQUARE [] + SQUARE [s 0.5 b 1] + } + rule { + CIRCLE [] + } + rule { + CIRCLE [] + CIRCLE [s 0.5 b 1] + } + rule { + grid3((1,0,1, + 1,1,1, + 0,1,0)) [] + } + rule { + grid3((1,1,1, + 1,0,0, + 1,1,1)) [] + } + rule { + grid3((1,0,0, + 0,1,0, + 0,0,1)) [] + } + rule { + grid3((1,0,1, + 1,1,1, + 1,0,1)) [] + } + rule { + grid3((1,0,0, + 1,1,1, + 0,0,1)) [] + } + rule { + grid3((1,0,0, + 1,0,0, + 1,1,1)) [] + } + rule { + grid5((1,1,1,1,1, + 1,0,0,0,1, + 1,1,1,1,1, + 1,0,0,0,1, + 1,0,0,0,1)) [] + } + rule { + grid5((1,0,1,0,1, + 1,0,1,0,0, + 1,0,1,1,1, + 1,0,0,0,0, + 1,1,1,1,1)) [] + } + rule { + hazard2 [] + } + rule { + if(depth < maxDepth - 1) hazard3 [] + } + rule { + if(depth < maxDepth - 2) hazard4 [] + } + rule { + donut_bit(depth) [] + } + rule { + + } diff --git a/danil/danil.cfdg b/danil/danil.cfdg new file mode 100644 index 0000000..b6beba5 --- /dev/null +++ b/danil/danil.cfdg @@ -0,0 +1,189 @@ +bg = [b 1 sat 0 hue 0] +CF::Background = bg +CF::MinimumSize = 1 + +startshape split3(0) [b 0.5] + baseSpace = 0.003 + spaceIncrease = 1.25 + maxDepth = 14 + +spaceSize(depth) = baseSpace*(spaceIncrease)^depth + +shape split(natural depth) { + spacing = spaceSize(depth) + scale = 0.5 - spacing + shift = 0.25 + spacing/2 + + leaf(=) [x shift y -shift s scale r (randint(4)*90)] + leaf(=) [x -shift y -shift s scale r (randint(4)*90)] + leaf(=) [x -shift y shift s scale r (randint(4)*90)] + leaf(=) [x shift y shift s scale r (randint(4)*90)] +} + +shape split3(natural depth) { + spacing = spaceSize(depth) + scale = (1/3) - spacing + shift = (1/3) + spacing/3 + + loop xz = 3 [x shift] + loop yz = 3 [y shift] + leaf(=) [s scale r (randint(4)*90) x -shift y -shift] +} + +shape split3start(natural depth) { + spacing = spaceSize(depth) + scale = (1/3) - spacing + shift = (1/3) + spacing/3 + + leaf(=) [s scale r (randint(4)*90) x -shift y -shift sat 0.5 hue 0] + leaf(=) [s scale r (randint(4)*90) y -shift sat 0.5 hue 45] + leaf(=) [s scale r (randint(4)*90) x shift y -shift sat 0.5 hue 90] + leaf(=) [s scale r (randint(4)*90) x -shift sat 0.5 hue 315] + leaf(=) [s scale r (randint(4)*90) sat 0 b -1] + leaf(=) [s scale r (randint(4)*90) x shift sat 0.5 hue 135] + leaf(=) [s scale r (randint(4)*90) x -shift y shift sat 0.5 hue 270] + leaf(=) [s scale r (randint(4)*90) y shift sat 0.5 hue 225] + leaf(=) [s scale r (randint(4)*90) x shift y shift sat 0.5 hue 180] +} + +path donut_bit(natural depth) { + spacing = spaceSize(depth) + MOVETO(0+spacing, 0.5) + LINETO(0.5, 0.5) + ARCTO(-0.5, -0.5, 1, CF::ArcCW) + LINETO(-0.5, 0-spacing) + ARCTO(0+spacing, 0.5, 0.5) + CLOSEPOLY() + FILL[] +} + +shape grid3(vector9 g){ + loop xz = 3 [ x (1/3) ] + loop yz = 3 [ y (1/3) ] + if (g[xz + yz*3]) SQUARE [s (1/3) x (-1/3) y (-1/3) ] +} + +shape grid5(vector25 g){ + loop xz = 5 [ x (1/5) ] + loop yz = 5 [ y (1/5) ] + if (g[xz + yz*5]) SQUARE [s (1/5) x (-2/5) y (-2/5) ] +} + +path dStripe(start, stop){ + MOVETO(-0.5,-0.5+start) + LINETO(-0.5, stop-0.5) + LINETO( stop-0.5,-0.5) + LINETO(-0.5+start,-0.5) + CLOSEPOLY() + FILL[] +} + +shape hazard2 { + n = 2 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape hazard3 { + n = 3 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape hazard4 { + n = 4 + loop i = n [ ] dStripe(0/(n*2) + i/n, 1/(n*2) + i/n) [ ] + loop i = n [ ] dStripe(1/(n*2) + i/n, 2/(n*2) + i/n) [ r 180 ] +} + +shape leaf(natural depth) + rule { + figure(depth + 1) [] + } + rule { + if (depth < maxDepth) split(depth + 2) [] + if (depth >= maxDepth) figure(depth + 2) [] + } + rule 0.5 { + if (depth < maxDepth-3) split3(depth + 3) [] + if (depth >= maxDepth) figure(depth + 3) [] + } + rule 0.5 { + if (depth < maxDepth-3) split3start(depth + 3) [] + if (depth >= maxDepth) figure(depth + 3) [] + } + +shape figure(natural depth) + rule { + SQUARE [] + } + rule { + SQUARE [] + SQUARE [s 0.5 b 1 sat -1] + } + rule { + CIRCLE [] + } + rule { + CIRCLE [] + CIRCLE [s 0.5 b 1 sat -1] + } + rule { + grid3((1,0,1, + 1,1,1, + 0,1,0)) [] + } + rule { + grid3((1,1,1, + 1,0,0, + 1,1,1)) [] + } + rule { + grid3((1,0,0, + 0,1,0, + 0,0,1)) [] + } + rule { + grid3((1,0,1, + 1,1,1, + 1,0,1)) [] + } + rule { + grid3((1,0,0, + 1,1,1, + 0,0,1)) [] + } + rule { + grid3((1,0,0, + 1,0,0, + 1,1,1)) [] + } + rule { + grid5((1,1,1,1,1, + 1,0,0,0,1, + 1,1,1,1,1, + 1,0,0,0,1, + 1,0,0,0,1)) [] + } + rule { + grid5((1,0,1,0,1, + 1,0,1,0,0, + 1,0,1,1,1, + 1,0,0,0,0, + 1,1,1,1,1)) [] + } + rule { + hazard2 [] + } + rule { + if(depth < maxDepth - 2) hazard3 [] + } + rule { + if(depth < maxDepth - 4) hazard4 [] + } + rule { + donut_bit(depth) [] + } + rule { + + } diff --git a/fletching/fletching-tyler.cfdg b/fletching/fletching-tyler.cfdg new file mode 100644 index 0000000..d08aac1 --- /dev/null +++ b/fletching/fletching-tyler.cfdg @@ -0,0 +1,30 @@ +startshape root + +CHEVRON_WIDTH = 2 +CHEVRON_HEIGHT = 1 +CHEVRON_SKEW = 40 + +GAP_WIDTH = 0.1 + +ASPECT_RATIO = 2 +NUM_COLUMNS = 50 +CANVAS_WIDTH = NUM_COLUMNS * CHEVRON_WIDTH +CANVAS_HEIGHT = CANVAS_WIDTH / ASPECT_RATIO +NUM_ROWS = (CANVAS_HEIGHT / CHEVRON_HEIGHT) + 1 + +CF::Size = [s CANVAS_WIDTH CANVAS_HEIGHT x -(CANVAS_WIDTH / 2) y -(CANVAS_HEIGHT / 2)] + +shape root { + doublewidth = 2 * CHEVRON_WIDTH + loop NUM_COLUMNS [x doublewidth] { + column[b 0.8 sat 0.6 s CHEVRON_WIDTH CHEVRON_HEIGHT] + column[b 0.8 sat 0.6 s CHEVRON_WIDTH CHEVRON_HEIGHT flip 90 x CHEVRON_WIDTH] + } +} + +shape column { + loop NUM_ROWS [y CHEVRON_HEIGHT] { + SQUARE [skew 0 CHEVRON_SKEW h rand(360)] + // SQUARE [b -1 sat 0 s GAP_WIDTH CHEVRON_HEIGHT] + } +} diff --git a/fletching/fletching.cfdg b/fletching/fletching.cfdg new file mode 100644 index 0000000..e47754f --- /dev/null +++ b/fletching/fletching.cfdg @@ -0,0 +1,78 @@ +// Fletching Project. Style copied from /u/red_blue_yellow's design without access to source +// https://www.reddit.com/r/generative/comments/8tmloo/untitled/ +// Written by manghoti + +CF::Background = [ hue 220 sat 0.2 b -0.8 ] +CF::Impure = 1 + +X=80 +Y=1600 + +PALETTE=( +// hue, sat , b + (222, 0.75, 0.3) , + (0 , 0 , 1) , + (169, 0.63, 0.38) , + (75 , 0.39, 0.67) , + (0 , 0 , 1) , + (89 , 0.14, 0.88) , + (222, 0.57, 0.6) , + (350, 0.13, 0.93) , + (0 , 0 , 1) , + (30 , 0.95, 0.99) , + (55 , 0.33, 0.80) , + (0 , 0 , 1) , + (13 , 0.39, 0.82) , + (18 , 0.93, 0.9) +) +PAL_NUM=14 + +startshape bars() + +shape bars { + loop u=X [ x 2.2 ] bar(u) [ ] +} + +shape bar(number u) { + stripe(u*2) [ ] + stripe(u*2+1) [ flip 90 x 1.1 ] +} + +OFFSET=0..2^13 //this moves the frac_noise noise around for different results each run +shape stripe(number u) { + loop v=Y [ y -0.1 ] { + SQUARE [ trans 0 -0.8 0 -0.91 1 0 + hue col(u,v) + a 1 min(1,max(0,frac_noise(u+OFFSET*4, v/200 +OFFSET*4, 0.5 , 6)*16-8 + (-1..1))) ] + } +} + +vector3 col(u, v) = PALETTE[floor(max(0,min(0.999, + frac_noise(u+OFFSET*6, v/900+OFFSET*6, 1 , 8)*0.5 + + frac_noise(u+OFFSET*7, v/15+OFFSET*7 , 100, 6)*1.7 + -.75 + (-0.02..0.02) + ))*PAL_NUM)*3,3] + +//============= fractal noise gen ============= +sanity_offset=40000 //frac_noise noise produces odd results at origin point +number frac_noise(xx, yy, scale, oct) = + frac_noise_loop(xx+sanity_offset,yy+sanity_offset,scale,oct)/2 +number frac_noise_loop(xx, yy, scale, oct) = if(oct < 1, 0, + noise(xx, yy, scale/(1.4^oct))/(1.4^oct) + frac_noise_loop(xx, yy, scale, oct-1) +) +number noise(xx, yy, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); + xf = xx/scale - xi; yf = yy/scale - yi; + lerp(lerp(randxy(xi, yi ), randxy(xi+1,yi ), xf), + lerp(randxy(xi, yi+1), randxy(xi+1,yi+1), xf), yf) +) + +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +// terrible random number generator +rand_p1=25889 +rand_p2=26903 +number randxy(xx, yy) = mod( + bitxor(xx*(xx+rand_p1)+rand_p2, + yy*(yy+rand_p2)+rand_p1), + 10000)/10000 diff --git a/fletching/my-frac-noise.cfdg b/fletching/my-frac-noise.cfdg new file mode 100644 index 0000000..da9cb28 --- /dev/null +++ b/fletching/my-frac-noise.cfdg @@ -0,0 +1,43 @@ +//Perlin noise project, by Alex Bruce +//Bastardized from https://www.contextfreeart.org/gallery/view.php?id=3786 + +width = 500 +CF::Size = [s width width x -(width/2) y -(width/2)] + +octaves=8 +test_scale=width/3 +test_offset=0..2^20 //test offset + +startshape texture [h 0 0.5 1] + +shape texture { + loop i=(width+1) [] loop j=(width+1) [] { + hsb = color(i, j) + SQUARE [x i j hue 1 hsb[0] sat 1 hsb[1] b 1 hsb[2]] + } +} + +vector3 color(xx, yy) = (0 , 0, perlin(xx+test_offset,yy+test_offset,test_scale,octaves)) +//vector3 color(xx, yy) = (0 , 0, randxy(xx,yy)) + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, scale, oct) = if(oct < 1, 0, + noise(xx, yy, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, scale, oct-1) +) + +number noise(xx, yy, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); + xf = xx/scale - xi; yf = yy/scale - yi; + lerp(lerp(randxy(xi, yi ), randxy(xi+1,yi ), xf), + lerp(randxy(xi, yi+1), randxy(xi+1,yi+1), xf), yf) +) +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +number randxy(xx, yy) = mod( + bitxor(xx*(xx+rand_p1)+rand_p2, + yy*(yy+rand_p2)+rand_p1), + 10000)/10000 diff --git a/flows/flows.cfdg b/flows/flows.cfdg new file mode 100644 index 0000000..c3d05ea --- /dev/null +++ b/flows/flows.cfdg @@ -0,0 +1,39 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 +T=1000 +Po=5000 +startshape flowfield [] + +shape flowfield { + loop 10000 [ ] flowline(0..120, 0..120, T) [] +} + +shape flowline(number xx, number yy, natural t) { + CIRCLE [ x xx y yy s 0.15 a -0.90 ] + if( t > 0 ) flowline( + xx + (perlin(xx , yy , 10, 4)-0.5)*0.1, + yy + (perlin(xx+Po, yy+Po, 10, 4)-0.5)*0.1 - 0.02 , + t - 1 ) [ ] +} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, scale, oct) = if(oct < 1, 0, + noise(xx, yy, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, scale, oct-1) +) + +number noise(xx, yy, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); + xf = xx/scale - xi; yf = yy/scale - yi; + lerp(lerp(randxy(xi, yi ), randxy(xi+1,yi ), xf), + lerp(randxy(xi, yi+1), randxy(xi+1,yi+1), xf), yf) +) +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +number randxy(xx, yy) = mod( + bitxor(xx*(xx+rand_p1)+rand_p2, + yy*(yy+rand_p2)+rand_p1), + 10000)/10000 diff --git a/flows/flows2.cfdg b/flows/flows2.cfdg new file mode 100644 index 0000000..5109112 --- /dev/null +++ b/flows/flows2.cfdg @@ -0,0 +1,41 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 +T=100 +Po=5000 + +startshape flowfield [] + +shape flowfield { + loop xx=100 [ ] loop yy=100 [ ] + flowline(xx, yy, T) [] +} + +shape flowline(number xx, number yy, natural t) { + CIRCLE [ x xx y yy s 0.3 a -0.94 ] + if( t > 0 ) flowline( + xx + (perlin(xx , yy , 10, 4)-0.5)*0.5, + yy + (perlin(xx+Po, yy+Po, 10, 4)-0.5)*0.5, + t - 1 ) [ ] +} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, scale, oct) = if(oct < 1, 0, + noise(xx, yy, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, scale, oct-1) +) + +number noise(xx, yy, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); + xf = xx/scale - xi; yf = yy/scale - yi; + lerp(lerp(randxy(xi, yi ), randxy(xi+1,yi ), xf), + lerp(randxy(xi, yi+1), randxy(xi+1,yi+1), xf), yf) +) +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +number randxy(xx, yy) = mod( + bitxor(xx*(xx+rand_p1)+rand_p2, + yy*(yy+rand_p2)+rand_p1), + 10000)/10000 diff --git a/flows/flows3.cfdg b/flows/flows3.cfdg new file mode 100644 index 0000000..757b1a1 --- /dev/null +++ b/flows/flows3.cfdg @@ -0,0 +1,44 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 + +Pl=1000 +Po=5000..30000 + +startshape flowfield [] + +shape flowfield { + loop 13000 [] flowline(-50..50, -50..50, Pl) [] +} + +shape flowline(number xx, number yy, number t) { + CIRCLE [ x xx y yy s 0.2 a -0.99 b -1 ] + if( t > 0 ) flowline( + xx - (xx/900) + (-0.03..0.03) + (perlin(xx+Po*1, yy+Po*1, t/50, 5, 4)-0.5)*(0.5..1.5), + yy - (yy/900) + (-0.03..0.03) + (perlin(xx+Po*2, yy+Po*2, t/50, 5, 4)-0.5)*(0.5..1.5), + t - 1 ) [ ] +} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, zz, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,zz+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, zz, scale, oct) = if(oct < 1, 0, + noise(xx, yy, zz, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, zz, scale, oct-1) +) + +number noise(xx, yy, zz, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); zi = floor(zz/scale); + xf = xx/scale - xi; yf = yy/scale - yi; zf = zz/scale - zi; + lerp(lerp(lerp(randxy(xi, yi , zi ), randxy(xi+1, yi , zi ), xf), + lerp(randxy(xi, yi+1, zi ), randxy(xi+1, yi+1, zi ), xf), yf), + lerp(lerp(randxy(xi, yi , zi+1), randxy(xi+1, yi , zi+1), xf), + lerp(randxy(xi, yi+1, zi+1), randxy(xi+1, yi+1, zi+1), xf), yf), zf)) + +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +rand_p3=22907 +number randxy(xx, yy, zz) = + mod(bitxor(bitxor(xx*(xx+rand_p1)+rand_p3, + yy*(yy+rand_p2)+rand_p1), + zz*(zz+rand_p3)+rand_p2),10000)/10000 diff --git a/flows/flows4.cfdg b/flows/flows4.cfdg new file mode 100644 index 0000000..5761f3f --- /dev/null +++ b/flows/flows4.cfdg @@ -0,0 +1,44 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 + +Pl=1000 +Po=5000..30000 + +startshape flowfield [] + +shape flowfield { + loop 33000 [] flowline(-50..50, -50..50, Pl) [] +} + +shape flowline(number xx, number yy, number t) { + CIRCLE [ x xx y yy s 0.2 a -0.98 b -1 ] + if( t > 0 ) flowline( + xx + (-0.01..0.01) + (perlin(xx+Po*1, yy+Po*1, t/50, 5, 4)-0.5)*0.3, + yy + (-0.01..0.01) + (perlin(xx+Po*2, yy+Po*2, t/50, 5, 4)-0.5)*0.3, + t - 1 ) [ ] +} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, zz, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,zz+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, zz, scale, oct) = if(oct < 1, 0, + noise(xx, yy, zz, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, zz, scale, oct-1) +) + +number noise(xx, yy, zz, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); zi = floor(zz/scale); + xf = xx/scale - xi; yf = yy/scale - yi; zf = zz/scale - zi; + lerp(lerp(lerp(randxy(xi, yi , zi ), randxy(xi+1, yi , zi ), xf), + lerp(randxy(xi, yi+1, zi ), randxy(xi+1, yi+1, zi ), xf), yf), + lerp(lerp(randxy(xi, yi , zi+1), randxy(xi+1, yi , zi+1), xf), + lerp(randxy(xi, yi+1, zi+1), randxy(xi+1, yi+1, zi+1), xf), yf), zf)) + +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +rand_p3=22907 +number randxy(xx, yy, zz) = + mod(bitxor(bitxor(xx*(xx+rand_p1)+rand_p3, + yy*(yy+rand_p2)+rand_p1), + zz*(zz+rand_p3)+rand_p2),10000)/10000 diff --git a/flows/flows5.cfdg b/flows/flows5.cfdg new file mode 100644 index 0000000..b900b84 --- /dev/null +++ b/flows/flows5.cfdg @@ -0,0 +1,86 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 +CF::Background = [hue 163 b -.9 saturation 0] + +Pl=200 +Pn=70000 +Pa=0.1 +Po=5000..30000 + +PALETTE=( +// hue, sat , b + (222, 0.75, 0.3) , + (0 , 0 , 1) , + (169, 0.63, 0.38) , + (75 , 0.39, 0.67) , + (0 , 0 , 1) , + (89 , 0.14, 0.88) , + (222, 0.57, 0.6) , + (350, 0.13, 0.93) , + (0 , 0 , 1) , + (30 , 0.95, 0.99) , + (55 , 0.33, 0.80) , + (0 , 0 , 1) , + (13 , 0.39, 0.82) , + (18 , 0.93, 0.9) +) +PAL_NUM=14 + +vector3 col(u, v) = PALETTE[floor(max(0,min(0.999, + perlin(u+Po, v+Po, 1, 20, 7)*0.9 + ))*PAL_NUM)*3,3] + +startshape flowfield [] + +shape flowfield { + +// SQUARE [ hue col(0.1, 0) x 1 ] +// SQUARE [ hue col(0.2, 0) x 2 ] +// SQUARE [ hue col(0.3, 0) x 3 ] +// SQUARE [ hue col(0.4, 0) x 4 ] +// SQUARE [ hue col(0.5, 0) x 5 ] +// SQUARE [ hue PALETTE[1*3,3] x 1 y 1] +// SQUARE [ hue PALETTE[2*3,3] x 2 y 1] +// SQUARE [ hue PALETTE[3*3,3] x 3 y 1] +// SQUARE [ hue PALETTE[4*3,3] x 4 y 1] +// SQUARE [ hue PALETTE[5*3,3] x 5 y 1] + loop Pn [] { + xx=-50..50 + yy=-50..50 + //SQUARE [ x xx yy hue col(xx,yy) ] + flowline(xx, yy, Pl) [hue col(xx,yy) blend CF::Normal] + } +} + +shape flowline(number xx, number yy, number t) { + CIRCLE [ x xx y yy a -(1-Pa) z -0.001 s 0.1 ] + if( t > 0 ) flowline( + xx + (-0.01..0.01) + (perlin(xx+Po*1, yy+Po*1, t/50, 5, 4)-0.5)*0.3, + yy + (-0.01..0.01) + (perlin(xx+Po*2, yy+Po*2, t/50, 5, 4)-0.5)*0.3 - 0.04, + t - 1 ) [ ] +} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, zz, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,zz+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, zz, scale, oct) = if(oct < 1, 0, + noise(xx, yy, zz, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, zz, scale, oct-1) +) + +number noise(xx, yy, zz, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); zi = floor(zz/scale); + xf = xx/scale - xi; yf = yy/scale - yi; zf = zz/scale - zi; + lerp(lerp(lerp(randxy(xi, yi , zi ), randxy(xi+1, yi , zi ), xf), + lerp(randxy(xi, yi+1, zi ), randxy(xi+1, yi+1, zi ), xf), yf), + lerp(lerp(randxy(xi, yi , zi+1), randxy(xi+1, yi , zi+1), xf), + lerp(randxy(xi, yi+1, zi+1), randxy(xi+1, yi+1, zi+1), xf), yf), zf)) + +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +rand_p3=22907 +number randxy(xx, yy, zz) = + mod(bitxor(bitxor(xx*(xx+rand_p1)+rand_p3, + yy*(yy+rand_p2)+rand_p1), + zz*(zz+rand_p3)+rand_p2),10000)/10000 diff --git a/flows/flows6.cfdg b/flows/flows6.cfdg new file mode 100644 index 0000000..7b7ab77 --- /dev/null +++ b/flows/flows6.cfdg @@ -0,0 +1,135 @@ +CF::MinimumSize = 0.5 +CF::Impure = 1 +CF::Background = [hue 163 b -.9 saturation 0] +CF::Size = [s 107 35 x 0 y 0] + +// paint strokes +Pl=(7..20)^2 //paint length +Pn=(60..265)^2 //paint number +Pa=0.05..0.3 //paint alpha +Ps=0.02..0.10 //paint size +Pg=0.01..-0.01 //paint gravity +Pc=1..20 //color scale + +noise_offset=5000..30000 + +// wind +Wx=(0.1..0.8)/(1..4) // wind x scale +Wy=(0.1..0.8)/(1..4) // wind y scale +Ws=0.5..10 // wind all scale +Wb=0..0.2 // wind brownian +Wz=(0.02..-0.02)/40 // wind zoom + +//PALETTE=( +//// hue, sat , b +// (222, 0.75, 0.3) , +// (0 , 0 , 1) , +// (169, 0.63, 0.38) , +// (75 , 0.39, 0.67) , +// (0 , 0 , 1) , +// (89 , 0.14, 0.88) , +// (222, 0.57, 0.6) , +// (350, 0.13, 0.93) , +// (0 , 0 , 1) , +// (30 , 0.95, 0.99) , +// (55 , 0.33, 0.80) , +// (0 , 0 , 1) , +// (13 , 0.39, 0.82) , +// (18 , 0.93, 0.9) +//) +//PAL_NUM=14 + +// old orange and pink highlited palette +//PALETTE=( +//// hue, sat , b +// (307, 0.8 , 0.75), +// (13 , 0.55, 0.83), +// (31 , 0.30, 0.91), +// (109, 0.17, 0.64), +// (0 , 0 , 0.29) +//) + +//// dark red highlight, grey blue palette +//PALETTE=( +//// hue, sat , b +// (21 , 0.42, 0.20), +// (37 , 0.51, 0.80), +// (354, 0.05, 0.84), +// (250, 0.26, 0.64), +// (342, 0.61, 0.17) +//) + +PALETTE=( +// hue, sat , b + (81 , 0.76, 0.66), + (64 , 0.36, 0.93), + (46 , 0.59, 0.75), + (18 , 0.77, 0.69), + (22 , 0.61, 0.29) +) +PAL_NUM=5 + +vector3 col(u, v) = PALETTE[ + floor(max(0,min(0.999, + (perlin(u+noise_offset, v+noise_offset, Pc, 20, 7)-0.33) + *2.5 + ))*PAL_NUM)*3, + 3 +] + +startshape flowfield [] + +shape flowfield { + loop Pn [] { + xx=-48..48 + yy=-12..12 + //SQUARE [ x xx yy hue col(xx,yy) ] + flowline(xx, yy, Pl) [hue col(xx,yy) blend CF::Normal] + } +} + +shape flowline(number xx, number yy, number t) { + CIRCLE [ x xx y yy a -(1-Pa) z -0.001 s Ps ] + if( t > 0 ) flowline( + xx + (-0.01..0.01) * Wb + xx * Wz + + (perlin(xx+noise_offset*1, yy+noise_offset*1, 1, Ws, 5)-0.5) * Wx, + yy + (-0.01..0.01) * Wb + yy * Wz + + (perlin(xx+noise_offset*2, yy+noise_offset*2, 1, Ws, 4)-0.5) * Wy - Pg, + t - 1 ) [ ] +} +//path flowline(number xx, number yy, number t) { +// LINETO(xx, yy) +// if ( t > 0 ) flowline( +// xx + (-0.01..0.01) * Wb +// + (perlin(xx+noise_offset*1, yy+noise_offset*1, 1, Ws, 5)-0.5) * Wx, +// yy + (-0.01..0.01) * Wb +// + (perlin(xx+noise_offset*2, yy+noise_offset*2, 1, Ws, 5)-0.5) * Wy - Pg, +// t - 1) +// if ( t > 0 ) flowline( 1, 1, 0) +// STROKE( Ps, CF::RoundJoin + CF::RoundCap ) [ a -(1-Pa) ] +//} + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, zz, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,zz+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, zz, scale, oct) = if(oct < 1, 0, + noise(xx, yy, zz, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, zz, scale, oct-1) +) + +number noise(xx, yy, zz, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); zi = floor(zz/scale); + xf = xx/scale - xi; yf = yy/scale - yi; zf = zz/scale - zi; + lerp(lerp(lerp(randxy(xi, yi , zi ), randxy(xi+1, yi , zi ), xf), + lerp(randxy(xi, yi+1, zi ), randxy(xi+1, yi+1, zi ), xf), yf), + lerp(lerp(randxy(xi, yi , zi+1), randxy(xi+1, yi , zi+1), xf), + lerp(randxy(xi, yi+1, zi+1), randxy(xi+1, yi+1, zi+1), xf), yf), zf)) + +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +rand_p3=22907 +number randxy(xx, yy, zz) = + mod(bitxor(bitxor(xx*(xx+rand_p1)+rand_p3, + yy*(yy+rand_p2)+rand_p1), + zz*(zz+rand_p3)+rand_p2),10000)/10000 diff --git a/flows/my-frac-noise.cfdg b/flows/my-frac-noise.cfdg new file mode 100644 index 0000000..bb7432b --- /dev/null +++ b/flows/my-frac-noise.cfdg @@ -0,0 +1,43 @@ +//Perlin noise project, by Alex Bruce +//Bastardized from https://www.contextfreeart.org/gallery/view.php?id=3786 + +width = 500 +CF::Size = [s width width x -(width/2) y -(width/2)] + +octaves=7 +test_scale=width/3 +test_offset=0..2^20 //test offset + +startshape texture [h 0 0.5 1] + +shape texture { + loop i=(width+1) [] loop j=(width+1) [] { + hsb = color(i, j) + SQUARE [x i j hue 1 hsb[0] sat 1 hsb[1] b 1 hsb[2]] + } +} + +vector3 color(xx, yy) = (0 , 0, perlin(xx+test_offset,yy+test_offset,test_scale,octaves)) +//vector3 color(xx, yy) = (0 , 0, randxy(xx,yy)) + +sanity_offset=30000 //perlin noise produces odd results at origin point +number perlin(xx, yy, scale, oct) = + perlin_loop(xx+sanity_offset,yy+sanity_offset,scale,oct)/2 +number perlin_loop(xx, yy, scale, oct) = if(oct < 1, 0, + noise(xx, yy, scale/(1.4^oct))/(1.4^oct) + perlin_loop(xx, yy, scale, oct-1) +) + +number noise(xx, yy, scale) = let( + xi = floor(xx/scale); yi = floor(yy/scale); + xf = xx/scale - xi; yf = yy/scale - yi; + lerp(lerp(randxy(xi, yi ), randxy(xi+1,yi ), xf), + lerp(randxy(xi, yi+1), randxy(xi+1,yi+1), xf), yf) +) +lerp(v1, v2, t) = (1-t)*v1 + t*v2 + +rand_p1=25889 +rand_p2=26903 +number randxy(xx, yy) = mod( + bitxor(xx*(xx+rand_p1)+rand_p2, + yy*(yy+rand_p2)+rand_p1), + 10000)/10000 diff --git a/hexs/hexs.cfdg b/hexs/hexs.cfdg new file mode 100644 index 0000000..f271747 --- /dev/null +++ b/hexs/hexs.cfdg @@ -0,0 +1,26 @@ +CF::Impure = 1 +CF::MinimumSize = 20 +CF::Background = [ b -0.7 ] +D=9 +startshape recurse_hex(D) + +shape recurse_hex(natural d) { + hex [ ] + //sub_hex(d) [ ] + loop 6 [[r 60]] sub_hex(d) [ x -1 ] +} +shape sub_hex(natural d) { + if ( 0..6 < 5) recurse_hex(d-1) [ + r 30 s (tan(30)) + hue (floor(0..1)*30) + sat (randint(2)/20) + b (randint(2)/15) + z 0.1..0.1001 ] +} + +path hex { + MOVETO(-1,0) + loop 6 [r 60] LINETO(-1,0) + CLOSEPOLY() + FILL [ b 0.1 sat 0.1 ] +} diff --git a/isohills/isohills.cfdg b/isohills/isohills.cfdg new file mode 100644 index 0000000..39dffbb --- /dev/null +++ b/isohills/isohills.cfdg @@ -0,0 +1,79 @@ +// Chris Coyne, copyright 2006 +// Creative Commons licensed: Creative Commons Attribution 3.0 Unported +CF::Background = [b 1 0.5] +CF::MinimumSize = 0.1 +CF::Impure = 1 +CF::Size = [s 1.7 1.7] + +strokeWidth=0.0025 + +startshape isoGrid() + +shape isoGrid { + loop yi = 50 [ y (0.5/(-50/2)) z 500] + loop xi = 50 [ x (1 /( 50/2))] + if (rand(0,1) <= 0.1) iso() [x -1 0.5 z randint(0,499)] +} + +shape iso { + isoTop() [] + isoFill() [z -0.01 h 1 (60*randint(0,6)) sat 1 0.75 b 1 0.6 ] + SQUARE [trans 0 0 -1 -0.5 0 -1 b 1 z -0.2 y -0.5] +} + +shape isoFill +rule 0.5 { + isoFillDown(select(rand(4),200,100,50,25)) [] + isoFillDown(select(rand(3),100,50,25)) [f 90] +} +rule 0.25 { + isoFillDown(select(rand(4),200,100,50,25)) [] +} +rule 0.25 { + isoFillDown(select(rand(3),100,50,25)) [f 90] +} +rule { + isoFillLeft(select(rand(3),100,50,25)) [] +} +rule { + isoFillLeft(select(rand(3),100,50,25)) [f 90] +} +rule { + isoFillWide(select(rand(4),100,50,25,12.5)) [] +} +rule {} + +shape isoFillDown(n) { + loop n [x (1/n) (-0.5/n)] isoDown() [] +} + +path isoDown { + LINETO(0,-1) + STROKE(strokeWidth)[] +} + +shape isoFillLeft(n) { + loop n-1 [x (-1/n) (-0.5/n)] isoLeft() [x (-1/n) (-0.5/n)] +} + +path isoLeft { + LINETO(1,-0.5) + STROKE(strokeWidth)[] +} + +shape isoFillWide(n) { + loop w=n-1 [] isoWide(w/(n)) [] +} + +path isoWide(w) { + MOVETO(-w,-w/2) + LINETO(w,-w/2) + STROKE(strokeWidth)[] +} + +path isoTop { + MOVETO(-1,-0.5) + LINETO(0,0) + LINETO(1,-0.5) + STROKE(strokeWidth)[] +} diff --git a/isohills/squarefrag.cfdg b/isohills/squarefrag.cfdg new file mode 100644 index 0000000..cb49dbf --- /dev/null +++ b/isohills/squarefrag.cfdg @@ -0,0 +1,76 @@ +// Chris Coyne, copyright 2006 +// Creative Commons licensed: Creative Commons Attribution 3.0 Unported +CF::Background = [b 1 0.5] +CF::MinimumSize = 0.1 +CF::Impure = 1 +CF::Size = [s 10 10 x -12 y -12] + +strokeWidth=0.01 + +startshape boxGrid() [] + +shape boxGrid { + n=200 + loop n [ y sqrt(0.02) z -1000 b 0.05 ] + loop n [ x sqrt(0.02) ] + if(randint(0,5)==0) box() [r (45 + randint(0,4)*90) z -randint(0,999)] +} + +shape box { + hueColor=(randint(6)*60) + SQUARE [b 1 1 z -0.2] + fill() [b 1 0.6 sat 1 0.7 h 1 hueColor z -0.1] + outline() [h 1 hueColor sat 1 0.7 b 1 0.6] +} + +shape fill + rule { + squareFill()[] + } + rule { + downFill()[] + } + rule { + diagFill()[] + } + rule 0.2 { + + } + +shape squareFill { + n=select(randint(3),10,20,40) + loop xi = n [ x (1/n) ] + loop yi = n [ y (1/n) ] + if(mod((xi+yi),2)) SQUARE [s (1/n) x (-(n/2-0.5)/n) (-(n/2-0.5)/n) ] +} + +path downFill { + n=select(randint(3),10,20,40) + loop n-1 [x (1/n)]{ + MOVETO((-(n/2-1)/n),0.5 ) + LINETO((-(n/2-1)/n),-0.5) + } + STROKE(strokeWidth, CF::SquareCap) [] +} + +shape diagFill { + n=select(randint(3),10,20,40) + loop i=n [] diagFillLine(i/n)[] + loop i=n [] diagFillLine(i/n)[f -45] +} + +path diagFillLine(w) { + MOVETO(-0.5 + w, 0.5 ) + LINETO( 0.5 ,-0.5 + w) + STROKE(strokeWidth) [] +} + +path outline { + MOVETO( 0.5, 0.5) + LINETO( 0.5,-0.5) + LINETO(-0.5,-0.5) + LINETO(-0.5, 0.5) + LINETO( 0.5, 0.5) + STROKE(strokeWidth, CF::SquareCap)[] +} + diff --git a/perlin.cfdg b/perlin.cfdg new file mode 100644 index 0000000..e2a37b6 --- /dev/null +++ b/perlin.cfdg @@ -0,0 +1,83 @@ +//perlin noise project by whatcode +//https://www.contextfreeart.org/gallery/view.php?id=3786 + +width = 200 +CF::Size = [s width width x -(width/2) y -(width/2)] + +startshape texture [b 0..1 h 0..360 sat -.5..1] + +base = 2^13 - 1 +rnd() = floor(1..base) +seed = (rnd(),rnd(),rnd(),rnd(),rnd(),rnd()) + +θ = 0..360 +stretch = if (0..5 > 1, 1, .2..5) +speed = 1..10 +octs = floor(3..12) +freq = 1..3 +pers = if (1..3 > 1, .5..1, 1..1.5) +mix = floor(0..9) +c0 = (0..360, 0..1, (0..4>1) && 0..1) +c1 = (0..360, 0..1, (0..4>1) && 0..1) +c2 = (0..360, 0..1, (0..4>1) && 0..1) +c3 = (0..360, 0..1, (0..4>1) && 0..1) +wt = (0..360, (0..2>1) && -.1..1, (0..2>1) && -.1..1) + + +shape texture { + loop i=(width+1) [] loop j=(width+1) [] { + hsb = color(i, j) + SQUARE [x i j h hsb] + } +} + +vector3 color(xx, yy) = let( + v0 = mod((perlin(xx, yy)*speed+6),4); + if (mix<7, cmix(v0), if (mix<8, cval(v0), + (wt[0]*v0, wt[1]*v0, wt[2]*v0)))) + +vector3 cmix(v) = + if (v<1, c0*(1-v,1-v,1-v) + c1*(v,v,v), + if (v<2, c1*(2-v,2-v,2-v) + c2*(v-1,v-1,v-1), + if (v<3, c2*(3-v,3-v,3-v) + c3*(v-2,v-2,v-2), + c3*(4-v,4-v,4-v) + c0*(v-3,v-3,v-3)))) + +vector3 cval(v) = if(v<1,c0,if(v<2,c1,if(v<3,c2,c3))) + +perlin(xx, yy) = let( + res = perloop(xx, yy, 0, octs); + if (pers == 1, res / octs, + res * (1 - pers) / (1 - pers^octs))) + +perloop(xx, yy, res0, li) = + if(li<=0, res0, let( + fli = freq^li; // freq*li + s0 = bitand(seed[5]+fli, base); + siz = 1/200*fli; + res = res0 + (pers^li)*noise(xx*siz+s0,yy*siz+s0,s0); + perloop(xx, yy, res, li-1))) + +noise(x0, y0, s0) = let( + xi = floor(x0); yi = floor(y0); + xf = x0 - xi; yf = y0 - yi; + c0 = dot2(rdir(xi, yi, s0), (xf, yf )); + c1 = dot2(rdir(xi, yi+1, s0), (xf, yf-1)); + c2 = dot2(rdir(xi+1, yi, s0), (xf-1,yf )); + c3 = dot2(rdir(xi+1, yi+1, s0), (xf-1,yf-1)); + fx = fade(xf); + lerp(lerp(c0, c2, fx), lerp(c1, c3, fx), fade(yf))) + +vector2 rdir(i, j, s0) = let( + r0 = bitand(s0*seed[0]+seed[1]*i*i+seed[2]*j, base); + r1 = bitand(r0*r0*seed[3]*j + seed[4], base); + θ = 360 * r1 / base; + (sin(θ), cos(θ))) + +vector2 unit(vector2 v) = let( + m = sqrt(v[0]*v[0] + v[1]*v[1]); + v/(m,m)) + +dot2(vector2 v, vector2 u) = v[0]*u[0] + v[1]*u[1] +lerp(v1, v2, t) = (1-t)*v1 + t*v2 +fade(t) = t*t*t*(t*(t*6-15)+10) + diff --git a/reference/ancient.cfdg b/reference/ancient.cfdg new file mode 100644 index 0000000..2ae30b4 --- /dev/null +++ b/reference/ancient.cfdg @@ -0,0 +1,94 @@ +/*Ancient Scripts by Leaf Garland*/ + +background { hue 40 sat 0.2 b -0.2} + +startshape LINES + +rule LINES { + 20 * {y -90} NEWLINE {hue 90 sat 0.7 b 0.2 a -0.5} +} + +rule NEWLINE { + LINE {y 0} +} + +rule NEWLINE { + LINE {y 20} +} + +rule NEWLINE { + LINE {y 30} +} + +rule LINE { + 50 * {x 36} CHAR {y rand(0,7)} +} + +rule CHAR 0.3 { + // space +} + +rule CHAR { + 2 * {x 20 flip 180} STROKE {r 90} + 2 * {y 20 flip 180} STROKE {} +} + +rule CHAR { + 4 * {r 60} STROKE {} +} + +rule CHAR { + STROKE {r 90} + 3 * {y 10 flip 180} STROKE {} +} + +rule STROKE { + B {} +} + +rule STROKE { + B {flip 90} +} + +rule B 30 { + MARK {} + B {x .6 r 10} +} + +rule B 30 { + MARK {} + B {x .6 r 3} +} + +rule B 250 { + MARK {} + B {x .9} +} + +rule B 10 { + MARK {} + B {flip 90} +} + +rule B 10 { } + + +rule MARK 3 { + CIRCLE {} +} + +rule MARK { + CIRCLE {s 2} +} + +rule MARK { + SQUARE {s 3} +} + +rule MARK { + CIRCLE {s 4} +} + +rule MARK 0.01 { + CIRCLE {s 7} +} diff --git a/reference/gradient.bmp b/reference/gradient.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c77224c278afeddde98dc730a354a0589628e0af GIT binary patch literal 8044 zcmeI1{Z~`>9mlWQt<<&XcGexV81zJHIpZJniDyFZ&l}ez@Oz z@Aq@R-}Ali^L==IKA+#8DnI_l_TAe70C=P1gJT~8z_#x;uaqC6H7EZ3z>ePDY<>T9 zYX$v6Yg-+I1{|fgw9;6udy5$~+Pw6;N&v|CNy)KaeZ(5^JeumRSvU`^&{wB!|83YF zO*?XJ-`Br6ukKFApR!N?ab@@^aeZs+7A0m|`I}kS>C?vSl%21?H8ZkL?52BHZw;q2 zQjedyR2(fL>?ryu@cqY4f3N+x_TG;kJWM>v3!(!7C=Z^0xnuJor4=pyviJTL0JwFv z=v4r?x^?Rwv}*ec!#hbsQj(W?GGtRW03iBq97#mT;oGXna31&d$2}fX!bR4rq6buw zZ#2N;!{{u>IbhBqUBF_ zqI&~ys_0hIkd!1j8IsE&xikE~?TP2Y-@FPumiypD2!7iZj;ECb5o;`FDhU#IQ76mZ z%CoU&(iTEQtgY`5gphma5vXzZLa4WKKb9>c4mx|APdZ&7FIZouldTSleRXi-uY=8r zd~%7i(at-Ws@KX^bsvZdq@!$s@NOgFW;ph6oa7zs{VIgqjc`qMm<9i&7uU0BiGfQo zFaegg$nC7O1sTFL`n3V2gEb&+t}ZSXHQL*)OhTDL!ggj2&h%TG4Zb6Ytfk6{xW^^z zZhgNSt;ugNL6?`9r$sdqcDW|Y8jKS5ID7TYdUf4w%<ag7iC~0L_|3QXg z6g*;7ELpPs{RLe$EhehaDzM=iJi0)fa78%^5{y-H_H> z%jigS6Yd;(dB@^>PIYj^iKpjb1Q`XH_18vOLGC`1-Q>#r?dJq zVFJOg{6pA$qwu%2L>e%~=tp zgJXTR!P4$PN|k($wz+n!g^lUyh(3MZ@5N*=m2e-|zH-N|5i^xsj@G;?0L$<>Ox}^3 z{+Nxrd=?cpyGj&RQ~3nSv$b}EHMU{pv4E%l+C+^9{0JpsJNnrH-N16gy6GBeCc^h( zW8t_)uDZhCl_5F&jQLn~Ft*+rUsnXkLm}MyzrC1lTc1Dnbu`q(c^E}}K0VBxOdK~E zI__3xbU6?vk0GP5JspYn$js$*ayZ<#hs48>9-WI4R(D8{zNWOB6s+#K0&&?aYu<$r z;!b=Xwh7(5wQ-WaFv@lFaKS%VT(*#16XN-XIJ_=00YNP5i)>p=iv$zukXh{QqY%zV z9}UL$namCGw<*PZ@@wete2$V6=S$}b7NabV%eE-bl2(#_O4371`ld;DJsGHYDMB>p zktXv}Hd3bP)9|~~mZtwg)y=p;WuPQrmBH#hM21Y^xUYar_+o6X0+U+0d^Rr}UnwAu znDE9@LE|iXgnB7NXNOo!NEg(fG`fi}kz@}cOpNg8JXhab>t9kIF z{-@V7@(>QQT{~gT#OiLV3%sMk%~z`%uRrLxlMRleja*=tT3T;J+vpE#G?P;h^NiqP z1d7ObERUL@uJjuQk7@-Y~ zl`)MdC#3d(ZNEhFb9PbfvL*kIWr!}|haH2A*v3bJrDc-?R)ek!NV?$hnjWGvK zIgU6lmdtYvY7YA1JeY@4nCxQ448}>#wGK7H%mHDI#p>T3sumUCPL{T~iQ@2ece|c& z0tG5=HFKy((PEjS&T6&ebi7f6fK(%tV^t#mAdrLkISOyJ)QdNo+!#@&yxEY(7TmSV zreHVJScX#OWeRfuS(G2DD8`8{Muya_TJA&xrXsi>#iRUGg+oA_Tacp6NlRzI-YWEa zxX)8HGjbW0cH%=^eHz=zA;>Ot_BM82j0k9Fq%BRNf*YNlh^eWw7rE;h6ydGP3q}^H z0