# [Java] An Introduction to Programming for College Students: Various Functions for Rectangle (Part 2)

• With Qiita, it is difficult to print only the text part. Therefore, the same contents are also posted on the following pages. If you want to print out or convert to PDF, please use this page:

http://gurakura.sakura.ne.jp/hellomondrian/rect3/

Click here for a list: http://gurakura.sakura.ne.jp/series/ Introduction to programming for art students/

# How to draw a crippled rectangle

By the way, this section ends with an introduction to how to draw a non-free rectangle, as opposed to a free rectangle. I think there are various ways to define a non-free quadrangle, but here I would like to take up a square as a quadrangle that has the same shape (=similarity) regardless of who draws it, and has little freedom.

Draw a square with the square function. The argument is square(x,y,l). x,y is the upper left position of the square and l is the side length.

Note: By the way, the reference position indicated by (x,y) can be changed with the rectMode function.

background(250,250,250);
size(500,500);

strokeWeight(10);
stroke(0,64,255);
fill(255,0,0);
square(100,50,200); The rect function can be represented using the quad function. You can also use the rect function to represent the square function. The rectangle drawn by rect(x,y,w,h) is the vertex of (x,y), (x+w,y), (x+w,y+h), (x,y+h) Is configured. So rect(x,y,w,h) is

quad(x,y, x+w,y, x+w,y+h, x,y+h)


Can be expressed as Similarly, square(x,y,l) also becomes

rect(x,y,l,l)


Can be expressed as well, which of course can be expressed with the quad function:

quad(x,y, x+l,y, x+l,y+l, x,y+l)


In this way, the same expression can be written in various codes in programming. Therefore, the individuality of the author (=programmer) appears in the source code.

For those who don’t know programming, programming may seem like a dry process, but it’s actually an act of showing individuality.

# Comp-Position in Color α

Looking closely at Mondrian’s Composition in Color A, there is a red rectangle that overlaps the blue rectangle and there is a gap between it and the blue rectangle below. For example: This is an enlarged version of part of the figure given at the beginning of this chapter. How should a program like this be realized in a program?

Currently, the only technology we know is to draw a rectangle and a straight line. How can such an expression be realized only with this knowledge?

Is it possible to draw a red square system on a blue square without thinking and then draw a white line later?

Or should the bottom blue rectangle be split into two rectangles to draw an L-shaped rectangle (that is, drawn as a set of non-overlapping rectangles)?

I think there are various ways.

Actually, there is no correct answer for this problem, and if you get the desired result in any way, that is the correct answer.

I would like to finish this chapter by introducing how to draw a contour line with a rectangle drawn by the rect function, and how to express a gap with a contour line. Note that a program that uses Composition in Color A as a subject will appear later, so this time it is named in Color $\alpha$ to mean the alpha version.

// comp-position in Color alpha
background(250,245,230);
size(500,500);

strokeWeight(10);
stroke(250,240,240); // same as background
fill(0,80,160); // blue
rect(60,120, 200,150);

fill(220,60,20); // red
rect(230,70, 160,150);

noStroke();
fill(80,80,80); // black
rect(270,230,80,15); In this way, there is also a method that does not use the contour line as the contour line. In addition, when drawing a picture with Processing, it is necessary to be familiar with the various functions that Processing has, and what effects and expressions can be obtained by using them.

# Column: α version, β version

In the computer world, we often hear the words such as alpha version and beta version. What is this all about? The $\beta$ version (beta version) of software means that it is almost complete, but there are still some things to be fixed.

For network games, we call beta testing, where you actually play with almost completed software to find bugs, adjust the entire system, and evaluate server performance.

By the way, those with a degree of perfection that can be candidates for release (shipping = product version) are called Release Candidate, and abbreviations such as RC are used.

The alpha version (alpha version) means that it is before the beta, and it still requires work to be almost completed, but it means that it works reasonably well.

The comp-position in Color created above is still lacking compared to Mondrian’s Composition in Color A. However, I can still draw something like a picture, so I chose comp-position in Color $\alpha$ with the meaning of being an alpha version.

Tags:

Updated: