# I can't make my lorenz attractor balls opaque help pls

**URL:** https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599
**Category:** Coding Questions
**Created:** [June 14, 2024, 10:40pm UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599 "2024-06-14T22:40:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mayara](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mayara](https://discourse.processing.org/u/mayara)
#### Post date: [June 14, 2024, 10:40pm UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599/1 "2024-06-14T22:40:40Z")

</div>

I want to make the balls in this code opaque but whenever I try the balls stop appearing  
help plssssssssss im going crazyyyyy 😧 😧 😭 😭 😢 😖 😖

\<let o = 10;  
let p = 28;  
let b = 8 / 3;

const num = 100;  
const intertemp = 35 \* 30;  
let a = ;

function setup() {  
createCanvas(windowWidth, windowHeight, WEBGL);  
blendMode(ADD);

```
nLorenz();

```

}

function nLorenz() {  
for (let i = 0; i \< num; i++) {  
a.push(new Lorenz(random(-1, 1), random(-1, 1), random(-1, 1)));  
}  
}

class Lorenz {

```
constructor(x, y, z) {
	this.pos = createVector(x, y, z);
	this.dV = createVector(0, 0, 0);
}

calcula(t) {
	this.dV.set(
		this.pos.x + t * o * (this.pos.y - this.pos.x),
		this.pos.y + t * (this.pos.x * (p - this.pos.z) - this.pos.y),
		this.pos.z + t * ((this.pos.x * this.pos.y) - (b * this.pos.z))
	);
	this.pos.set(this.dV);
}

draw() {
	push();
			
	translate(this.pos.x * 5, this.pos.y * 5, (this.pos.z - 25) * 5);
	sphere(1); // raio das bolota
	pop();
}

```

}  
function draw() {  
background(0);

```
if (frameCount % intertemp === 0) {
	a = [];
	nLorenz();
}

for (let i = 0; i < num; i++) {
	a[i].calcula(0.01);
	a[i].draw();
}

```

}\>

---

<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: [June 14, 2024, 11:46pm UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599/2 "2024-06-14T23:46:19Z")

</div>

Hello @mayara,

Welcome.

Please read:  
_[Guidelines—Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147)_

You did not format your code correctly.

What is the source of this code?

Hints only:

- _[reference | p5.js](https://p5js.org/reference/#/p5/fill)_ \< Add some color with opacity to the sphere.
- Remove the _background()_
- Make the sphere larger and remove the stroke.
- Add the end of _draw()_ overlay the the entire sketch window with a _rect()_ that is black and also has opacity.

Experiment a little with above to achieve desired results.

I did the above to achieve this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/5/754209362c273784f9c29229097cbec75589991c.png)

It looks much better live than in a screen grab.

`:)`

---

<div class="post-metadata">

### Author: ![mayara](https://avatars.discourse-cdn.com/v4/letter/m/ecb155/32.png) [@mayara](https://discourse.processing.org/u/mayara)
#### Post date: [June 15, 2024, 12:22am UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599/3 "2024-06-15T00:22:10Z")

</div>

I’m sorry, but I didn’t understand correctly. when I tried to do what you said, my attractor got a little weird.

sorry for having the wrong code format and about where the code is from, I saw a lorenz attractor in the processing search tab and tried to do it

 ![atratorfeio](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/f/cf0cfd8f2bb6333d9ad0cb7de0348427c897822e.png)

---

<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: [June 15, 2024, 1:10am UTC](https://discourse.processing.org/t/i-cant-make-my-lorenz-attractor-balls-opaque-help-pls/44599/4 "2024-06-15T01:10:37Z")

</div>

Hello again!

```auto
  fill(255, 255, 0, 128); //yellow and opacity 128
  noStroke();
  sphere(3); // raio das bolota

```

At the end of _function draw()_:

```auto
function draw() {
//background(0);

// Your code...

fill(0, 10); //black and opacity 10
rectMode(CENTER);
rect(0, 0, width, height);
}

```

Always _fill()_ before the shape!

My background was black so that is why I chose black… you may have to change things on your end.

Experiment a little… I was just playing around with this and was done very quickly.

You can always go back and edit your code… as a new user you may have some limitations and have to wait a day.

This will be off the screen:  
`rect(windoWidth, windowHeight, windoWidth, windowHeight);`

I suggest you visit the p5.js web page for tutorials, examples and references and it also has an editor:

> **[home | p5.js](https://p5js.org/)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

In the p5.js editor on web page I added this to function _setup()_ so it was initially black:  
`background(0);`

I was using the Processing p5 mode editor initially.

This was in the p5.js editor with my suggested code changes:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/4/344655db812cc322db45d2ce777d7148bbf5085a.png)

`:)`
