Radioactive construction ☢️

The Standard Radiation Symbol with dimensions as defined in archive.org/stream/f…t#page/n848/mode/1up

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

const scale = 15; //min=.5, max=18, step=0.1
const showHelperLines = 1; //min=0, max=1, step=1

const r = 1 * scale;

// Global code will be evaluated once.
const text = new Text();
const turtle = new Turtle();
turtle.radians();

// The walk function will be called until it returns false.
function walk(i) {
    //inner circle (start down, go clockwise)
    turtle.jump(0, -r);
    turtle.seth(0);
    turtle.circle(r);
    
    for(let j = 0; j < 3; j++) {
        //small one
        turtle.jump(-Math.cos(j/3 * 2 * Math.PI) * 1.5 * r, -Math.sin(j / 3 * 2 * Math.PI) * 1.5 * r);
        turtle.seth((j/3 * 2 * Math.PI) - (Math.PI/2));
        
        turtle.circle(1.5*r, (Math.PI/3));

        //big one
        turtle.jump(-Math.cos(j/3 * 2 * Math.PI) * 5 * r, -Math.sin(j / 3 * 2 * Math.PI) * 5 * r);
        turtle.seth((j/3 * 2 * Math.PI) - (Math.PI/2));
        
        turtle.circle(5*r, (Math.PI/3));
    }
    
    for(let j = 0; j < 6; j++) {
        turtle.jump(-Math.cos(j/6 * 2 * Math.PI) * 1.5 * r, -Math.sin(j / 6 * 2 * Math.PI) * 1.5 * r);
        turtle.goto(-Math.cos(j/6 * 2 * Math.PI) * 5 * r, -Math.sin(j / 6 * 2 * Math.PI) * 5 * r);
    }

    if(showHelperLines == 0) {
        turtle.jump(-34, 90);
        turtle.seth(0);
        text.print(turtle, '- Radiation -', .3);
    }    

    if(showHelperLines == 1) {
        turtle.seth(0);//Math.PI*3/2);
        turtle.jump(-r*6,r);
        text.print(turtle, 'R', .3)
        turtle.jump(-r*6,r);
        text.print(turtle, '  =RADIUS OF', .2)
        turtle.jump(-r*5.25,r+8);
        text.print(turtle, 'CENTRAL DISC', .2)
        
        //y-axis
        dashedLine(0, -r*5, 0, r*6.5, [5,.5]);

        //60 deg endings
        for(let j = 0; j < 3; j++) {
            dashedLine(-Math.cos(j/6 * 2 * Math.PI) * 6 * r, -Math.sin(j / 6 * 2 * Math.PI) * 6 * r, -Math.cos(j/6 * 2 * Math.PI) * 5 * r, -Math.sin(j / 6 * 2 * Math.PI) * 5 * r, [5,.5]);
        }

        turtle.jump(-5.5 * r, 0);
        turtle.seth(Math.PI / 2);
        let p = [];
        for(let j = 0; j < 2; j++) {
            arrowHead(turtle, 3, Math.PI / 6);
            turtle.left(Math.PI)
            turtle.circle(5.5 * r, Math.PI/7);
            p.push( turtle.pos() );
            turtle.penup();
            turtle.circle(5.5 * r, Math.PI/21);
            turtle.pendown();
            turtle.circle(5.5 * r, Math.PI/7);
            arrowHead(turtle, 3, Math.PI / 6);
            turtle.left(Math.PI);
        }
        turtle.seth(0);
        turtle.jump(p[0][0] - (r / 7), p[0][1] - (r / 3));
        text.print(turtle, '60', .2);
        text.print(turtle, ' o', .13);
        turtle.jump(p[1][0] + (r / 10), p[1][1]);
        text.print(turtle, '60', .2);
        text.print(turtle, ' o', .13);

        dashedLine(r*5, 0, r*5, r*6.6, [5,.5]);

        dashedLine(r*1.5, 0, r*1.5, r*5.75, [5,.5]);

        dashedLine(r, 0, r, r*4.5, [5,.5]);


        turtle.seth(Math.PI);

        turtle.jump(0, r*6.3);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r*2);
        turtle.jump(r*1.5, r*5.5);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r/2);
        turtle.jump(r, r*4.2);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r/2);

        turtle.seth(0);

        turtle.jump(r*5, r*6.3);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r*2);
        turtle.jump(0, r*5.5);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r/2);
        turtle.jump(0, r*4.2);
        arrowHead(turtle, 3, Math.PI / 6);
        turtle.backward(r/2);
        
        turtle.seth(0);
        turtle.jump(r / 2 - 2.2, r*4.2);
        text.print(turtle, 'R', .2);
        
        turtle.seth(0);
        turtle.jump(r / 3.5, r*5.5);
        text.print(turtle, '1/ R', .2);
        turtle.jump(r / 1.9, r*5.4);
        text.print(turtle, '1', .13);
        turtle.jump(r / 1.3, r*5.6);
        text.print(turtle, '2', .13);
        
        turtle.seth(0);
        turtle.jump(r *2.2, r*6.3);
        text.print(turtle, '5R', .2);
    }
    
    return false;
}

function arrowHead(turtle, arrowSize, arrowAngle) {
    if(arrowSize === null) { arrowSize = 3; }

    if(arrowAngle === null) { arrowAngle = Math.PI / 6; }
    
    let h = turtle.heading();
    let p = turtle.pos();
    
    turtle.right(Math.PI - arrowAngle);
    turtle.forward(arrowSize);
    turtle.jump(p);
    turtle.right(2 * arrowAngle);
    turtle.forward(arrowSize);
    turtle.jump(p);
    turtle.seth(h);
}

function dashedLine(x1, y1, x2, y2, pattern = [500]) {
    turtle.jump(x1, y1);
    turtle.setheading(y2 > y1? Math.PI / 2: Math.PI / 2 * 3);
    let len = Math.sqrt((x2-x1)**2 + (y2-y1)**2);
    if(x1 != x2) {
        turtle.setheading((x2-x1 < 0? Math.PI: 0) + Math.atan((y2 - y1) / (x2 - x1)));
    }
    let tr = 0;
    let i = 0;
    turtle.penup();
    while(tr < len) {
        let inc = pattern[i % pattern.length];
        turtle.isdown()? turtle.penup(): turtle.pendown();
        turtle.forward(inc + tr > len? len - tr: inc);
        i++;
        tr+=inc;
    }
}

////////////////////////////////////////////////////////////////
// Text utility code. Created by Reinder Nijhoff 2019
// https://turtletoy.net/turtle/1713ddbe99
////////////////////////////////////////////////////////////////

function Text() {
    class Text {
        print (t, str, scale = 1, italic = 0, kerning = 1) {
            t.radians();
            let pos = [t.x(), t.y()], h = t.h(), o = pos;
            str.split('').map(c => {
                const i = c.charCodeAt(0) - 32;
                if (i < 0 ) {
                    pos = o = this.rotAdd([0, 48*scale], o, h);
                } else if (i > 96 ) {
                    pos = this.rotAdd([16*scale, 0], o, h);
                } else {
                    const d = dat[i], lt = d[0]*scale, rt = d[1]*scale, paths = d[2];
                    paths.map( p => {
                        t.up();
                    	p.map( s=> {
                        	t.goto(this.rotAdd([(s[0]-s[1]*italic)*scale - lt, s[1]*scale], pos, h));
                        	t.down();
                        });
                    });
                    pos = this.rotAdd([(rt - lt)*kerning, 0], pos, h);
                }
            });
        }
        rotAdd (a, b, h) {
            return [Math.cos(h)*a[0] - Math.sin(h)*a[1] + b[0], 
                    Math.cos(h)*a[1] + Math.sin(h)*a[0] + b[1]];
        }
    }
    
const dat = ('br>eoj^jl<jqirjskrjq>brf^fe<n^ne>`ukZdz<qZjz<dgrg<cmqm>`thZhw<lZlw<qao_l^h^e_caccdeefg'+
'gmiojpkqmqporlshsercp>^vs^as<f^h`hbgdeeceacaab_d^f^h_k`n`q_s^<olmmlolqnspsrrspsnqlol>]wtgtfsereqfph'+
'nmlpjrhsdsbraq`o`makbjifjekckaj_h^f_eaecffhimporqssstrtq>eoj`i_j^k_kajcid>cqnZl\\j_hcghglhqjulxnz>c'+
'qfZh\\j_lcmhmllqjuhxfz>brjdjp<egom<ogem>]wjajs<ajsj>fnkojpiojnkokqis>]wajsj>fnjniojpkojn>_usZaz>`ti'+
'^f_dbcgcjdofrisksnrpoqjqgpbn_k^i^>`tfbhak^ks>`tdcdbe`f_h^l^n_o`pbpdofmicsqs>`te^p^jfmfogphqkqmppnrk'+
'shserdqco>`tm^clrl<m^ms>`to^e^dgefhekenfphqkqmppnrkshserdqco>`tpao_l^j^g_ebdgdlepgrjsksnrppqmqlping'+
'kfjfggeidl>`tq^gs<c^q^>`th^e_dadceegfkgnhpjqlqopqorlshserdqcocldjfhigmfoepcpao_l^h^>`tpeohmjjkikfjd'+
'hcecddaf_i^j^m_oapepjoomrjshserdp>fnjgihjikhjg<jniojpkojn>fnjgihjikhjg<kojpiojnkokqis>^vrabjrs>]wag'+
'sg<amsm>^vbarjbs>asdcdbe`f_h^l^n_o`pbpdofngjijl<jqirjskrjq>]xofndlcicgdfeehekfmhnknmmnk<icgefhfkgmh'+
'n<ocnknmpnrntluiugtdsbq`o_l^i^f_d`bbad`g`jambodqfrislsorqqrp<pcokompn>asj^bs<j^rs<elol>_tc^cs<c^l^o'+
'_p`qbqdpfoglh<chlhoipjqlqopqorlscs>`urcqao_m^i^g_eadccfckdnepgrismsorqprn>_tc^cs<c^j^m_oapcqfqkpnop'+
'mrjscs>`sd^ds<d^q^<dhlh<dsqs>`rd^ds<d^q^<dhlh>`urcqao_m^i^g_eadccfckdnepgrismsorqprnrk<mkrk>_uc^cs<'+
'q^qs<chqh>fnj^js>brn^nnmqlrjshsfreqdndl>_tc^cs<q^cl<hgqs>`qd^ds<dsps>^vb^bs<b^js<r^js<r^rs>_uc^cs<c'+
'^qs<q^qs>_uh^f_daccbfbkcndpfrhslsnrppqnrkrfqcpan_l^h^>_tc^cs<c^l^o_p`qbqepgohlici>_uh^f_daccbfbkcnd'+
'pfrhslsnrppqnrkrfqcpan_l^h^<koqu>_tc^cs<c^l^o_p`qbqdpfoglhch<jhqs>`tqao_l^h^e_caccdeefggmiojpkqmqpo'+
'rlshsercp>brj^js<c^q^>_uc^cmdpfrisksnrppqmq^>asb^js<r^js>^v`^es<j^es<j^os<t^os>`tc^qs<q^cs>asb^jhjs'+
'<r^jh>`tq^cs<c^q^<csqs>cqgZgz<hZhz<gZnZ<gznz>cqc^qv>cqlZlz<mZmz<fZmZ<fzmz>brj\\bj<j\\rj>asazsz>fnkc'+
'ieigjhkgjfig>atpeps<phnfleiegfehdkdmepgrislsnrpp>`sd^ds<dhffhekemfohpkpmopmrkshsfrdp>asphnfleiegfeh'+
'dkdmepgrislsnrpp>atp^ps<phnfleiegfehdkdmepgrislsnrpp>asdkpkpiognfleiegfehdkdmepgrislsnrpp>eqo^m^k_j'+
'bjs<gene>atpepuoxnylzizgy<phnfleiegfehdkdmepgrislsnrpp>ate^es<eihfjemeofpips>fni^j_k^j]i^<jejs>eoj^'+
'k_l^k]j^<kekvjyhzfz>are^es<oeeo<ikps>fnj^js>[y_e_s<_ibfdegeifjijs<jimfoeretfuius>ateees<eihfjemeofp'+
'ips>atiegfehdkdmepgrislsnrppqmqkphnfleie>`sdedz<dhffhekemfohpkpmopmrkshsfrdp>atpepz<phnfleiegfehdkd'+
'mepgrislsnrpp>cpgegs<gkhhjfleoe>bsphofleieffehfjhkmlompopporlsisfrep>eqj^jokrmsos<gene>ateeeofrhsks'+
'mrpo<peps>brdejs<pejs>_ubefs<jefs<jens<rens>bseeps<pees>brdejs<pejshwfydzcz>bspees<eepe<esps>cqlZj['+
'i\\h^h`ibjckekgii<j[i]i_jakbldlfkhgjkllnlpkrjsiuiwjy<ikkmkojqirhthvixjylz>fnjZjz>cqhZj[k\\l^l`kbjci'+
'eigki<j[k]k_jaibhdhfihmjilhnhpirjskukwjy<kkimiojqkrltlvkxjyhz>^vamakbhdgfghhlknlplrksi<akbidhfhhill'+
'nmpmrlsisg>brb^bscsc^d^dsese^f^fsgsg^h^hsisi^j^jsksk^l^lsmsm^n^nsoso^p^psqsq^r^rs').split('>').map(
    r=> { return [r.charCodeAt(0)-106,r.charCodeAt(1)-106, r.substr(2).split('<').map(a => {const ret 
    = []; for (let i=0; i<a.length; i+=2) {ret.push(a.substr(i, 2).split('').map(b => b.charCodeAt(0)
    -106));} return ret; })]; });

    return new Text();
}