# Trying to target an area of square to apply noise function

**URL:** <https://discourse.processing.org/t/trying-to-target-an-area-of-square-to-apply-noise-function/30786>\
**Category:** Coding Questions\
**Created:** [June 18, 2021, 10:17pm UTC](https://discourse.processing.org/t/trying-to-target-an-area-of-square-to-apply-noise-function/30786 "2021-06-18T22:17:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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 19, 2021, 10:47am UTC](https://discourse.processing.org/t/trying-to-target-an-area-of-square-to-apply-noise-function/30786/4 "2021-06-19T10:47:38Z")

</div>

Hello,

This may be a better example… but still just a quick one.

I was not too confident in my tinkering with the other code (done very quickly!) and added some points (hints and actual points!) to help visualize what was being modified.

> **Example Code**
>
> ```auto
> ArrayList<PVector> square = new ArrayList<PVector>();
> 
> PShape s;
> 
> public void settings() 
> {  
> size(400, 400, P2D); 
> }
> 
> public void setup() 
> {
> //noLoop();
> 
> for(int x = 0; x < 10; x += 1) 
> {
> float y = x;  
> square.add(new PVector(x*10, y*10)); //Should be a diagonal line
> }
> 
> s = createShape();
> s.beginShape();
> s.fill(255, 0, 0);
> for (PVector v : square) {
> s.vertex(v.x, v.y);
> }
> 
> s.endShape(CLOSE);
> }
> 
> public void draw() 
> {
> background(255);
>   
> // vertices modified and displayed 
> for (int i = 0; i < s.getVertexCount(); i++) 
> {
> PVector v = s.getVertex(i);
> v.y += random(-1, 1);
> //v.y = random(-10, 10);
> s.setFill(color(255, 255, 0));
> s.setVertex(i, v);
>     
> // These help to see the modified vertices and NOT part of shape
> strokeWeight(5);
> stroke(255, 0, 0);
> point(v.x, v.y);
> }
>   
> // New modified shape
> s.setStrokeWeight(2);
> shape(s, 100, 100);
> }
> 
> ```

Once you get the hang of this you won’t be able to stop!

Some nuggets in here:  
_[PShape \ Language (API) \ Processing 3+](https://processing.org/reference/PShape.html)_

If you want to copy a PShape:  
_[Copying a PShape?](https://discourse.processing.org/t/copying-a-pshape/1081)_

`:)`

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

---

_[View the full topic](https://discourse.processing.org/t/trying-to-target-an-area-of-square-to-apply-noise-function/30786)._
