Blog

Making a robot army with Processing and HYPE

Start of with some shitty doodles of the parts you want to use:

Example of the heads i used

Example of the heads i used

Turn everything into SVGs in your vector graphics program of choice:

and name ALL THE THINGS

and name ALL THE THINGS

then we take all the SVG files, put them in a directory for a file we're going to make, choose a colour palette and get the hex codes for each colour then finally write a  block of text with some a program and a library that will look all the bit up and put them together in a mostly random way:

import processing.pdf.*;
boolean record = false;

HDrawablePool h, b, ls, rs, lua, rua, lla, rla, lul, rul, lll, rll;
HColorPool colors;

void setup(){
    size(400,650);
    H.init(this).background(#202020);
    smooth();

    colors = new HColorPool(#443D40,#70414B,#B5455A,#F44868,#D1465F,#12B6A7,#18BFB0,#4BC5BC,#268C83,#375454,#306D6A,#6ACAC2,#A4D3CF,#C4DDDA,#EEF1F1,#3B4345);

    h = new HDrawablePool(01);
    h.autoAddToStage()
        .add(new HShape("h-01.svg"))
        .add(new HShape("h-02.svg"))
        .add(new HShape("h-03.svg"))
        .add(new HShape("h-04.svg"))
        .add(new HShape("h-05.svg"))
        .add(new HShape("h-06.svg"))
        .add(new HShape("h-07.svg"))
        .add(new HShape("h-08.svg"))
        .add(new HShape("h-09.svg"))
        .add(new HShape("h-10.svg"))
        .add(new HShape("h-11.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(135, 10)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;


    b = new HDrawablePool(01);
    b.autoAddToStage()
        .add(new HShape("b-01.svg"))
        .add(new HShape("b-02.svg"))
        .add(new HShape("b-03.svg"))
        .add(new HShape("b-04.svg"))
        .add(new HShape("b-05.svg"))
        .add(new HShape("b-06.svg"))
        .add(new HShape("b-07.svg"))
        .add(new HShape("b-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(85, 110)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

ls = new HDrawablePool(01);
    ls.autoAddToStage()
        .add(new HShape("ls-01.svg"))
        .add(new HShape("ls-02.svg"))
        .add(new HShape("ls-03.svg"))
        .add(new HShape("ls-04.svg"))
        .add(new HShape("ls-05.svg"))
        .add(new HShape("ls-06.svg"))
        .add(new HShape("ls-07.svg"))
        .add(new HShape("ls-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(10, 110)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    rs = new HDrawablePool(01);
    rs.autoAddToStage()
        .add(new HShape("rs-01.svg"))
        .add(new HShape("rs-02.svg"))
        .add(new HShape("rs-03.svg"))
        .add(new HShape("rs-04.svg"))
        .add(new HShape("rs-05.svg"))
        .add(new HShape("rs-06.svg"))
        .add(new HShape("rs-07.svg"))
        .add(new HShape("rs-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(285, 110)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    lua = new HDrawablePool(01);
    lua.autoAddToStage()
        .add(new HShape("lua-01.svg"))
        .add(new HShape("lua-02.svg"))
        .add(new HShape("lua-03.svg"))
        .add(new HShape("lua-04.svg"))
        .add(new HShape("lua-05.svg"))
        .add(new HShape("lua-06.svg"))
        .add(new HShape("lua-07.svg"))
        .add(new HShape("lua-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(22, 185)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    rua = new HDrawablePool(01);
    rua.autoAddToStage()
        .add(new HShape("rua-01.svg"))
        .add(new HShape("rua-02.svg"))
        .add(new HShape("rua-03.svg"))
        .add(new HShape("rua-04.svg"))
        .add(new HShape("rua-05.svg"))
        .add(new HShape("rua-06.svg"))
        .add(new HShape("rua-07.svg"))
        .add(new HShape("rua-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(298, 185)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    lla = new HDrawablePool(01);
    lla.autoAddToStage()
        .add(new HShape("lla-01.svg"))
        .add(new HShape("lla-02.svg"))
        .add(new HShape("lla-03.svg"))
        .add(new HShape("lla-04.svg"))
        .add(new HShape("lla-05.svg"))
        .add(new HShape("lla-06.svg"))
        .add(new HShape("lla-07.svg"))
        .add(new HShape("lla-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(22, 260)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    rla = new HDrawablePool(01);
    rla.autoAddToStage()
        .add(new HShape("rla-01.svg"))
        .add(new HShape("rla-02.svg"))
        .add(new HShape("rla-03.svg"))
        .add(new HShape("rla-04.svg"))
        .add(new HShape("rla-05.svg"))
        .add(new HShape("rla-06.svg"))
        .add(new HShape("rla-07.svg"))
        .add(new HShape("rla-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(298, 260)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    lul = new HDrawablePool(01);
    lul.autoAddToStage()
        .add(new HShape("lul-01.svg"))
        .add(new HShape("lul-02.svg"))
        .add(new HShape("lul-03.svg"))
        .add(new HShape("lul-04.svg"))
        .add(new HShape("lul-05.svg"))
        .add(new HShape("lul-06.svg"))
        .add(new HShape("lul-07.svg"))
        .add(new HShape("lul-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(105, 410)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    rul = new HDrawablePool(01);
    rul.autoAddToStage()
        .add(new HShape("rul-01.svg"))
        .add(new HShape("rul-02.svg"))
        .add(new HShape("rul-03.svg"))
        .add(new HShape("rul-04.svg"))
        .add(new HShape("rul-05.svg"))
        .add(new HShape("rul-06.svg"))
        .add(new HShape("rul-07.svg"))
        .add(new HShape("rul-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(215, 410)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    lll = new HDrawablePool(01);
    lll.autoAddToStage()
        .add(new HShape("lll-01.svg"))
        .add(new HShape("lll-02.svg"))
        .add(new HShape("lll-03.svg"))
        .add(new HShape("lll-04.svg"))
        .add(new HShape("lll-05.svg"))
        .add(new HShape("lll-06.svg"))
        .add(new HShape("lll-07.svg"))
        .add(new HShape("lll-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(105, 485)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    rll = new HDrawablePool(01);
    rll.autoAddToStage()
        .add(new HShape("rll-01.svg"))
        .add(new HShape("rll-02.svg"))
        .add(new HShape("rll-03.svg"))
        .add(new HShape("rll-04.svg"))
        .add(new HShape("rll-05.svg"))
        .add(new HShape("rll-06.svg"))
        .add(new HShape("rll-07.svg"))
        .add(new HShape("rll-08.svg"))
        .onCreate(
            new HCallback() {
                public void run(Object obj) {
                    HShape d = (HShape) obj;
                    d
                        .enableStyle(true)
                        .strokeJoin(ROUND)
                        .strokeCap(ROUND)
                        .strokeWeight(1)
                        .stroke(#FFFFFF)
                        //.size( (int)random(200,400) )
                        //.rotate( (int)random(360) )
                        .loc(215, 485)
                        //.anchorAt(H.CENTER)
                    ;
                    d.randomColors(colors.fillOnly());
                }
            }
        )
        .requestAll()
    ;

    //H.drawStage();
}

void draw() {
    PGraphics tmp = null;

    if (record) {
        tmp = beginRecord(PDF, "render-######.pdf");
    }

    if (tmp == null) {
        H.drawStage();
    } else {
        PGraphics g = tmp;
        boolean uses3D = false;
        float alpha = 1;
        H.stage().paintAll(g, uses3D, alpha);
    }

    if (record) {
        endRecord();
        record = false;
    }
}

void keyPressed() {
    if (key == 's') {
        record = true;
        draw();
    }
}