# Creating woven patterns ... beginner

**URL:** <https://discourse.processing.org/t/creating-woven-patterns-beginner/16788>\
**Category:** Coding Questions\
**Created:** [January 1, 2020, 8:41pm UTC](https://discourse.processing.org/t/creating-woven-patterns-beginner/16788 "2020-01-01T20:41:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee14](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@Lee14](https://discourse.processing.org/u/Lee14)\
**Post date:** [January 1, 2020, 8:41pm UTC](https://discourse.processing.org/t/creating-woven-patterns-beginner/16788/1 "2020-01-01T20:41:51Z")

</div>

I am looking to create a sketch which draws a woven pattern … that is, mimics woven cloth … so with warp and weft. I would like to do it, as a beginner coder, using pixels to draw it … but am a bit confused. I have been able to get a criss-cross pattern in x and y directions, but not to do the over-under weft thing. I imagine i need to ‘get’ the pixel color as in 'if green then each 2nd one make green (to show gong under) … hmmmmm.

---

<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:** [January 1, 2020, 9:17pm UTC](https://discourse.processing.org/t/creating-woven-patterns-beginner/16788/2 "2020-01-01T21:17:49Z")

</div>

Hello and welcome to the forum!

> [@Lee14](#):
>
> if green then each 2nd one make green

you can use get() to get the color of a pixel - see reference

Use it with 2 parameters (x,y) to get the color of ONE pixel

> **[get() / Reference](https://www.processing.org/reference/get_.html)**
>
> Reads the color of any pixel or grabs a section of an image. If no parameters are specified, the entire image is returned. Use the x and y parameters to get the value of one pixel. Get a…

(there will be a certain amount of pixels where == won’t work because of anti-alising, ignore this first)

**Remark**

so

```auto
if (get(x,y) == green) {
   each 2nd one make green
}

```

_make green_ or maybe just draw nothing at this position, then you would just leave the color already drawn at this position visible.

**Remark 2**

```auto
each 2nd

```

you could do this like :

before setup() :

boolean isFirstRow = true;

in your function:

```auto
if(isFirstRow) {
    // is true !!! 
    // draw green
    isFirstRow=false; // toggle 
} else 
{
    //draw red or so
    isFirstRow=true; // toggle 
}

```

Show your entire code to get more help

Regards, Chrisir

---

<div class="post-metadata">

**Author:** ![Lee14](https://avatars.discourse-cdn.com/v4/letter/l/b19c9b/32.png) [@Lee14](https://discourse.processing.org/u/Lee14)\
**Post date:** [January 2, 2020, 10:17am UTC](https://discourse.processing.org/t/creating-woven-patterns-beginner/16788/3 "2020-01-02T10:17:25Z")

</div>

Thanks Chrisir!! I will check it out!!

best,

Lee

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [January 2, 2020, 1:42pm UTC](https://discourse.processing.org/t/creating-woven-patterns-beginner/16788/4 "2020-01-02T13:42:54Z")

</div>

As a beginner you might also be interested in the WOVNS examples (designed to create patterns that you get can woven) [http://www.wovns.com/tutorials/designing-computational-textiles-with-processing/](http://www.wovns.com/tutorials/designing-computational-textiles-with-processing/). Not exactly what you were requesting, but quite interesting.
