# Shape generator help (Armin Hofmann’s ‘rubber band’ shape generator) #2

**URL:** https://discourse.processing.org/t/shape-generator-help-armin-hofmann-s-rubber-band-shape-generator-2/41693
**Category:** Coding Questions
**Tags:** homework
**Created:** [April 12, 2023, 7:01am UTC](https://discourse.processing.org/t/shape-generator-help-armin-hofmann-s-rubber-band-shape-generator-2/41693 "2023-04-12T07:01:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SvenHW](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@SvenHW](https://discourse.processing.org/u/SvenHW)
#### Post date: [April 12, 2023, 7:01am UTC](https://discourse.processing.org/t/shape-generator-help-armin-hofmann-s-rubber-band-shape-generator-2/41693/1 "2023-04-12T07:01:35Z")

</div>

Can someone help me with my code?  
I tried to auto generate the shapes from Armin Hofmann but don’t know how to get further.  
This is what I have now:

https://openprocessing.org/sketch/1894305/embed/

This his how it should be:

 ![24ca834d3105c5747feba6a34077b7a8](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/8/a/8a16cca54c171db066b0098fc8156b05e99fc928.jpeg)

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [April 13, 2023, 1:28am UTC](https://discourse.processing.org/t/shape-generator-help-armin-hofmann-s-rubber-band-shape-generator-2/41693/2 "2023-04-13T01:28:35Z")

</div>

you have to use the shape method, hence call beginShape and endShape and make use of arcs and vertexes here is an example.

this is taken from an old request

> **[how to combine a line and an arc into a shape? - Processing Forum](https://forum.processing.org/one/topic/how-to-combine-a-line-and-an-arc-into-a-shape.html)**
>
> Processing Forum

```auto

    Shape[] shapes = new Shape[3];
    void setup(){
      size(300,300);
      smooth(8);
     
      float eh = 100;
      float ew = 200;
      PVector l = new PVector(100,200);
     
      shapes[2] = new Shape(eh, ew, 100.0, 100.0/3, l);
    }
    void draw(){
      background(255);
      strokeWeight(4);
      stroke(0);
      strokeCap(PROJECT);
      strokeJoin(MITER);
      fill(255,0,0);
      //shapes[2].c = color(0);
      shapes[2].draw();
     
    }
    class Shape{
      //----- variables ------
      float ellipseHeight;
      float ellipseWidth;
      float shapeWidth;
      float shapeHeight;
      PVector location;
     
      //----- constructor -----
      Shape(float eh, float ew, float sh, float sw, PVector l){
        ellipseHeight = eh;
        ellipseWidth = ew;
        shapeWidth = sw;
        shapeHeight = sh;
        PVector p = l.get();
        location = p;
      }
     
      //------ draw shape -----
      void draw(){
        beginShape();
        float theY = (ellipseHeight/2) * sin(acos(shapeWidth/(ellipseWidth/2)));
        arc(location.x, location.y-shapeHeight+theY, shapeWidth*2, theY*2, -PI/2,0);
        vertex(location.x+shapeWidth, location.y-shapeHeight+theY);
        vertex(location.x+shapeWidth, location.y+theY);
        vertex(location.x, location.y+theY);
        vertex(location.x, location.y-shapeHeight);
    // );   
        endShape();
      }
    }

```

the code in question to make the shape in the draw loop

```auto
void draw(){
        beginShape();
        float theY = (ellipseHeight/2) * sin(acos(shapeWidth/(ellipseWidth/2)));
        arc(location.x, location.y-shapeHeight+theY, shapeWidth*2, theY*2, -PI/2,0);
        vertex(location.x+shapeWidth, location.y-shapeHeight+theY);
        vertex(location.x+shapeWidth, location.y+theY);
        vertex(location.x, location.y+theY);
        vertex(location.x, location.y-shapeHeight);
    // );   
        endShape();

}

```

after that its just knowing how to make proper use of the arc function

> **[arc() / Reference](https://processing.org/reference/arc_.html)**
>
> Draws an arc to the screen. Arcs are drawn along the outer edge of an ellipse defined by the a, b, c, and d parameters. The origin of the arc's ellipse may be changed with …
