from solid import *
from solid.utils import *  # Not required, but the utils module is useful
import viewscad
d = difference()(
    cube(10),  # Note the comma between each element!
    sphere(12)
)
scad_render(d)
'\n\ndifference() {\n\tcube(size = 10);\n\tsphere(r = 12);\n}'
r = viewscad.Renderer()
r.render(d)
from math import cos, radians, sin, pi, tau

o = translate([0, 1, 0])(sphere(r=0.2))
for i in range(int(tau*3)):
    a = i/3
    o += translate([sin(a), cos(a), 0])(sphere(r=0.2))
r.render(o)

Bringing in some data

import pandas as pd
df = pd.read_csv('data/day_counts.csv', parse_dates=['Date']).fillna(0)
df.head()
Date Day Count
0 2018-12-08 Saturday 1.0
1 2018-12-09 Sunday 3.0
2 2018-12-10 Monday 2.0
3 2018-12-11 Tuesday 2.0
4 2018-12-12 Wednesday 1.0
chunks = []
for i in range(0, len(df), 28):
    chunks.append(df['Count'].values[i:i+28])
chunks[0]
array([1., 3., 2., 2., 1., 1., 4., 1., 0., 2., 1., 1., 1., 0., 2., 0., 2.,
       0., 1., 1., 1., 0., 0., 1., 1., 2., 0., 1.])
def draw_chunk(c):
    o = sphere(r=0.2)
    for i, v in enumerate(c):
        o += translate([sin(i*tau/28), cos(i*tau/28), 0])(sphere(r=0.15 + 0.05*v))
    o -= sphere(r=0.3)
    return o
r.render(draw_chunk(chunks[0]))
o = draw_chunk(chunks[0])
for i, c in enumerate(chunks[1:4]):
    o += translate([0, 0, i/4])(draw_chunk(c))
r.render(o)
scad_render_to_file(o, 'outputs/test1.scad')
'/home/jonathan/Projects/days_of_code/notebooks/outputs/test1.scad'