<jupyter_start><jupyter_text>spiral start buffer shaded<jupyter_code>image_path= '/home/naka/art/wigglesphere.jpg'
filename = 'vp_test29.svg'
paper_size:str = '11x14 inches'
border:float=20  # mm
image_rescale_factor:float=0.04
smooth_disk_size:int=1
hist_clip_limit=0.1
hist_nbins=32
intensity_min=0.
intensity_max=1.
hatch_spacing_min=0.35  # mm
hatch_spacing_max=1.1 # mm
pixel_width=1 # mm
pixel_height=1 # mm
angle_jitter='ss.norm(loc=10, scale=0).rvs'  # degrees
pixel_rotation='0'  # degrees
merge_tolerances=[0.3, 0.4,]  # mm
simplify_tolerances=[0.2,]  # mm
savedir='/home/naka/art/plotter_svgs'
# make page
paper = Paper(paper_size)
drawbox = paper.get_drawbox(border)

pt0 = Point(139.7, 70)
c = pt0.buffer(70, resolution=20)
buffer_gen = ss.uniform(loc=1, scale=1.1).rvs
d_buffer_gen = functools.partial(np.random.uniform, low=-1.3, high=-1.29)
d_translate_factor_gen = ss.uniform(loc=0.7, scale=0.1).rvs
fills = []
all_polys = Polygon()
p = c.buffer(0.1, cap_style=2, join_style=3)
p = p.buffer(buffer_gen(), cap_style=2, join_style=2)
angles_gen = gp.make_callable(np.radians(-90))
stp = gp.ScaleTransPrms(d_buffer=d_buffer_gen(),angles=angles_gen(),d_translate_factor=d_translate_factor_gen(), n_iters=300)
stp.d_buffers += np.random.uniform(-0.05, 0.05, size=stp.d_buffers.shape)
P = gp.Poly(p)
P.fill_scale_trans(**stp.prms)
visible_area = p.difference(all_polys)
visible_fill = P.fill.intersection(visible_area.buffer(1e-6))
visible_fill = gp.merge_LineStrings([g for g in reversed(visible_fill.geoms)])
fills.append(visible_fill)
all_polys = so.unary_union([all_polys, p])
pt1 = Point(139.7, 211)
c = pt1.buffer(70, cap_style=1, join_style=1, resolution=2)
buffer_gen = ss.uniform(loc=1, scale=1.1).rvs
d_buffer_gen = functools.partial(np.random.uniform, low=-1.3, high=-1.29)
d_translate_factor_gen = ss.uniform(loc=0.7, scale=0.1).rvs
visible_fill

p = c
angles_gen = gp.make_callable(np.radians(90))
stp = gp.ScaleTransPrms(d_buffer=d_buffer_gen(),angles=angles_gen(),d_translate_factor=d_translate_factor_gen(), n_iters=300)
stp.d_buffers += np.random.uniform(-0.05, 0.05, size=stp.d_buffers.shape)
P = gp.Poly(p)
P.fill_scale_trans(**stp.prms)
visible_area = p.difference(all_polys)
visible_fill = P.fill.intersection(visible_area.buffer(1e-6))
visible_fill = gp.merge_LineStrings([g for g in reversed(visible_fill.geoms)])
fills.append(visible_fill)
all_polys = so.unary_union([all_polys, p])
blss = gp.merge_LineStrings([f for f in fills if f.length > 0.1])
blss = gp.make_like(blss, drawbox)
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
# for ii, ls in enumerate(lss):
#     sk.stroke(ii + 1)
#     sk.geometry(ls)
sk.stroke(1)
sk.geometry(blss)
    
sk.display()

ad = axidraw.AxiDraw()          # Initialize class
ad.interactive()
ad.options.units = 2
ad.connect()                    # Open serial port to AxiDraw 
ad.options.speed_pendown = 60 
ad.options.accel=50
ad.update()
blss.bounds
def draw_geom(axidraw_handle, geom):
    pts = geom.coords
    y,x = pts[0]
    ad.moveto(x, y)
    for pt in pts[1:]:
        y,x = pt
        ad.lineto(x, y)
    ad.penup()
wait_time = 2
for geom in tqdm(blss):
    draw_geom(ad, geom)
    ad.moveto(0,0)
    time.sleep(wait_time)
11 * 25.4
pt = [0]
pt
                              # Absolute moves follow:
ad.moveto(356, 279)                  # Pen-up move to (1 inch, 1 inch)
# ad.lineto(2,1)                  # Pen-down move, to (2 inch, 1 inch)
ad.moveto(0,0)  
                # Pen-up move, back to origin.
ad.disconnect()                 # Close serial port to AxiDraw<jupyter_output><empty_output><jupyter_text>more complex<jupyter_code>image_path= '/home/naka/art/wigglesphere.jpg'
filename = 'vp_test18.svg'
paper_size:str = '11x14 inches'
border:float=20  # mm
image_rescale_factor:float=0.04
smooth_disk_size:int=1
hist_clip_limit=0.1
hist_nbins=32
intensity_min=0.
intensity_max=1.
hatch_spacing_min=0.35  # mm
hatch_spacing_max=1.1 # mm
pixel_width=1 # mm
pixel_height=1 # mm
angle_jitter='ss.norm(loc=10, scale=0).rvs'  # degrees
pixel_rotation='0'  # degrees
merge_tolerances=[0.3, 0.4,]  # mm
simplify_tolerances=[0.2,]  # mm
savedir='/home/naka/art/plotter_svgs'
# make page
paper = Paper(paper_size)
drawbox = paper.get_drawbox(border)

xgen = ss.uniform(loc=0.5, scale=0.05).rvs
split_func = functools.partial(gp.split_along_longest_side_of_min_rectangle, xgen=xgen)
splits = gp.recursive_split_frac_buffer(
    drawbox, 
    split_func=split_func,
    p_continue=1, 
    depth=0, 
    depth_limit=7,
    buffer_frac=-0.0
)

bps = MultiPolygon([p for p in splits])

   
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.penWidth('0.5mm')
sk.geometry(bps.boundary)

# tolerance=0.5

sk.display()
all_bps = gp.Shape(bps)
# make pixel polys
prms = []
for bp in tqdm(bps):

#     a = np.random.uniform(0, 240)
    dist_from_center = bp.centroid.distance(bps.centroid)
    a = np.interp(dist_from_center, [0, 150], [0, 1020])
    prm = {
        'geometry':bp,
        'raw_pixel_width':pixel_width,
        'raw_pixel_height':pixel_height,
        'angle':a,
        'group': 'raw_hatch_pixel',
        'magnitude': np.random.uniform(0.3, 2),

    }
    prms.append(prm)
raw_hatch_pixels = geopandas.GeoDataFrame(prms)
#  rescale polys to fit in drawbox
bbox = box(*raw_hatch_pixels.total_bounds)
_, transform = gp.make_like(bbox, drawbox, return_transform=True)
A = gp.AffineMatrix(**transform)
scaled_hatch_pixels = raw_hatch_pixels.copy()
scaled_hatch_pixels['geometry'] = scaled_hatch_pixels.affine_transform(A.A_flat)
scaled_hatch_pixels['scaled_pixel_height'] = scaled_hatch_pixels['geometry'].apply(gp.get_height)
scaled_hatch_pixels['scaled_pixel_width'] = scaled_hatch_pixels['geometry'].apply(gp.get_width)
new_drawbox = so.unary_union(scaled_hatch_pixels.geometry)
db = gp.Poly(new_drawbox)
# scaled_hatch_pixels['angle'] = np.interp(scaled_hatch_pixels.geometry.centroid.y, [db.bottom, db.top], [0, 680]) + np.random.randn(len(scaled_hatch_pixels)) * 5
scaled_hatch_pixels['angle'] = scaled_hatch_pixels['angle'] // 5 * 5
# scaled_hatch_pixels['angle'] = np.interp(scaled_hatch_pixels['angle'], xp=[0, 180], fp=[30, 150])
qpg = NoisyQuantizedPiecewiseGrid(scaled_hatch_pixels, xstep=5, ystep=5, noise_scale=0.1, noise_mult=0.5, verbose=False)
qpg.make_grid()
spiral_angle_max = np.pi * 200
spiral_angle_min = 0
spiral_angle_spacing = np.pi * 0.053
sp_angle_range = np.arange(spiral_angle_min, spiral_angle_max, spiral_angle_spacing)
spiral_distances = np.linspace(0, 100, len(sp_angle_range))

start_points = [Point(np.cos(a) * d, np.sin(a) * d) for a, d in zip(sp_angle_range, spiral_distances)]
start_points = gp.make_like(MultiPoint(start_points), db.p)
poly = new_drawbox
pts = []
lss = []
n_steps = 8
for pt in tqdm(start_points):
    
    vp = VectorParticle(pos=pt, grid=qpg, stepsize=1, momentum_factor=np.random.uniform(0,0))
    for ii in range(n_steps):
        vp.step()
    if len(vp.pts) > 1:
        ls = gp.merge_LineStrings([LineString(vp.pts)])
    lss.append(ls)
buffer_gen = ss.uniform(loc=0.5, scale=0.5).rvs
d_buffer_gen = functools.partial(np.random.uniform, low=-0.35, high=-0.30)
d_translate_factor_gen = ss.uniform(loc=0.6, scale=0.8).rvs
fills = []
all_polys = Polygon()
for ii, l in enumerate(tqdm(lss[:])):
    p = l.buffer(0.5, cap_style=2, join_style=2)
    p = p.buffer(buffer_gen(), cap_style=2, join_style=2)
    angles_gen = gp.make_callable(sp_angle_range[ii])
#     angles_gen = gp.make_callable(-90)
    stp = gp.ScaleTransPrms(d_buffer=d_buffer_gen(),angles=angles_gen(),d_translate_factor=d_translate_factor_gen(), n_iters=300)
    stp.d_buffers += np.random.uniform(-0.05, 0.05, size=stp.d_buffers.shape)
    P = gp.Poly(p)
    P.fill_scale_trans(**stp.prms)
    visible_area = p.difference(all_polys)
    visible_fill = P.fill.intersection(visible_area.buffer(1e-6))
    
    fills.append(visible_fill)
    all_polys = so.unary_union([all_polys, p])
blss = gp.merge_LineStrings([f for f in fills if f.length > 0.1])
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.stroke(1)
sk.geometry(blss)
    
sk.display()
25342 * 4 / 60 / 60
len(blss)
ii = 21
ii % 20
wait_time = 2
blss
def draw_geom_offset(axidraw_handle, geom, xoff=0, yoff=0):
    pts = geom.coords
    y,x = pts[0]
    ad.moveto(x+xoff, y+yoff)
    for pt in pts[1:]:
        y,x = pt
        ad.lineto(x+xoff, y+yoff)
    ad.penup()

ad = axidraw.AxiDraw()          # Initialize class
ad.interactive()
ad.options.units = 2
ad.connect()                    # Open serial port to AxiDraw 
ad.options.speed_pendown = 60 
ad.options.accel=50
ad.update()
ad.moveto(0, 0)
geom.length > 0
yoff = 0
xoff = 0
counter = 0
for ii, geom in enumerate(tqdm(fills)):
    try:
        for line in geom:
            if line.length > 0:
                draw_geom_offset(ad, line, xoff=xoff, yoff=yoff)
                counter += 1
                if counter % 20 == 0:
                    ad.moveto(xoff, yoff)
                    time.sleep(wait_time)
    except:
        pass
yoff = 0
xoff = 0
counter = 0
for ii, geom in enumerate(tqdm(fills)):
    for line in geom:
        if line.length > 0:
            draw_geom_offset(ad, line, xoff=xoff, yoff=yoff)
            counter += 1
            if counter % 20 == 0:
                ad.moveto(xoff, yoff)
                time.sleep(wait_time)
len(fills)<jupyter_output><empty_output><jupyter_text>more complex<jupyter_code>image_path= '/home/naka/art/wigglesphere.jpg'
filename = 'vp_test18.svg'
paper_size:str = '11x14 inches'
border:float=20  # mm
image_rescale_factor:float=0.04
smooth_disk_size:int=1
hist_clip_limit=0.1
hist_nbins=32
intensity_min=0.
intensity_max=1.
hatch_spacing_min=0.35  # mm
hatch_spacing_max=1.1 # mm
pixel_width=1 # mm
pixel_height=1 # mm
angle_jitter='ss.norm(loc=10, scale=0).rvs'  # degrees
pixel_rotation='0'  # degrees
merge_tolerances=[0.3, 0.4,]  # mm
simplify_tolerances=[0.2,]  # mm
savedir='/home/naka/art/plotter_svgs'
# make page
paper = Paper(paper_size)
drawbox = paper.get_drawbox(border)

xgen = ss.uniform(loc=0.5, scale=0.25).rvs
split_func = functools.partial(gp.split_along_longest_side_of_min_rectangle, xgen=xgen)
splits = gp.recursive_split_frac_buffer(
    drawbox, 
    split_func=split_func,
    p_continue=1, 
    depth=0, 
    depth_limit=7,
    buffer_frac=-0.0
)

bps = MultiPolygon([p for p in splits])

   
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.penWidth('0.5mm')
sk.geometry(bps.boundary)

# tolerance=0.5

sk.display()
all_bps = gp.Shape(bps)
# make pixel polys
prms = []
for bp in tqdm(bps):

#     a = np.random.uniform(0, 240)
    dist_from_center = bp.centroid.distance(bps.centroid)
    a = np.interp(dist_from_center, [0, 150], [0, 1020])
    prm = {
        'geometry':bp,
        'raw_pixel_width':pixel_width,
        'raw_pixel_height':pixel_height,
        'angle':a,
        'group': 'raw_hatch_pixel',
        'magnitude': np.random.uniform(0.3, 2),

    }
    prms.append(prm)
raw_hatch_pixels = geopandas.GeoDataFrame(prms)
#  rescale polys to fit in drawbox
bbox = box(*raw_hatch_pixels.total_bounds)
_, transform = gp.make_like(bbox, drawbox, return_transform=True)
A = gp.AffineMatrix(**transform)
scaled_hatch_pixels = raw_hatch_pixels.copy()
scaled_hatch_pixels['geometry'] = scaled_hatch_pixels.affine_transform(A.A_flat)
scaled_hatch_pixels['scaled_pixel_height'] = scaled_hatch_pixels['geometry'].apply(gp.get_height)
scaled_hatch_pixels['scaled_pixel_width'] = scaled_hatch_pixels['geometry'].apply(gp.get_width)
new_drawbox = so.unary_union(scaled_hatch_pixels.geometry)
db = gp.Poly(new_drawbox)
# scaled_hatch_pixels['angle'] = np.interp(scaled_hatch_pixels.geometry.centroid.y, [db.bottom, db.top], [0, 680]) + np.random.randn(len(scaled_hatch_pixels)) * 5
scaled_hatch_pixels['angle'] = scaled_hatch_pixels['angle'] // 5 * 5
# scaled_hatch_pixels['angle'] = np.interp(scaled_hatch_pixels['angle'], xp=[0, 180], fp=[30, 150])
qpg = NoisyQuantizedPiecewiseGrid(scaled_hatch_pixels, xstep=5, ystep=5, noise_scale=0.1, noise_mult=0.5, verbose=False)
qpg.make_grid()
spiral_angle_max = np.pi * 200
spiral_angle_min = 0
spiral_angle_spacing = np.pi * 0.1
sp_angle_range = np.arange(spiral_angle_min, spiral_angle_max, spiral_angle_spacing)
spiral_distances = np.linspace(0, 100, len(sp_angle_range))

start_points = [Point(np.cos(a) * d, np.sin(a) * d) for a, d in zip(sp_angle_range, spiral_distances)]
start_points = gp.make_like(MultiPoint(start_points), db.p)
poly = new_drawbox
pts = []
lss = []
n_steps = 14
for pt in tqdm(start_points):
    
    vp = VectorParticle(pos=pt, grid=qpg, stepsize=1, momentum_factor=np.random.uniform(0,0))
    for ii in range(n_steps):
        vp.step()
    if len(vp.pts) > 1:
        ls = gp.merge_LineStrings([LineString(vp.pts)])
    lss.append(ls)
buffer_gen = ss.uniform(loc=0.5, scale=0.5).rvs
d_buffer_gen = functools.partial(np.random.uniform, low=-0.4, high=-0.2)
d_translate_factor_gen = ss.uniform(loc=0.6, scale=0.8).rvs
fills = []
all_polys = Polygon()
for ii, l in enumerate(tqdm(lss[:])):
    p = l.buffer(1.5, cap_style=2, join_style=2)
    p = p.buffer(buffer_gen(), cap_style=2, join_style=2)
    angles_gen = gp.make_callable(sp_angle_range[ii])
#     angles_gen = gp.make_callable(-90)
    stp = gp.ScaleTransPrms(d_buffer=d_buffer_gen(),angles=angles_gen(),d_translate_factor=d_translate_factor_gen(), n_iters=300)
    stp.d_buffers += np.random.uniform(-0.05, 0.05, size=stp.d_buffers.shape)
    P = gp.Poly(p)
    P.fill_scale_trans(**stp.prms)
    visible_area = p.difference(all_polys)
    visible_fill = P.fill.intersection(visible_area.buffer(1e-6))
    
    fills.append(visible_fill)
    all_polys = so.unary_union([all_polys, p])
blss = gp.merge_LineStrings([f for f in fills if f.length > 0.1])
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.stroke(1)
sk.geometry(blss)
    
sk.display()
save
filename = 'vp_test30.svg'
savepath = Path(savedir).joinpath(filename).as_posix()
sk.save(savepath)
def draw_geom_offset(axidraw_handle, geom, xoff=0, yoff=0):
    pts = geom.coords
    y,x = pts[0]
    ad.moveto(x+xoff, y+yoff)
    for pt in pts[1:]:
        y,x = pt
        ad.lineto(x+xoff, y+yoff)
    ad.penup()

ad = axidraw.AxiDraw()          # Initialize class
ad.interactive()
ad.options.units = 2
ad.connect()                    # Open serial port to AxiDraw 
ad.options.speed_pendown = 60 
ad.options.accel=50
ad.update()
ad.moveto(0, 0)
geom.length > 0
yoff = 0
xoff = 0
counter = 0
for ii, geom in enumerate(tqdm(fills)):
    try:
        for line in geom:
            if line.length > 0:
                draw_geom_offset(ad, line, xoff=xoff, yoff=yoff)
                counter += 1
                if counter % 20 == 0:
                    ad.moveto(xoff, yoff)
                    time.sleep(wait_time)
    except:
        pass
yoff = 0
xoff = 0
counter = 0
for ii, geom in enumerate(tqdm(fills)):
    for line in geom:
        if line.length > 0:
            draw_geom_offset(ad, line, xoff=xoff, yoff=yoff)
            counter += 1
            if counter % 20 == 0:
                ad.moveto(xoff, yoff)
                time.sleep(wait_time)
len(fills)<jupyter_output><empty_output><jupyter_text>bez shading<jupyter_code>image_path= '/home/naka/art/wigglesphere.jpg'
filename = 'vp_test31.svg'
paper_size:str = '11x14 inches'
border:float=20  # mm
image_rescale_factor:float=0.04
smooth_disk_size:int=1
hist_clip_limit=0.1
hist_nbins=32
intensity_min=0.
intensity_max=1.
hatch_spacing_min=0.35  # mm
hatch_spacing_max=1.1 # mm
pixel_width=1 # mm
pixel_height=1 # mm
angle_jitter='ss.norm(loc=10, scale=0).rvs'  # degrees
pixel_rotation='0'  # degrees
merge_tolerances=[0.3, 0.4,]  # mm
simplify_tolerances=[0.2,]  # mm
savedir='/home/naka/art/plotter_svgs'
# make page
paper = Paper(paper_size)
drawbox = paper.get_drawbox(border)

xgen = ss.uniform(loc=0.6, scale=0.1).rvs
split_func = functools.partial(gp.split_along_longest_side_of_min_rectangle, xgen=xgen)
splits = gp.recursive_split_frac_buffer(
    drawbox, 
    split_func=split_func,
    p_continue=0.7, 
    depth=0, 
    depth_limit=7,
    buffer_frac=-0.0
)

bps = MultiPolygon([p for p in splits])

   
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.penWidth('0.5mm')
sk.geometry(bps.boundary)

# tolerance=0.5

sk.display()
n_layers = 1
layers = []
for ii in range(n_layers):
    fills = []
    for p in bps:
        xjitter_func = 0
        yjitter_func = ss.norm(loc=0, scale=np.random.uniform(0.1, 1.5)).rvs
        bhf = gp.BezierHatchFill(
            spacing=np.random.uniform(0.25, 0.35),
            degrees=np.random.uniform(40,60),
            poly_to_fill=p, 
            xjitter_func=xjitter_func, 
            yjitter_func=yjitter_func,
            fill_inscribe_buffer=1.4,
            n_nodes_per_line=15,
            n_eval_points=100,
        )
        fills.append(bhf.p)

    fills = [f for f in fills if f.length > 0]
    layer = gp.merge_LineStrings(fills)
    layers.append(layer)
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.penWidth('0.3mm')
for i, layer in enumerate(layers):
    sk.stroke(i+1)
    sk.geometry(layer)

# sk.penWidth('0.2')
# for tolerance in [0.1, 0.3, 1.5]:
#     sk.vpype(f'linemerge --tolerance {tolerance}mm')
# sk.vpype('linesimplify --tolerance 0.1 linesort')

sk.display(color_mode='layer')
def draw_geom_offset(axidraw_handle, geom, xoff=0, yoff=0):
    pts = geom.coords
    y,x = pts[0]
    ad.moveto(x+xoff, y+yoff)
    for pt in pts[1:]:
        y,x = pt
        ad.lineto(x+xoff, y+yoff)
    ad.penup()

ad = axidraw.AxiDraw()          # Initialize class
ad.interactive()
ad.options.units = 2
ad.connect()                    # Open serial port to AxiDraw 
time.sleep(wait_time)
ad.options.speed_pendown = 60 
ad.options.accel=50
ad.update()
ad.moveto(0, 150)
geom.length > 0
ad.current_pos()
ad.pen_lower()
ad.pen_raise()
yoff = 150
xoff = 0
counter = 0
wait_time=2.1
for ii, geom in enumerate(tqdm(fills[21:])):
    try:
        for line in geom:
            if line.length > 0:
                draw_geom_offset(ad, line, xoff=xoff, yoff=yoff)
                counter += 1
                if counter % 30 == 0:
                    ad.moveto(xoff, yoff)
                    time.sleep(wait_time)
    except KeyboardInterrupt:
        break
    except:
        pass<jupyter_output><empty_output><jupyter_text>testing<jupyter_code>image_path= '/home/naka/art/wigglesphere.jpg'
filename = 'vp_test29.svg'
paper_size:str = '11x14 inches'
border:float=20  # mm
image_rescale_factor:float=0.04
smooth_disk_size:int=1
hist_clip_limit=0.1
hist_nbins=32
intensity_min=0.
intensity_max=1.
hatch_spacing_min=0.35  # mm
hatch_spacing_max=1.1 # mm
pixel_width=1 # mm
pixel_height=1 # mm
angle_jitter='ss.norm(loc=10, scale=0).rvs'  # degrees
pixel_rotation='0'  # degrees
merge_tolerances=[0.3, 0.4,]  # mm
simplify_tolerances=[0.2,]  # mm
savedir='/home/naka/art/plotter_svgs'
# make page
paper = Paper(paper_size)
drawbox = paper.get_drawbox(border)

drawbox.bounds
p = box(110, 30 ,180 ,110)
p.bounds
fills = []
xjitter_func = 0
yjitter_func = ss.norm(loc=0, scale=np.random.uniform(0.31, 0.35)).rvs
bhf = gp.BezierHatchFill(
    spacing=np.random.uniform(0.28, 0.3),
    degrees=90,
    poly_to_fill=p, 
    xjitter_func=xjitter_func, 
    yjitter_func=yjitter_func,
    fill_inscribe_buffer=1.4,
    n_nodes_per_line=10,
    n_eval_points=20,
)
fills.append(bhf.p)
blss = gp.merge_LineStrings([f for f in fills if f.length > 0.1])
sk = vsketch.Vsketch()
sk.size(paper.page_format_mm)
sk.scale('1mm')
sk.stroke(1)
sk.geometry(p.boundary)
for ii, ls in enumerate(blss):
    sk.stroke(ii + 2)
    sk.geometry(ls)
# sk.stroke(1)
# sk.geometry(blss)
sk.stroke(1000)
sk.geometry(drawbox.boundary)
    
sk.display()
filename = 'vp_test31.svg'
savepath = Path(savedir).joinpath(filename).as_posix()
sk.save(savepath)
wait_time = 1.1
len(blss)
ad = axidraw.AxiDraw()   
ad.plot_setup(savepath)
ad.options.mode = "layers"
for ii in tqdm(range(len(blss))):
    ad.options.layer = ii
    ad.options.speed_pendown = 90
    ad.plot_run()
    time.sleep(wait_time)
    

ad = axidraw.AxiDraw()          # Initialize class
ad.interactive()
ad.options.units = 2
ad.connect()                    # Open serial port to AxiDraw 
ad.options
ad.options.speed_pendown = 90 
ad.options.accel=90
ad.update()
def draw_geom(axidraw_handle, geom):
    pts = geom.coords
    y,x = pts[0]
    ad.moveto(x, y)
    for pt in pts[1:]:
        y,x = pt
        ad.lineto(x, y)
    ad.penup()
ii = 2
geom = blss[ii]
draw_geom(ad, geom)
for geom in tqdm(blss):
    draw_geom(ad, geom)
#     ad.moveto(0,0)
#     time.sleep(wait_time)
11 * 25.4
pt = [0]
ad.penup()
                              # Absolute moves follow:
ad.moveto(30, 110)                  # Pen-up move to (1 inch, 1 inch)
# ad.lineto(2,1)                  # Pen-down move, to (2 inch, 1 inch)
ad.moveto(0,0)  
                # Pen-up move, back to origin.
ad.disconnect()                 # Close serial port to AxiDraw<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14010441385856667, 'fraction_numerical': 0.03488372093023256, 'mean_word_length': 3.783427922814983, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '138530', 'license': 'MIT', 'n_tokens_mistral': 9049, 'n_tokens_neox': 8485, 'n_words': 1456, 'path': 'scratch/040_manual.ipynb', 'repo_name': 'ANaka/genpen', 'size': '21070'}