# Make older processing code compatible with processing 3

**URL:** <https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567>\
**Category:** Coding Questions\
**Created:** [November 20, 2020, 3:22pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567 "2020-11-20T15:22:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![princess](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@princess](https://discourse.processing.org/u/princess)\
**Post date:** [November 20, 2020, 3:22pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567/1 "2020-11-20T15:22:07Z")

</div>

var colors;  
var type;

function setup() {  
createCanvas(windowWidth, windowHeight);

colors = [  
color(255, 0, 0),  
color(0, 255, 0),  
color(0, 0, 255)  
];

type = 0;  
}

function draw() {  
blendMode(BLEND);

if(type == 0) {  
background(255);  
blendMode(EXCLUSION);  
} else {  
background(0);  
blendMode(SCREEN);  
}  
noFill();  
strokeWeight(20);  
for(var i = 0; i \< 3; i++) {  
stroke(colors[i]);  
beginShape();  
for(var w = -20; w \< width + 20; w += 5) {  
var h = height / 2;  
h += 200 \* sin(w \* 0.03 + frameCount \* 0.07 + i \* TWO\_PI / 3) \* pow(abs(sin(w \* 0.001 + frameCount \* 0.02)), 5);  
curveVertex(w, h);  
}  
endShape();  
}

}

function mousePressed() {  
if(type == 0) {  
type = 1;  
} else {  
type = 0;  
}  
}

---

<div class="post-metadata">

**Author:** ![princess](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@princess](https://discourse.processing.org/u/princess)\
**Post date:** [November 20, 2020, 3:24pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567/2 "2020-11-20T15:24:28Z")

</div>

So I know that things like “function” need to be switched to void and etc. I was able to change everything except the colors to be compatible with Processing 3. If someone knows how to keep the colors alternating, I’d appreciate the help

---

<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:** [November 20, 2020, 3:33pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567/3 "2020-11-20T15:33:33Z")

</div>

```auto

//color colors;
color[] colors = {
  color(255, 0, 0), 
  color(0, 255, 0), 
  color(0, 0, 255)
};

int type;

void setup() {
  size(600, 600);
  type = 0;
}

void draw() {
  blendMode(BLEND);

  if (type == 0) {
    background(255);
    blendMode(EXCLUSION);
  } else {
    background(0);
    blendMode(SCREEN);
  }
  noFill();
  strokeWeight(20);
  for (int i = 0; i < 3; i++) {
    stroke(colors[i]);
    beginShape();
    for (int w = -20; w < width + 20; w += 5) {
      int h = height / 2;
      h += 200 * sin(w * 0.03 + frameCount * 0.07 + i * TWO_PI / 3) * pow(abs(sin(w * 0.001 + frameCount * 0.02)), 5);
      curveVertex(w, h);
    }
    endShape();
  }
}

void mousePressed() {
  if (type == 0) {
    type = 1;
  } else {
    type = 0;
  }
}

```

---

<div class="post-metadata">

**Author:** ![princess](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@princess](https://discourse.processing.org/u/princess)\
**Post date:** [November 20, 2020, 3:39pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567/4 "2020-11-20T15:39:17Z")

</div>

Thank you so much! It works perfectly:3

---

<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:** [November 20, 2020, 4:18pm UTC](https://discourse.processing.org/t/make-older-processing-code-compatible-with-processing-3/25567/5 "2020-11-20T16:18:56Z")

</div>

Hello,

> **[learn | p5.js](https://p5js.org/learn/)**

Links to:  
[Processing transition](https://github.com/processing/p5.js/wiki/Processing-transition)

`:)`
