Points and Lines.

Points and Lines.

Points and lines can be used to draw basic geometry. Change the value of the variable ā€˜dā€™ to scale the form. The four variables set the positions based on the value of ā€˜dā€™.

 
int d = 70;
int p1 = d;
int p2 = p1+d;
int p3 = p2+d;
int p4 = p3+d;

size(640, 360);
noSmooth();
background(0);
translate(140, 0);

// Draw gray box
stroke(153);
line(p3, p3, p2, p3);
line(p2, p3, p2, p2);
line(p2, p2, p3, p2);
line(p3, p2, p3, p3);

// Draw white points
stroke(255);
point(p1, p1);
point(p1, p3); 
point(p2, p4);
point(p3, p1); 
point(p4, p2);
point(p4, p4);

Functions Used

stroke()

Sets the color used to draw lines and borders around shapes

Learn More
size()

Defines the dimension of the display window width and height in units of pixels

Learn More
point()

Draws a point, a coordinate in space at the dimension of one pixel

Learn More
noSmooth()

Draws all geometry and fonts with jagged (aliased) edges and images when hard edges between the pixels when enlarged rather than interpoloating pixels

Learn More
translate()

Specifies an amount to displace objects within the display window

Learn More
line()

Draws a line (a direct path between two points) to the screen

Learn More
background()

The background() function sets the color used for the background of the Processing window

Learn More