Saturday, July 8, 2017

Mystic Scribbles

Generate a page of random nonsense scribbles in the style of mystic manuscript.

for (rows=[0:20])
{My_poly_line=make_points(120- round(rnd(20)));
translate([rnd(20),rows*27])polyline(My_poly_line);
}
module sline(p1, p2 ,width=0.6,s=12) {
if(abs(p1.x-p2.x)>abs(p1.y-p2.y)){
for(i=[-1/s:1/s:1+1/s]) 
line(xlerp(p1,p2,i),xlerp(p1,p2,i+1/s),width);}
else{for(i=[0:1/s:1-1/s]) 
line(ylerp(p1,p2,i),ylerp(p1,p2,i+1/s),width);}}

module line(p1, p2 ,width=0.3) {
 hull() {        
translate(p1) rotate(45)scale([3,0.1]) circle(width);
translate(p2) rotate(45)scale([3,0.1]) circle(width);    }}


module polyline(p) {for(i=[0:max(0,len(p)-2)])
    if(round(rnd(0.53))==0)sline(p[i],p[i+1]);}
function smooth_curve(a) =
let (b = clamp(a))(b * b * (3 - 2 * b));

function clamp(a, b = 0, c = 1) = min(max(a, b), c);
function lerp(start, end, bias) = (end * bias + start * (1 - bias));
function xlerp(start, end, i) =
     [lerp(start.x,end.x,smooth_curve(i)),lerp(start.y,end.y,i)];
function ylerp(start, end, i) =
     [lerp(start.x,end.x,i),lerp(start.y,end.y,smooth_curve(i))];
 
function make_points(j=10,l1=[-30,-10],l2=[30,10])= 
     ([for(i=[1:j])[
rnd(l1.x,l2.x)/4+i*4,
rnd(l1.y,l2.y)]]);
function rnd(a = 1, b = 0, s = []) = 
  s == [] ? 
   (rands(min(a, b), max(   a, b), 1)[0]) 
  : 
   (rands(min(a, b), max(a, b), 1, s)[0])
  ; 


 

2 comments:

  1. :D HAHA. Mine to. Each text row is actually generated as one multi line made up of random points within a window that slides along the row. And then when plotted out random parts are left blank. Many different styles can be achieved.

    ReplyDelete