Parabolic Curve

I’m new to coding and processing. I have no idea how to begin this code, I wonder how I should start? This what I need to get below.

please format code with </> button * homework policy * asking questions

There are several ways to approach this …

I can see the same shape repeated again and again – that quarter-circle curve formed from straight lines. If you can get one of these right, you might repeat it (maybe define a function to draw a quarter-circle curve) and rotate & position it using Processing’s transform functions.

* When you ask a question, try to think of some approach; this is programming, and there are many ways to tackle a problem. Even better, provide a little code you’ve started on.

1 Like

Okay Thank you! I’m learning and I’m not aware of all the serval ways. I haven’t started a code but I’ll show you my progress. I’m going to get started!

2 Likes

Hello @bopStu77,

There are resources (tutorials, references, examples. etc.) here:
https://processing.org/

I always think through a problem without even writing a line of code.

I encourage you as a new programmer to make a sincere effort to write your own code with out the influence of someone else’s work or solution.

Glean insight where needed (references, simple examples) and then write your code!

Your efforts will be rewarded in the long run.

To get you started:
Coordinate System and Shapes \ Processing.org

:)

Absolutely the way to go especially in this example because as previously mentioned

This image might make it clearer.

So design an algorithm to do this, translate it to code and then you will be well on the way to making the full picture.

1 Like

Hey! So this what I have so far guys, what are the next steps

void setup() {
size(600,600);
background(255);

}

void draw() {
stroke (0);
line(width/2,0,width/2,height);
line(0,height/2,width,height/2);
line(width/2,0,280,height/2);
line(width/2,30,250,height/2);
line(width/2,50,220,height/2);
line(width/2,70,190,height/2);
line(width/2,90,170,height/2);
line(width/2,110,150,height/2);
line(width/2,130,130,height/2);
line(width/2,150,110,height/2);
line(width/2,170,80,height/2);
line(width/2,190,50,height/2);
line(width/2,210,30,height/2);
line(width/2,230,0,height/2);
line(width/2,250,0,height/2);
line(width/2,270,0,height/2);
}

When you compare the original sketch to what you see in your current sketch, what can you imagine the the next step would be?

In other words, can you write down in a couple of sentences what is happening with the module you’ve created to how it appears in the original sketch?
The process of doing this will help guide you to the next step…
:nerd_face:

1 Like

Hello,

Please format code properly:
https://discourse.processing.org/faq#format-your-code

Look for patterns, sequences and repetition in your code:

line(width/2,   0, 280, height/2);
line(width/2,  30, 250, height/2);
line(width/2,  50, 220, height/2);
line(width/2,  70, 190, height/2);
line(width/2,  90, 170, height/2);
line(width/2, 110, 150, height/2);
line(width/2, 130, 130, height/2);
line(width/2, 150, 110, height/2);
line(width/2, 170,  80, height/2);
line(width/2, 190,  50, height/2);
line(width/2, 210,  30, height/2);
line(width/2, 230,   0, height/2);
line(width/2, 250,   0, height/2);
line(width/2, 270,   0, height/2);

:)

What I’m wondering is how I can get this sketch’s code to turn around and create that reflection like the sketch above?

when you look at your lines,

  • x-from is constant width/2, y-from is increasing and
  • x-to in decreasing, and y-to is constant height/2

repeat for all 4 corners and change for each corner

You can reflect horizontally and vertically using scale(-1, 1) and scale(1, -1), respectively. You use the translate() function to reposition the drawing space. For example –

// draw the line at the top left
line(width/2, 0, 0, height/2);

// draw the line at the top right
scale(-1, 1);
translate(-width, 0);
line(width/2, 0, 0, height/2);
resetMatrix();

// draw the line at the bottom right
scale(-1, -1);
translate(-width, -height);
line(width/2, 0, 0, height/2);
resetMatrix();

Of course, you want to draw many lines to form each curve (not one line), so it’ll help to define a function.