# PVector array filled with static data

**URL:** <https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282>\
**Category:** Beginners\
**Created:** [June 25, 2019, 11:14am UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282 "2019-06-25T11:14:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [June 25, 2019, 11:14am UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282/1 "2019-06-25T11:14:41Z")

</div>

Hi team,

I have an issue regarding the correct way to assign PVector data in an array.  
the data is derived from earlier task (see image and code below), i only want to us the output as a PVector in an array (static coded).

picture used in datafolder:

 ![wind_32sc_0to6](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f2661ce89fe5c1a7c4fb78eaebccb42868314548.jpeg)

resulting array that is desired to be used in other sketch:  
[30.0, 50.0, 136.0] [39.0, 60.0, 149.0] [47.0, 68.0, 159.0] [53.0, 76.0, 169.0] [58.0, 84.0, 177.0] [66.0, 95.0, 187.0] [87.0, 126.0, 195.0] [104.0, 151.0, 203.0] [118.0, 174.0, 211.0] [130.0, 192.0, 217.0] [142.0, 202.0, 213.0] [148.0, 206.0, 194.0] [154.0, 208.0, 172.0] [163.0, 209.0, 147.0] [169.0, 213.0, 115.0] [187.0, 220.0, 107.0] [207.0, 229.0, 102.0] [223.0, 238.0, 97.0] [239.0, 246.0, 91.0] [252.0, 250.0, 88.0] [253.0, 222.0, 82.0] [253.0, 190.0, 77.0] [254.0, 151.0, 72.0] [255.0, 100.0, 62.0] [251.0, 91.0, 59.0] [247.0, 82.0, 52.0] [243.0, 72.0, 46.0] [240.0, 59.0, 38.0] [213.0, 54.0, 35.0] [179.0, 47.0, 32.0] [141.0, 38.0, 31.0] [84.0, 28.0, 29.0]

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/1/16b05d576782819e4d828096734c2abb8b696370.png)

i tried variations of PVector colorLegendWind [] = [30.0, 50.0, 136.0] [39.0, 60.0, 149.0] [47.0, 68.0, 159.0] [ 5…

knowing it is wrong, hope a hint can be given.

snippet:

```auto
float x1;
PImage img;
float editr;
PVector colorLegendWind [] = new PVector[32];
//PVector colorLegendWind []= new PVector {( 1,2,3) (1,2,3)}; 
//PVector colorLegendWind []= ( 1,2,3) (1,2,3); 

void setup(){
 size(1000,900); 
 
// colorLegendWind= [( 30.0, 50.0, 136.0 ) ( 39.0, 60.0, 149.0 )] ;
 
 
 
 img = loadImage("wind_32sc_0to6.JPG");
 x1= 162;
 y1= 865;
 y2= 110;
  editr= (y1-y2)/31;
  
}
  
  void draw(){
   background(255); 
    
    image(img,0,0);
    img.loadPixels();
    //println(mouseX,mouseY);
    
    for (int i=0;i<32; i++){
      
      stroke(255);
      strokeWeight(5);
      point(x1,y1-i*editr);
      color c = get(int(x1+5), int(y1-i*editr));
      //println(red(c),green(c),blue(c));
      colorLegendWind[i]= new PVector(red(c),green(c),blue(c));
      
    }
print( colorLegendWind);
noLoop();
}
```

---

<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:** [June 25, 2019, 2:41pm UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282/2 "2019-06-25T14:41:10Z")

</div>

Hey,

Can you post your code in plain text by pressing `Ctrl+T` in the Processing IDE then use the `</>` button on the forum to insert it so people can use your code and understand it.

---

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [June 25, 2019, 2:51pm UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282/3 "2019-06-25T14:51:18Z")

</div>

Thank you for pointing out,

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 25, 2019, 3:12pm UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282/4 "2019-06-25T15:12:06Z")

</div>

If you want to create an array w/ its elements already initialized at the same time its variable is declared, we need to use curly braces `{}` in Java: ☕

`PVector[] vecs = { new PVector(), new PVector(PI, TAU), PVector.random3D(this) };`

If the variable already exists and you wanna assign an already filled array to it, you’re gonna need to use the operators `new` & `[]` as well: 🤓

```auto
PVector[] vecs;
vecs = new PVector[] { new PVector(), new PVector(PI, TAU), PVector.random3D(this) };

```

---

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [June 25, 2019, 3:32pm UTC](https://discourse.processing.org/t/pvector-array-filled-with-static-data/12282/5 "2019-06-25T15:32:54Z")

</div>

Thank you for pointing out that that is the way forward. Was afraid detailed declaration is needed in order to make it work. But very happy knowing how to continue. Thank you. Mr GotoLoop
