# Beginner having problems, for cycle, lines coordinates

**URL:** <https://discourse.processing.org/t/beginner-having-problems-for-cycle-lines-coordinates/23659>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [September 3, 2020, 1:57pm UTC](https://discourse.processing.org/t/beginner-having-problems-for-cycle-lines-coordinates/23659 "2020-09-03T13:57:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TabeaErre](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@TabeaErre](https://discourse.processing.org/u/TabeaErre)\
**Post date:** [September 3, 2020, 1:57pm UTC](https://discourse.processing.org/t/beginner-having-problems-for-cycle-lines-coordinates/23659/1 "2020-09-03T13:57:15Z")

</div>

Hi everybody, I’m very new to processing. I’m trying to finish this code, my uni professor told me I had to do a “for cycle” to draw all the lines using the coordinates. I don’t know how to do it, I’m stuck. Also after that the lines has to change according to a data that’s in the json file (the data is the co2kt level). How can I do it? How can I draw the lines from the coordinates and then associate it to his personal co2kt level? Thank you

The code:

PShape terra;  
PShape Albania;  
PShape Belgium;  
PShape Bulgaria;  
PShape Italy;  
// coordinate inizio e fine delle linee  
float[][] coordinateInizio = { {276, 303}, {226, 269},{300, 302}, {258, 311} };  
float[][] coordinateFine = { {581, 599}, {83, 599},{779, 437}, {408, 1} };

JSONObject json;  
JSONArray countries;  
JSONArray co2kt;  
int albania = 2; // indice del json  
int belgium = 18;  
int bulgaria = 28;  
int italia = 91;

void setup() {  
size(800, 600);  
json = loadJSONObject(“daviz.json”);  
countries = json.getJSONArray(“items”);  
co2kt= json.getJSONArray (“co2kt”);

println(countries.getJSONObject(2).getFloat(“co2kt”));  
println(countries.getJSONObject(18).getFloat(“co2kt”));  
println(countries.getJSONObject(28).getFloat(“co2kt”));  
println(countries.getJSONObject(91).getFloat(“co2kt”));

terra = loadShape(“terra.svg”);  
Albania = terra.getChild(“Albania”);  
Belgium = terra.getChild(“Belgium”);  
Bulgaria = terra.getChild(“Bulgaria”);  
Italy = terra.getChild(“Italy”);  
//co2kt = terra.getChild (“co2kt”);

}  
void draw() {  
background (255,255,255);  
shapeMode (CORNER);  
shape(terra, 0, 0,800,600);  
strokeWeight(10);

}

---

<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:** [September 3, 2020, 3:24pm UTC](https://discourse.processing.org/t/beginner-having-problems-for-cycle-lines-coordinates/23659/2 "2020-09-03T15:24:28Z")

</div>

Task not clear.

Is the length of the line representing something? Is it on a map?

Can you post the json file content
