Inversely ellipses

How to draw ellipses like this ( using for or while)

Let’s say you use a for loop

for(.....) {

}

Inside the for loop is one ellipse command with ellipse(x,y,6,6);

define x and y before setup (): float x,y;

Now how do you need to change x and y inside the for loop to get the result you want?

Please post your entire code. Then we can help you further.

Thank you.

Regards,

Chrisir

2 Likes

The math:
What is the equation to a straight line?
The axes are not well labelled; is that a point at (4,3) and (13, 17)?
They do look equally spaced but not a well defined origin.

The plot:
Processing references are helpful.
https://processing.org/reference/
https://processing.org/tutorials/

As a new programmer or new to Processing I encourage you to look at references and tutorials to glean some insight and understanding, think about it and then write code yourself from scratch.

:slight_smile:

3 Likes

how to draw many ellipse in proportional(using for or while)
i aslo can draw like this

void setup(){
size(300,300);

for (int i = 10;i <300;i = i+70){

ellipse(i,100,15,15);}
}

these ellipse can make proportional
please help
void setup(){
size(300,300);

for (int i = 10;i <300;i = i+70){

ellipse(i,100,15,15);}
}

If you kindly look at my post and follow my advice

1 Like

or say … i<10; i = i + 1) {

and manage the rest with x and y as shown

1 Like

dear sir
i am very new
and i tried to manage x,y, but still not success

only i can draw horizontal an vertical…but i want proportional
thank you for helping

Change x AND y

See my first post

Then show your entire code

1 Like

Yes I get it… thank you very much @Chrisir
@glv :slightly_smiling_face:

Preformatted texthow to put numbers this graph

Preformatted text`void setup(){
  size(600,600);
  background(190);
  for(int i = 30 ;i <580;i=i+20){
    line(i,30,i,570);
    line(30,i,570,i);
   
    
  }
  strokeWeight(2);
    line(30,570,570,570);
    line(30,30,30,570);}
  void draw(){
    textSize(24);
    text("Y",10,35);
    text("x",570,590);
    noStroke();
    fill(200,0,0);
    ellipse(570,570,10,10);
    ellipse(30,30,10,10);
  }

pls first you need to learn how to post code here at the forum:
from the post editor use the

</> code tag

looks like:

```
type or paste code here
```

please repair above code this way, and only PASTE good formatted code only:
in IDE use [ctrl][t] for this.


what is the question here?
are you talking about the numbers for the X and Y axis?

Ya I want write X and Y number

Thank you very much for helping
Now see the code

Preformatted text`void setup(){
  size(600,600);
  background(190);
  for(int i = 30 ;i <580;i=i+20){
    line(i,30,i,570);
    line(30,i,570,i);
   
    
  }
  strokeWeight(2);
    line(30,570,570,570);
    line(30,30,30,570);}
  void draw(){
    textSize(24);
    text("Y",10,35);
    text("x",570,590);
    noStroke();
    fill(200,0,0);
    ellipse(570,570,10,10);
    ellipse(30,30,10,10);
  }

Start draw () with a call of background - see reference.

In the tutorials read the first three text tutorials. Skip the videos for now

Do all drawings in draw().

For the ellipses use a for loop as I described. Write ellipse only once in the for loop - not like you have it now.

Make 2 other for loops in draw to write the numbers at the lines

sorry, but why you post the code 2 times, and why you

    • not format it in processing
    • not format it here as code

as i told you?

it should look like:

int off = 30, dgrid = 20, scale = 2*dgrid;

void setup() {
  size(600, 600);
}

void axis() {
  textSize(15);
  stroke(255);
  strokeWeight(1);
  for (int i = off; i <= width - off; i += dgrid) {
    line(i, off, i, width - off);
    line(off, i, height - off, i);
  }
  fill(200, 0, 0);
  stroke(200, 0, 0);
  text("X", 580, off-4);
  text("-Y", 10, 595);
  for ( int k = 0; k <= (width - 2*off)/scale; k++ ) {
    line(off + k*scale, off, off + k*scale, off -2);
    text( k, off-4 + k*scale, off -4 );
    line( off, off + k*scale, off-2, off + k*scale);
    text( k, 10, off+4 + k*scale);
  }
}

void circles() {
  int d = 30, x0 = 20, dx = 4*x0 ;
  stroke(200,200,0); //noStroke();
  noFill(); //fill(200, 200, 0);
  for ( int l = x0; l <  width-off-d; l +=dx ) ellipse(off + l, off + l, d, d);
}

void draw() {
  background(0);
  axis();
  circles();
}

1 Like

wow nice thank you so much
how to change that ellipse 13y to 13x

What do you mean?

Chrisir

I mean who can draw ellipses like that
Using(

for)