//************************************************ //******* initial essential variables ************ //************************************************ //******* pixels are set as numbers (10, 55, 450) //******* color values are set in greyscale by setting a number between 0 = black, to 255, white. //******* if you want rgb values, then set them in this manner (255,0,0) . That would produce red. boolean saveImage = false; //if set to true, a png will be created with your grid in the sketch's folder as soon as you run it. Test the variables, then once it's ready, set it to true. //after you run your program, just go to the top menu to SKETCH -> Show Sketch Folder -> and there you will find the .png file int docWidth = 1024; //width of the image to save (pixels) int docHeight = 800; //height of the image to save (pixels) int docBackground = 255; //document background color. default is white. int colWidth = 50; //the desired width of all the vertical columns. int colMarWidth = 20; //the margin that should separate the vertical columns. int endsAt = 960; //at which width does your grid end (pixels) int colBorderColor = 155; // int colFillColor = 230; int rulerBackground = 240; boolean horizontalAsCol = false; //if set to true, horizontal lines will be displayed at the same distance as the width of the columns. Creating squares. Turned off by default, the lines are drawn in golden ratio. boolean showSquares = false; //if you want a grid of squares displayed on the whole image int squareSize = 10; //square dimensions in pixels int squareColor = 210; //how dark the squares should be size(docWidth,docHeight); //the width and height of the document. And also of the final output image background(docBackground);//255 white -> 0 black. If you can, don' mess around with your background color too much int aurea;//don't touch this block of code int separation; if(!horizontalAsCol){ aurea = colWidth * 11 / 17; separation = colWidth + colMarWidth; }else{ aurea = colWidth; separation = colWidth + colMarWidth; } //********* draw the colums ***********// fill(colFillColor); //stroke(colBorderColor); noStroke(); for(int k=0; k<=width; k+=separation){ rect(k,20,colWidth,height); } //********* draw squares ************// if(showSquares){ stroke(squareColor); for(int a =0;a<=width;a+=squareSize){ for(int b=0;b<=height;b+=squareSize){ line(a,0,a,height);//vertical lines line(0,b,width,b);//horizontal } } } //----------------------- //top ruler area //----------------------- fill(rulerBackground); noStroke(); rect(0,0,width,20); //bottom border rect top stroke(160); line(0,20,width,20); //lines top every 5 pixels for(int i=0; i<=width; i+=5){ line(i,0,i,10); } //lines top every 10 pixels stroke(100); for(int j=0; j<=width; j+=10){ line(j,0,j,15); } //------------------------- //horizontal lines at aurea height //------------------------- for(int l=aurea;l<=height;l+=aurea){ stroke(180); line(0,l,width,l); stroke(200); line(0,l+colMarWidth,width,l+colMarWidth); stroke(200); line(0,l-colMarWidth,width,l-colMarWidth); } //------------------------- //line at the end of the 960 px //------------------------- stroke(100); strokeWeight(1); line(endsAt,0,endsAt,height); //-------------------------- //saving the file //-------------------------- String fileWidth = str(colWidth); String filename = "grid_every_"+fileWidth+".png"; if(saveImage){ println("i am true - "+filename); save(filename); }