# Pj.5s code into Processing code

**URL:** https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088
**Category:** Libraries
**Created:** [December 9, 2022, 2:44am UTC](https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088 "2022-12-09T02:44:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![asymmetric](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/asymmetric/32/16577_2.png) [@asymmetric](https://discourse.processing.org/u/asymmetric)
#### Post date: [December 9, 2022, 2:44am UTC](https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088/1 "2022-12-09T02:44:54Z")

</div>

How do I translate the following code into processing from pj.5s?

```auto
let y
let pins = []
////////////////////////////////////////////////////////////////////////////////////////////////////
OPC.slider("pins_num", 30, 1, 100)
OPC.slider("complexity", 3, 1, 10, 1)
OPC.slider("maximumHeight", 100, 10, 100)
parameterChanged = (variableName, value) => setup()
////////////////////////////////////////////////////////////////////////////////////////////////////
setup = () => {
  createCanvas(windowWidth, windowHeight)
  strokeWeight(.5)
  y = 0
  pins.length = 0
  for (let i = 0; i < pins_num; i++) {
    pins[i] = createVector(random(width), random(height))
  }
}
draw = () => {
  if (y < height) {
    beginShape()
    for (let x = 0; x < width; x++) {
      angle = pins.reduce((sum, p) => sum + complexity * atan2(p.y - y, p.x - x), 0)
      z = map(cos(angle), -1, 1, 0, maximumHeight)
      vertex(x, y + z)
    }
    vertex(width, height)
    vertex(0, height)
    endShape(CLOSE)
    y++
  }
}

```

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [December 9, 2022, 9:29am UTC](https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088/2 "2022-12-09T09:29:03Z")

</div>

Hi @asymmetric,

> [@asymmetric](#):
>
> How do I translate the following code into processing from pj.5s?

Processing and p5js have a similar API and function signatures so translating between one and another shouldn’t be too complicated (unless you use fancy language feature either in JavaScript or Java).

> [@asymmetric](#):
>
> `OPC.slider("pins_num", 30, 1, 100)`

The thing that might be different is if you use JavaScript libraries. You need to code it yourself or find an equivalent in Java.

What is `OPC` referring to?

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [December 10, 2022, 10:58am UTC](https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088/3 "2022-12-10T10:58:21Z")

</div>

2 posts were split to a new topic: [Processing code into p5.js code](https://discourse.processing.org/t/processing-code-into-p5-js-code/40105)

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [December 10, 2022, 11:05am UTC](https://discourse.processing.org/t/pj-5s-code-into-processing-code/40088/4 "2022-12-10T11:05:48Z")

</div>

`OPC` refers to the [OpenProcessing Configurator](https://github.com/msawired/OPC) library:

> “a helper library that allows sketches on OpenProcessing to provide a UI to play with dynamic variables in their sketches”

The closest to OPC in Processing Java would be ControlP5. Porting from one to the other would require some work.
