edited May 2017 in General

Sorry to ask but i have a question....i'm a little bit new to processing and doing a project for school but what i need to do is do a pattern function in processing, can anyone help, it would really mean alot


  • What kind of pattern? What have you tried? Do you have any resources to share like pics or links?


  • void pattern() {


    This is a function called pattern. It doesn't do anything. Did you want it to do something? What have you tried to get it to do already? Post your current code. If you have none, attempt to write some (or even just the steps you hope to take) (or even a blank sketch that does nothing) and post that.

    Also post some idea of what you expect it to do.

  • what i kinda want is that you have a random object just repeating itself all over the screen then when you click on the mouse it changes either with size or just changes to a different object

  • Screen Shot 2017-05-01 at 5.20.11 PM something like this

  • Answer ✓

    Partial demo below.


    //Instructions: Move mouse on sketch to change size
    //              Click on sketch to change shape
    final int stepx=100;
    final int stepy=stepx;
    final int maxSize=stepx;
    final int kSquares=0;
    final int kCircles=1;
    final int kEllipses=2;
    int figureType=kSquares;
    int sx, sy;
    void setup() {
      size(400, 600);
      ellipseMode(CENTER);  //Default btw
    void draw() {
      fill(0, 255, 0);
      for (int i=stepx; i<width; i+=stepx) {
        for (int j=stepy; j<height; j+=stepx) {
          if (figureType==kSquares) {
            sx=(int)map(mouseX, 0, width, 0, maxSize);
            rect(i, j, sx, sy);
          if (figureType==kCircles) {
            sx=(int)map(mouseX, 0, width, 0, maxSize);
            ellipse(i, j, sx, sy);
          if (figureType==kEllipses) {
            sx=(int)map(mouseX, 0, width, 0, maxSize);
            ellipse(i, j, sx, sy/2.0);
    void mouseReleased(){
  • grids. search for grids.

    two nested for loops, rows and columns.

    ellipse(), rect()

  • thanks a lot

Sign In or Register to comment.