# Arc in layer. How to put an arc() in a layer

**URL:** <https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991>\
**Category:** Coding Questions\
**Created:** [May 9, 2021, 7:10pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991 "2021-05-09T19:10:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [May 9, 2021, 7:10pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/1 "2021-05-09T19:10:36Z")

</div>

```auto
let botonito, indice=-1, segmentos=[], global_layer;
let a,b,c,d,e,f;

function setup() {
  
var ww = windowWidth, wh = windowHeight;
var wwg = ww/20, whg = wh/20;

let uno = [wwg*8,whg*2,wwg*8,whg,3.14,6.28],
    dos = [wwg*12,whg*4,wwg,whg*4,4.71,1.57],
    tres = [wwg*10,whg*5.75,wwg*4.5,whg,0,3.14],
    cuatro = [wwg*10,whg*5.75,wwg*4.5,whg,3.14,6.28],
    cinco = [wwg*12.25,whg*8.35,wwg,whg*5,4.71,1.57],
    seis = [wwg*8.25,whg*11,wwg*8,whg,0,3.14],
    siete = [wwg*4.75,whg*11,wwg,whg*0.75,3.14,6.28],
    ocho = [wwg*5.25,whg*13.5,wwg*0.5,whg*5,4.71,1.57],
    nueve = [wwg*4.75,whg*16,wwg,whg*0.75,0,3.14],
    diez = [wwg*8.5,whg*16,wwg*8.5,whg,3.14,6.28],
    once = [wwg*12.6,whg*17.6,wwg,whg*3.5,4.71,1.57],
    doce = [wwg*7.7,whg*19.25,wwg*10,whg,0,3.14],
    trece = [wwg*2.75,whg*10.5,wwg,whg*17.5,1.57,4.71],
    catorce = [wwg*10.25,whg*1.7,wwg*15,whg,3.14,6.28],
    quince = [wwg*16.65,whg*1.7,wwg*2,whg*1.15,0,3.14],
    dieciseis = [wwg*17.2,whg*1.7,wwg*3,whg,3.14,6.28],
    diecisiete = [wwg*18.6,whg*10.1,wwg,whg*17,4.71,1.57],
    dieciocho = [wwg*17.1,whg*18.65,wwg*2.85,whg,0,3.14],
    diecinueve = [wwg*15.75,whg*10.25,wwg,whg*17.25,1.57,4.71];

segmentos=[uno,dos,tres,cuatro,cinco,seis,siete,ocho,nueve,diez,once,doce,trece,catorce,quince,dieciseis,diecisiete,dieciocho,diecinueve];
  
  createCanvas(ww, wh);
  botonito = createButton('siguiente segmento');
  botonito.position(0,0);
  botonito.mousePressed(etapas);
  stroke(0);
  global_layer = createGraphics(ww, wh);
  global_layer.clear();
}

function draw() {
  background(210);
  noFill();
  noLoop();
  globy();
}

function etapas(){
  indice = (indice + 1) % 19;
  global_layer.strokeWeight(random(1,3));
  a = segmentos[indice][0];
  b = segmentos[indice][1];
  c = segmentos[indice][2];
  d = segmentos[indice][3];
  e = segmentos[indice][4];
  f = segmentos[indice][5];
  global_layer.arc(a,b,c,d,e,f);
}

function globy() {
  image(global_layer, 0, 0);
}

```

button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)`Preformatted text`

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 9, 2021, 7:45pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/2 "2021-05-09T19:45:55Z")

</div>

Hello @patricio1979,

Do you mean to put an arc on a layer above the createCanvas area/layer?

If so, this YouTube tutorial on Coding Train may be of interest:

https://www.youtube.com/embed/TaluaAD9MKA?feature=oembed&wmode=opaque&list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

🤓

---

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [May 9, 2021, 7:56pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/3 "2021-05-09T19:56:27Z")

</div>

I saw that.

The problem might be in the way the variables are declared.  
Perhaps each layer works with their specific set of variables. There’s no problem with the front or back. The problem is that it doesn’t draw the arc at all.

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 9, 2021, 8:08pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/4 "2021-05-09T20:08:56Z")

</div>

I could be wrong, but the way I’m reading your code is that your **etapas** function is being called to the createCanvas area? But shouldn’t **etapas** be called into the **globy** function?

---

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [May 9, 2021, 8:19pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/5 "2021-05-09T20:19:07Z")

</div>

That does not work either. The **etapas** function is for step sequencing only.  
Perhaps is a nameSpace method…

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 9, 2021, 8:32pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/6 "2021-05-09T20:32:49Z")

</div>

Hmm, not sure what’s going on… I’ll be curious to hear other responses…

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 9, 2021, 8:59pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/7 "2021-05-09T20:59:25Z")

</div>

You need to call etapas at the end of setup ()

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 9, 2021, 9:41pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/8 "2021-05-09T21:41:53Z")

</div>

Hello,

Change this:  
`noLoop();`

to this:  
`// noLoop();`

You may also want to use this:  
`global_layer.noFill();`

Reference:  
[NoLoop() Reference](https://p5js.org/reference/#/p5/noLoop)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a761ab5c8351b350623a459b1f083aa514138ee4.png)

`:)`

---

<div class="post-metadata">

**Author:** ![patricio1979](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/patricio1979/32/13609_2.png) [@patricio1979](https://discourse.processing.org/u/patricio1979)\
**Post date:** [May 9, 2021, 10:39pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/9 "2021-05-09T22:39:45Z")

</div>

Beautiful, don’t understand why, but you nailed it. Thank you!!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 9, 2021, 10:48pm UTC](https://discourse.processing.org/t/arc-in-layer-how-to-put-an-arc-in-a-layer/29991/10 "2021-05-09T22:48:25Z")

</div>

> [@patricio1979](#):
>
> don’t understand why,

Hello,

Take a look at the reference for noLoop()

`:)`
