Make a shape with diagonal lines?

edited October 2015 in How To...

I'm trying to fill a shape with coloured diagonal stripes. Can any one help? I've attached pictures to show what i need. :)>-

blue stripes

red stripes

yellow stripes

Tagged:

Answers

  • How are you drawing the shapes? You could use a stepped texture and the vertex (x, y, u, v) call but it depends what you are doing.

    Alternatively mask () might work or even a custom seed fill (non-real-time).

  • I'm using beginShape() and endShape().

  • Please be more specific about your question. As koogs already stated, texture() should do the job. Did you have a look?

    If you are still stuck, please tell us what does not work and maybe show a code-example.

    Regards.

  • Answer ✓
    PGraphics st;
    
    void setup() {
      size(300, 300, P2D);
      st=createGraphics(width, height, P2D);
      st.beginDraw();
      st.noStroke();
      st.fill(0,255,0,255);
      st.rotate(-.666);
      for (int i=0; i<50; i++) {
        st.fill(255*(i%2),255,0,255);
        st.rect(-300, i*10, 600, 10);
      }
      st.endDraw();
    }
    
    void draw() {
      background(255,0,0);
      stroke(0);
      strokeWeight(4);
      beginShape();
      texture( st.get() );
      vertex(100, 100, 100, 100);
      vertex(100, 200, 100, 200);
      vertex(200, 200, 200, 200);
      vertex(200, 100, 200, 100);
      vertex(150, 50, 150, 50);
      endShape(CLOSE);
    }
    
Sign In or Register to comment.