{"id":3049,"date":"2019-04-24T15:44:44","date_gmt":"2019-04-24T19:44:44","guid":{"rendered":"https:\/\/itp.nyu.edu\/adjacent\/issue-5\/?p=2546"},"modified":"2019-04-24T15:44:44","modified_gmt":"2019-04-24T19:44:44","slug":"bauhaus-and-code-part-ii","status":"publish","type":"post","link":"https:\/\/itp.nyu.edu\/adjacent\/hidden\/bauhaus-and-code-part-ii\/","title":{"rendered":"Bauhaus and Code Pt. II"},"content":{"rendered":"<p><\/p>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-5\/wp-content\/uploads\/sites\/10\/2019\/04\/davidbinyan-01.jpg\" alt=\"An image of a bauhaus designed building with a yellow outline\" class=\"wp-image-2175\" \/><\/figure>\n\n\n<p><\/p>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h1 class=\"wp-block-heading\">Bauhaus and Code Pt.2<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"mce_20\">By Dav\u00edd Raphael Lockard<\/h2>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>&#8220;The investigation should proceed in a meticulously exact and pedantically precise manner. Step by step, this &#8220;tedious&#8221; road must be traversed \u2014 not the smallest alteration in the nature, in the characteristics, in the effects of the individual elements should escape the watchful eye.&#8221; (p.21)<\/em> <\/p><\/blockquote>\n\n\n\n<p>As a point of reference, we will be using Vasily Kandinsky&#8217;s pedagogical writing &#8211; as it is interestingly suited for transposition onto digital drawing. Kandinsky was a central teacher at the Bauhaus. He used his experiences teaching the preliminary course to write the book <em>Point and Line to Plane<\/em> &#8211; an attempt at formulating a systematic approach to painting. The quotes are all taken from this book. <\/p>\n\n\n\n<p>This tutorial is designed for people with no previous experience programming. If you have coded before, you are more than welcome to join along. This is the moment to suggest you settle deeper into your seat and make sure to be using a computer with a keyboard rather than a mobile device.    <\/p>\n\n\n\n<p>One important thing before we start: If this tutorial grabs your interest, you are warmly encouraged to visit <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/p5js.org\/\" target=\"_blank\">P5.js<\/a>, an amazing resource for taking ones first steps in creative coding. This tutorial relies deeply on the amazing tools and methodologies built by the P5 community, and is inspired by its ethos. For robust and welcoming tutorials, you are warmly encouraged to visit <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.youtube.com\/channel\/UCvjgXvBlbQiydffZU7m1_aw\" target=\"_blank\">Dan Shiffman\u2019s<\/a> online videos, to which this tutorial is heavily indebted. P5 was created by <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"http:\/\/lauren-mccarthy.com\/\" target=\"_blank\">Lauren McCarthy<\/a> and developed by a community of collaborators, with support from the<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"http:\/\/processing.org\/foundation\/\" target=\"_blank\"> Processing Foundation<\/a> and<a href=\"http:\/\/itp.nyu.edu\/itp\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\"> NYU ITP<\/a>.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Environment <\/h3>\n\n\n\n<p>There is a wide variety of programming languages. Different ones are good for different needs, but the underlying logic of all programming languages is for all intents and purposes the same. We will be learning Javascript, which is a language a lot of the internet is built in.<\/p>\n\n\n\n<p>We will be learning it through a library called P5. For now, just think of library as a sort of dialect &#8211; P5 is a dialect of Javascript. It is well suited for people who think visually. <\/p>\n\n\n\n<p>As we were saying earlier, the grey window below is an editor, in which one can both write programs &#8211; on the left side &#8211; and execute them, on the right. (Thanks to <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/toolness\" target=\"_blank\">Atul Varna<\/a> for creating this <a href=\"https:\/\/toolness.github.io\/p5.js-widget\/#wordpress\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">embeddable editor<\/a>.)<\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n<pre>\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h3 class=\"wp-block-heading\">1. The Point <\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>The point is the result of the initial collision of the tool with the basic plane. Paper, wood, canvas, stucco, metal \u2014 may all serve as this basic plane. The tool may be pencil, burin, brush, pen, etching-point, etc. The basic plane is impregnated by this first collision. (p. 27)<\/em><\/p><\/blockquote>\n\n\n\n<p>To examine this \u2018basic collision\u2019 on an interactive digital surface, let&#8217;s start with learning to write a program like the one below: a rectangle that follows your mouse. In doing so, we will experiment with <em>functions<\/em> and <em>variables<\/em> &#8211; two key terms in programming.  <\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_44\">2. createCanvas and background<\/h3>\n\n\n\n<p><strong>Functions<\/strong> are building blocks that carry out tasks. A large part of coding is learning to write your own functions. But at first we will be using a few functions that come \u2018ready to use\u2019 in p5. Our first two functions will generate our surface &#8211; or canvas as it is called in P5 &#8211; and give it color:<\/p>\n\n\n\n<p><em>createCanvas<\/em> generates the surface. (Note the capitalization)<\/p>\n\n\n\n<p><em>background<\/em> determines the surface&#8217;s color<\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<pre class=\"wp-block-preformatted\">\ncreateCanvas(400,200)\nbackground(0,0,0)\n\n<\/pre>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Notice that each of these functions is followed by numbers. These numbers are called <em>arguments<\/em>. They&nbsp;must&nbsp;be wrapped in parentheses and separated by commas. An argument tells \u2018its\u2019 function how to do its job. Not all functions need arguments, as we shall see soon. But the first ones we will use do. Let\u2019s take a closer look at what these two particular functions work, and what their arguments are doing. <\/p>\n\n\n\n<p>The<em> createCanvas<\/em> function needs two arguments to determine its dimensions. The first will determine the canvas width, and the second its height. Writing <em>createCanvas(400,200)<\/em> will result in a horizontal canvas that is 400 by 200 pixels in size. To get a canvas in the same ratio but vertically oriented, one would flip the order of those two numbers.<\/p>\n\n\n\n<p> In the editor below, go ahead and change the canvas dimensions by modifying the <em>createCanvas<\/em> arguments. Hit play to execute the code. Try making a square canvas of 300 by 300, for example, and a few other combinations. Be sure to keep the numbers separated with a comma, and between parentheses. <strong>Code is very particular about how you write it <\/strong>&#8211; as you will see, even one small mistake may cause your program to not to run at all.   <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\ncreateCanvas(400,200)\nbackground(0,0,0)\n\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-8 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>&#8220;The point is a small world cut off more or less equally from all sides and almost torn out of its surroundings&#8230;it maintains itself firmly in place and reveals not the slightest tendency to movement in any direction whatsoever, either horizontal or vertical.\u201d (p.21)<\/p>\n\n\n\n<p>Onward to our next function: <em>background.<\/em> This one determines the color of the canvas. We are using the RGB (a red-green-blue) model, in which colors are created through a mix of three separate values: of red, green, and blue. The scale is 0 to 255, with dark being 0 and light being 255. So black is 0,0,0 &#8211; and white is 255,255,255. This might sound complex but it&#8217;s easier to understand once you start playing around.<\/p>\n\n\n\n<p>Try plugging in a few different combinations in the editor below. Make the canvas red by using 255,0,0. (You will have to hit play to see your changes take effect) Try making it green by using 0,255,0. Or blue by 0,0,255. And then try some other random combinations of three values. Remember, always separated by commas, and between parentheses!   <\/p>\n<\/div>\n<\/div>\n\n\n<p><\/p>\n<pre>\ncreateCanvas(400,200)\nbackground(0,0,0)\n\n\n<\/pre>\n<p><\/p>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-9 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h3 class=\"wp-block-heading\" id=\"mce_82\">3. fill and rect<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&#8220;The point&#8217;s external concept in painting is not precise. The invisible geometric point must assume a certain proportion when materialized, so as to occupy a certain area of the basic plane. In addition, it must have certain boundaries or outlines to separate it from its surroundings.&#8221; (p.28)<\/p><\/blockquote>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-10 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p> Once you are comfortable with changing the canvas size and background color, let&#8217;s go ahead and place a static, white rectangle on our canvas. We will do this using the functions <em>fill<\/em> and <em>rect<\/em>.<\/p>\n\n\n\n<p><em>fill<\/em> picks a new color<\/p>\n\n\n\n<p><em>rect<\/em> draws a rectangle and determines its location and dimensions   <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\ncreateCanvas(400,200)\nbackground(0,0,0)\nfill(255,255,255)\nrect(200,100,20,20)\n\n<\/pre>\n\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-11 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>In the editor above, you will see added to our canvas a rectangle whose color, location, and size are determined by the arguments of these two new functions.<\/p>\n\n\n\n<p>Let\u2019s see how. The <em>fill<\/em> function is determining the rectangle&#8217;s color. It comes before the rectangle &#8211; just like in painting one first dips a brush into a new color, and then paints a shape.   <\/p>\n\n\n\n<p>Similarly to the <em>background<\/em> function we looked at earlier, <em>fill<\/em> always requires three arguments (for red, green, and blue). In line 3 of the panel below, try playing around with <em>fill<\/em>&#8216;s arguments to modify the rectangle&#8217;s color.   <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\ncreateCanvas(400,200)\nbackground(0,0,0)\nfill(255,255,255)\nrect(200,100,20,20)\n\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-12 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>As for the <em>rect<\/em> function &#8211; notice that it takes four arguments. Different functions require different amounts of arguments, and they use them in different ways. In <em>rect<\/em>, the first two arguments will always determine the rectangle&#8217;s location. <em>rect<\/em>&#8216;s first argument will determine its distance from the horizontal axis (X), and its second from the vertical axis (Y). In p5 the zero point is always at top left, so the smaller these numbers, the closer your rectangle will be to the top left. Try moving the rectangle to a different place on the canvas. (Hit play to update the code, as usual). Notice that your rectangle will not be visible if you place it outside the canvas bounds! <\/p>\n\n\n\n<p><em>rect<\/em>&#8216;s third and fourth arguments, meanwhile, determine the rectangle&#8217;s size: once again, first X, then Y. In the editor below, try playing around with the size of the rectangle.  <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\ncreateCanvas(400,200)\nbackground(0,0,0)\nfill(255,255,255)\nrect(200,100,20,20)\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-13 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p> Once you have are comfortable changing the color, location, and size of your rectangle, <strong>try adding another rectangle,<\/strong> by writing a new line of code right below line 4, in line 5. You can either write it yourself or just copy line 4 &#8211; in either case, you will have to modify your new rectangle&#8217;s location so it doesn&#8217;t just &#8216;hide&#8217; your previous one. You can add as many rectangles as you want to &#8211; try creating a few more. Then see if you can make another rectangle that is in a different color: to do this, you will need to add another <em>fill<\/em> function before your new rectangle, and modify its arguments to the new color you want. Once you have created a canvas with a few different rectangles in different sizes and colors in different location, let&#8217;s move on. <\/p>\n\n\n\n<p><em>&#8220;The point is a small world cut off more or less equally from all sides and almost torn out of its surroundings&#8230;it maintains itself firmly in place and reveals not the slightest tendency to movement in any direction whatsoever, either horizontal or vertical.\u201d (p.21)<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"mce_128\">4. setup and draw<\/h3>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-14 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Before ripping our square away from its surroundings and making it interactive, we must devote our attention to a fundamental aspect in the structure of our code: how it functions in time. While this all looks as if we have only created our canvas and whatever is on it once, these lines of code are actually being executed over and over again &#8211; about 60 times per second.<\/p>\n\n\n\n<p> And it works like this: right now, the computer is reading all our functions in the order they are listed, <em>then<\/em> executing them <em>all at once<\/em>, and then starting over again.   <\/p>\n\n\n\n<p>So right now our computer is being instructed to execute four functions in a loop:<\/p>\n\n\n\n<p> 1&gt; Make a canvas <\/p>\n\n\n\n<p> 2&gt; Paint it black<\/p>\n\n\n\n<p> 3&gt; Select white color<\/p>\n\n\n\n<p> 4&gt; Paint a rectangle (Or more than one, if you added more.) <\/p>\n\n\n\n<p> 5&gt; Go back to step 1    <\/p>\n\n\n\n<p>In order to do more interesting things, we are going to make a separation between things that<em> loop forever <\/em>and things that<em> happen just once.<\/em> This may be unclear, but you will soon understand what this means. For now, let&#8217;s look at how we can separate our functions, so that our first function <em>createCanvas<\/em> happens only once (when the code is first executed) &#8211; and the rest to happen over and over again as long as the program is running.<\/p>\n\n\n\n<p>To do this, we will have to make two new functions, and place the current functions inside of them. This is what it will look like:  <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\nfunction setup() {\n  createCanvas(400, 200)\n}\nfunction draw() {\n  background(0,0,0);\n  fill(255,255,255)\n  rect(200,100,20,20)\n}\n<\/pre>\n<p><\/p>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-15 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>As you can see, while the output remains the same, our code looks quite different.<\/p>\n\n\n\n<p>We have created two new functions called <em>setup<\/em> and <em>draw<\/em>, and placed our four lines of code inside them. These new functions are not taking arguments. Instead, they each have a pair of curly brackets, into which we are placing other lines of code &#8211; other functions, in this case.<\/p>\n\n\n\n<p><em>setup<\/em> and <em>draw<\/em> are two very useful functions provided by p5, and there is an important distinction regarding what happens to code that is placed within either. Consider it like this: whatever code is inside <em>setup<\/em>&#8216;s curly brackets will happen <u>only once<\/u> when the program is started. Whatever code is inside <em>draw<\/em>, on the other hand, will be <u>executed repeatedly<\/u> happening again and again as long as the program is running. If this doesn&#8217;t make sense don&#8217;t worry, you will soon see what this means in practice, as we learn about variables in the next section. <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Aside from its scientific value, which depends upon an exact examination of the individual art elements, the analysis of the art elements forms a bridge to the inner pulsation of a work of art. (p.17) <\/p><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">5. Variables<\/h3>\n\n\n\n<p>Now that we have made this separation into the setup and draw function, we can make our little rectangle change in all sort of ways. For example, in the editor below, in size. <\/p>\n\n\n\n<p> <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\nfunction setup() {\ncreateCanvas(400, 200)\n}\n\nfunction draw() {\nbackground(0,0,0)\nfill(255,255,255)\nrect(20,100, mouseX,20)\n}\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-16 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Have a look at the rectangle&#8217;s size arguments in the code above. As you can see, in place of a number in its width argument, we have placed the word mouseX. Instead of a static value, we have given it a fluid variable.<\/p>\n\n\n\n<p>Variables are sort of like containers for values. Soon we will write our own variables, but right now we are using predefined variables that are part of the p5 library. <em>mouseX<\/em> and <em>mouseY<\/em> are p5 variables that &#8216;listen&#8217; to the location of the user&#8217;s mouse (relative to the canvas&#8217; top left corner). By placing these particular variables in a function\u2019s arguments, the function becomes responsive to your mouse. In the sketch above (sketch is the word used for a p5 program) you can see that the width of the rectangle is determined by the location of the mouse in the canvas.<br><\/p>\n\n\n\n<p>In the sketch above, try changing the rectangle&#8217;s height to <em>mouseY<\/em>. Then try replacing one of the arguments in the fill function with mouseX or mouseY.  Play around &#8211; see what happens when you, for example, flip the arguments so that that the rectangles X location is determined by the mouse Y, and vice versa.<\/p>\n\n\n\n<p>Try experimenting in the window below. Also try placing the mouse variables in place of the background RGB values. See if you can make an interesting composition. Mission #1, complete.<br><\/p>\n<\/div>\n<\/div>\n\n\n<pre>\nfunction setup() {\n\n}\nfunction draw() {\n\n}\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-17 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<h3 class=\"wp-block-heading\">6. The Line<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p> &#8220;The geometric line is an invisible thing. It is the track made by the moving point; that is, its product. It is created by movement \u2014 specifically through the destruction of the intense self-contained repose of the point. Here, the leap out of the static into the dynamic occurs.&#8221; (p. 65) <\/p><\/blockquote>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-18 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Kandinsky considered the point and the line as the two most fundamental visual elements &#8211; the building blocks of all visual expression. Following his lead, let&#8217;s examine the creation of lines in code.<\/p>\n\n\n\n<p>In order to create a program like the one above, we will need to use two new functions: stroke and line.<\/p>\n\n\n\n<p>The line function takes four arguments: the first two determine the line&#8217;s starting point (on the x and y grids), and the third and fourth arguments determine the line&#8217;s ending point. Play around with the example below. See if you can add a fourth line from the bottom righthand corner to the mouse. Then add a horizontal line and a vertical line. <\/p>\n\n\n\n<p>Play around, and see what behaviors you can create. <\/p>\n<\/div>\n<\/div>\n\n\n<pre>\n\nfunction setup (){\ncreateCanvas(400, 400);\n}\n\nfunction draw(){\nbackground(200,200,200)\nstroke(255,0,0)\nline(0, 0, mouseX, mouseY)\nline(0, 400, mouseX, mouseY)\nline(400, 0, mouseX, mouseY)\n}\n\n\n\n<\/pre>\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-19 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>The default color of our line is white. To give it a color, we will use a new function called <em>stroke<\/em>. Like fill, the stroke function takes three arguments (red green and blue), to determine its color.<br><\/p>\n\n\n\n<p>In the example below, you can see two lines with different colors. Notice that each line is defined by the color above it. Think of it like a brush dipped in paint. When you want to use a new color, you must first dip your brush into a new paint. Try adding a few more lines in different colors. (You will have to change their locations, too &#8211; otherwise one will simply cover the other.)<\/p>\n<\/div>\n<\/div>\n\n\n<pre>\nfunction setup (){\ncreateCanvas(400, 400)\n}\n\nfunction draw(){\nbackground(0,0,0)\nstroke(0,0,255)\nline(0, 0, 150, 150)\nstroke(255,255,255)\nline(150, 150, mouseX, mouseY)\n\n}\n\n<\/pre>\n\n\n<pre class=\"wp-block-preformatted\">\nfunction setup() {\ncreateCanvas(400, 400)\n}\nfunction draw() {\n  background(100,160,200)\n  fill(mouseX,mouseX,mouseX)\n  rect(mouseX, mouseY,mouseX, 35)\n  \n  \n}\n\n<\/pre>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-20 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>When a force coming from without moves the point in any direction, the first type of line results; the initial direction remains unchanged, and the line has the tendency to run in a straight course to infinity. This is the straight line whose tension represents the most concise form of the potentiality for endless movement.<\/em><br><\/p><\/blockquote>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-21 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n\n\n\n<p>In one of the editors above, try experimenting with the functions we have learned and mouseX and mouseY variables. Try making a few rectangles that use the mouseX or mouseY as a value for their color and size arguments, like the example below.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>As we gradually tear the point out of its restricted sphere of customary influence, its inner attributes \u2014 which were silent until now \u2014 make themselves heard more and more. <\/em><br><\/p><p><em>One after the other, these qualities \u2014 inner tensions \u2014 come out of the depths of its being and radiate their energy. Their effects and influence upon human beings overcome ever more easily the resistances they set up. In short, the dead point becomes a living thing.&#8221; (p.26)<\/em><br><\/p><\/blockquote>\n\n\n\n<p>Once you feel comfortable with that, here&#8217;s one last thing to try before we end this first lesson: in your code above, try adding this line of code:<\/p>\n\n\n\n<p>rect(50,50,(mouseX+30), (mouseY+30))<\/p>\n\n\n\n<p>As you can see, we have placed the mouse variables into their own sets of parentheses, and modified them using simple math. This can work with subtraction, multiplication and division, too &#8211; but as always, you will have to pay close attention to the parentheses!<\/p>\n\n\n\n<p>Now you have all the coding skills needed to create a program like the one at the very top of the first article page. (except for the ellipse &#8211; which you can read about <a href=\"https:\/\/p5js.org\/reference\/#\/p5\/ellipse&#010;\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">here<\/a>)\n<\/p>\n\n\n\n<p>Perhaps this is the moment to &#8216;graduate&#8217; to a more robust editor, where you can also name, save, and share your programs: the <a href=\"https:\/\/editor.p5js.org\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">p5 Web Editor<\/a>!<\/p>\n\n\n\n<p>This is barely the start. If you are hooked and want to learn thoroughly from the experts &#8211; you would be wise to visit <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/p5js.org\/\" target=\"_blank\">p5.js<\/a> or Dan Shiffman&#8217;s <a href=\"https:\/\/www.youtube.com\/channel\/UCvjgXvBlbQiydffZU7m1_aw\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">videos<\/a>. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Many thanks to <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/demo.peblio.co\/\" target=\"_blank\">peblio<\/a>, the platform that inspired this piece. I would love to hear from you at <a href=\"mailto:drl349@nyu.edu?Subject=Re%20Bauhaus and Coding\" target=\"_top\" rel=\"noopener noreferrer\">drl349@nyu.edu<\/a>&#8211; if this was helpful, or you ran into trouble.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-columns has-2-columns is-layout-flex wp-container-core-columns-is-layout-22 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bauhaus and Code Pt.2 By Dav\u00edd Raphael Lockard &#8220;The investigation should proceed in a meticulously exact and pedantically precise manner. Step by step, this &#8220;tedious&#8221; road must be traversed \u2014 not the smallest alteration in the nature, in the characteristics, [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":2337,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-3049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hidden"],"_links":{"self":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts\/3049"}],"collection":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/comments?post=3049"}],"version-history":[{"count":0,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts\/3049\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/media?parent=3049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/categories?post=3049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/tags?post=3049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}