Artists, create a cool landscape with code! | Sadiq Somjee | Skillshare

Artists, create a cool landscape with code!

Sadiq Somjee, Artist

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
10 Lessons (1h 7m)
    • 1. Artists Create Landscapes with Code!

      3:04
    • 2. Install and Setup

      5:36
    • 3. My First Program

      11:14
    • 4. Introducing Variables

      4:14
    • 5. Coordinates and Lines

      9:23
    • 6. Random Trees

      7:21
    • 7. Fall Leaves

      8:05
    • 8. Beautiful Grass

      7:34
    • 9. Amazing Skies

      5:27
    • 10. Cool Project Ideas

      4:54

About This Class

Learn how to generate a simple landscape with code. No prior programming knowledge is required. Learn the Processing designed just for artists, it's easy. This course is taught from an artists perspective in a simple and visual way. It covers the basics of creating shapes and colors with code. The instructor is a graphic novelist, nature photographer and visual artist with many years of experience in the software industry. 

Transcripts

1. Artists Create Landscapes with Code!: Hi. Welcome to my class In this class will create a simple forest landscape with code. This class is designed just for artists just like you. You will learn how to use a language called processing to make beautiful forests and landscapes. Processing is a computer language that was developed at M. I. T. Specifically for artists just like you. You really don't need to know how to code or any mouth. I'll get you started in a fun and simple way. I'll show you how to use basic shapes and colors and shapes like circles and triangles and rectangles to create amazing art. In this class, your project will be to create a beautiful and dynamic digital landscape with processing. I'll show you an example in the minute. But first, who am I? My name is Sadiq Somji. I'm a visual artist, a nature photographer, and I studied computer signs in this class. I'll bring all these three disciplines together to create beautiful and dynamic art. Let me show you what I'm talking about. I'll kick run and it's generating a beautiful forest landscape. It's a treed landscape with the night sky and and sort off off white, yellowish moon in the background. The trees off various sizes and the random and the grass are also various sign sizes and leaning either left or right or straight. The colors are somewhat dynamically generated. I've controlled them with the various browns and greens to give that impression off the grass, and I put some fall color leaves for the trees. The backdrops interesting because it has this. So the wide, slushy paint blobs behind a black sky with little bit of blues and and purples, perhaps somewhat like van Gogh might have done. The interesting thing here is, if I were to run this program again, it will generate a completely different composition. The moon will be placed in a different place. Crees will be placed in different areas, and they'll be different sizes. I can control the number of trees. I want the number of grasses and wanna show, and I can control the lightness and their doctors up off the sky. Come on, join me. Let's get started. Thanks and have a great day 2. Install and Setup: Welcome back in this video. I'm going to show you how to install processing and give you a quick introduction to the interface. Let's get started. I'd like you to open your favorite browser and navigate to the processing Don't or website . You get to the home page, click on download processing. I'm going to select no donation and hit download, and you presented with several options. So if you have a Windows machine, one of the newer 64 bit machines click on the 64 bit windows. If you have an older Windows machine, click on the 32 bit. If you have a Lennox machine, click on the appropriate one. Since I have a Mac, I'm going to click on the Mac OS X and it's It's downloading. I've previously downloaded a version, so let me just minimize this, uh, window and go to my downloads folder. I'll open my Downloads folder, and what you should find is a zip file with processing. Just click on that. It's gonna un compress the ZIP file, and it will create a little processing program with an icon. Looks like an eye, Treanor, so I'm just gonna pull it out and drag it to my desktop. Close this window, the processing programs now on my desktop. So if I run it, it's it's It's advising me that this programs downloaded from the Internet and I'm okay with it, So I'm gonna click open the processing dialogue comes up. Here we go. So just to recap you went to the processing dot or website he clicked on download. I clicked on no donation and depending on whether you have a Windows or a Mac or Lennox, choose the appropriate download type. No, if you have a map. If your Windows PC, go to your downloads folder and create a short cut off the processing. Five. Copy the shortcut here desktop and click on processing, and this processing window will fire up. Let's take a minute and study this into face firm very quickly, so you have a run menu, a run button here and the stop button. Click on the run button and you get a little window, which we call a canvas, and you have a menu item now for the purposes off this class, I'd like you to type in exactly what I typed in. Don't worry about with syntax or the commands. This what I'm about to type in is a basic framework of all processing programs. So it has two functions which always start with the word boy that has a set up function. And it has these squiggly brackets and there is a draw function, and it has thes squiggly brackets once again. And if you had run, the exact same thing happens. Let's close that, and we'll just enter a couple of basic commands and in this case will increase the size of the canvas with the size statement size. And I'll give the size of whipped off 6 40 a height off 400 and statements always ending the semicolon, and I'll run that notice. My dialogue is now six body wide. My 400 just gonna close that a couple of quick tips before I leave you. In case you forget, some say, a semi colon. It's going to complain. It won't run. All you need to do is take a careful look at the syntax, had the semi colon and run it again. It'll complain about things like missing brackets, so it says it's missing the right parent. This is that's a pretty good, uh, error message. Let's put that back and run it. Okay? This is your basic framework and sort of a quasi first program. Let's go to the file menu and save it, and I'm going to save it as my first program and I'm gonna hit safe. Okay, that's the end of this lesson. In the next lesson, I'm gonna show you how to write your first. 3. My First Program: I and welcome back in this video, I'm going to show you how to change the screen size and set different colors for a cameras background. Also show you some basics. Shapes like drawing a circle and changing the colors. Let's get started. Click on your processing Icahn. If you haven't done it already and you'll get this dialogue little pop up, go to file and open recent off the program that you see you see it has the two functions you had Lloyd set up with the opening and closing curly brackets. Boy drove opening and closing curly brackets. Okay, so remember when we ran it? He just had this little cameras window so we can change that. Let me show you how. Let's close that. And there's a function called size that determines the canvas window, and I'm going to choose a size off 6 40 whipped by about by 400. Hi, and it always ends in a semi colon. Let's run this and see what happens there. You've got a window that says my class programs. That's 6 40 My 400 these air pixels. Let me close that. Why don't you play with a few numbers. For example, if I put 800 here and run it, you notice your canvas is a bit wider. It's the same 400 in length. Let me close that. One of the other things I'd like to add is to change the background colors. So the command for that is back. Simply background, background and the values ranged from 0 to 2 55 0 being black to 55 being white. So let's choose a black background off black run. It seems that is indeed the case. It's run that wonderful. Get a black background, try a few shades of gray. Say, if I had a number in between, Ah, 100 would be a nice gray scale in between or if I were to choose the highest value, which is 2 55 Can you guess what it might be? Right? It's white. Okay, so we covered size and background size to change the size of you can list and background to set the colors. I'm going to reset the background to Black, and I'd like you to do the same. And let's run that So we got the black background. This is gonna be your night sky off your beautiful forest landscape. Now let's draw a circle. And the command for circle is is Phillips. So let me just copy and paste this. I'd like you. I'd like you to type it in within the currently brackets in the draw. So if I have and Phillips that's on Exposition 200 Y Position 200 which is 100 by 100 in size. Let's see what happens. Here we go. We got a little white moon in the back. The interesting thing here is one of the features of processing is if you highlight the the function and you right, click, it's and say Find it in reference, it will go online and show you what the command is all about. So here we go. It explains the lips command, and here you have a circle that's 55 by 55 heightened long. So the first coordinate is the X coordinate. Second is the Y Coordinate. The third C is the width of the lips, and the last corner Last para meter is the height of the lips. So if you have both the height and both both the width and the height the same it would be a circle. Let's play with this for a minute. I'm just gonna close. I'm just gonna close this window and say I had a wider circle and I go run. So you get an elliptical moon so you can play with that and say I had, uh, less wide circle and se Um ah, higher one. You can guess what will happen. You get a longer, longer, Phillips, so you can play with these, But for for the purposes of this class, I'd like you to set it back to 100 by 100. 200. 200 are the coordinates, which I'm gonna show you how to set in a different lesson. Let's run that again. There we go. A beautiful moon in a in a background off the night sky. I'm gonna show Introduce the fill command. So the Phil, the fill command takes three values. It can also take one value. So if I had Phil just like the background command from 0 to 2 56 So if I had a fill of zero and I ran it, you won't see anything because the moon is here. It's black on a black background. But if I changed it to 2 55 that would be a white moon and I run it. And there you go has a white move. So when you introduce three values, you have a red value, a green value in a blue valley. So let's cry that so a red value off, say, 100 a blue value of zero and a green value of zero story and a blue value off say, 200. I wonder what this would be like. It's kind of a purplish moon. That's that's really interesting. So this the Phil has red, green and blue, just like your color palette. Now I'm working a little program on my website. Here's Here's a link and I'd like you to go there and play with it So it's on. Somji notes slash rgb dash colors, and this is an interactive program. So if I had a friend of zero a green of zero and a blue zero and dynamically changes his colors, it's a black, so it by have a little bit more off a ring value of 112. It's kind of, I guess, uh, t old reddish color and so you see what I mean. It's just like using a palette for your oil paints or your water paints and you're mixing colors. And depending on these red, green and blue values, you get a different film. So, for example, if I wanted more off a yellow moon, I could choose. I could experiment with this and choose, say, more open green. That gives me a bit more off yellow, perhaps a little less red or more, maybe more red and less blue. So if I use these values too pointy one, let me go back to the program. I use these values. 2 41 red 2 35 for green and say, 24 blue and I run the program. Let's see what we get. Beautiful yellow move. Okay, so now have you got a black background with a beautiful yellow move? Minimize this window. I think it's a good idea to play with this palette. Get used to how colors mix. You can use that to set some of your colors and also go back to your program and play with play with different colors. Say say, I wanted to increase the value of blue I get, I get a nice, beautiful, off white move, at least on my screen. Your screen may look, it's likely different or the video might looks like different. I'll close this and before I close off, I just want to give you five quick tips. So the first thing is noticed in sight inside the curly brackets, all the functions and with this semi semi colon, if you miss a semi colon processing is going to complain. With this dialogue, I'm sure you have encountered this already. You just simply go to that statement and add the cult semi colon. It'll complain, even if you were missing a pyramid, your and give you that little highlight. So, um, so it tells you exactly what the issues are. If you're missing a closing bracket, for example, it will also complain, so it's very specific and how it wants the commands. I suggest you run the program often to catch the errors often, and this way it will make your work a lot easier and also save often so you don't lose your work. Okay, so just to recap, go back. You learned how to set the screen size, throw a circle and set colors and said different backgrounds. See you in the next video 4. Introducing Variables: I welcome to a quick lesson on variables. Variables are simply containers where you can store values and you can give them any name like X y top axe and tough wife. You need to initialize variables by their type. So into is a type variable, and I called it X of assigned a value of one. So where you post can be off type integer. So here I have declared a variable called Draw count off type integer and assign it value. 10. Another type of Merrick variable is float and float simply stores decimal values. Integers don't processing also has built in Variables With and height. Let's take a quick look within height are simply the width and height off the screen. So if I do print lines with and height, what do you think I would get? My size is 6 40 by 400 so I get 6 40 by 400 in this consul area. If I were to change this back to 400 what do you think I would get right? 400 by 400. Let me it stop here. Let's take a quick example off variables. You can also do basic math like incremental values. Scient Value Deck lamented or multiplied by another value. Remember variables that just containers to store values. So let's declare a variable and off type integer called Draw Count, and I'm gonna sign it a value off one in the set up program. Just run that there's no difference there, set up runs just once. Draw runs many times, so I'm just gonna print the value off, draw count and run that, and it's just printing the value one. So that's not very interesting. Let's try incremental it. It's a draw. Count equals draw cones. Let's one. You see the value keeps incremental by one because the draw function keep is running over and over again. So a different type of variable is a variable off type float. So if I were to initialize a variable afloat and I I initialized and I declare a variable X off type float, I set X equals two one, just like draw account. And here I increment X as well. X equals X plus just to this reform and add X to the print statement. Let's see what happens. You see X is incremental by two each time and it has decimal values. Okay, I'll hit. Stop. And in this lesson, you got a quick overview off variables off type float integer you. I showed you how to get the the screen height and the width using the width and the height , variables and used use variables for basic addition. And I showed you how to use print line to print values into your counsel. See you in the next lesson. 5. Coordinates and Lines: Hi. In this video, I'm going to show you the coordinate system and how to draw lines. Indra lines to create the tree trunks, these brown tree trunks in various locations. Let's get started. So what I'd like you to do is go to go to your browser and open somji notes dot com. Why were my Web pages click on utility? And I've created a little utility to explain the coordinate system? What I'd like you to do is fall along with me in this program. What have done is created of a camera size off 400 400 by 400. I've divided into four equal parts vertically and horizontally. And what this utility does is when you click on it, it will show you the X and Y coordinates. So in here, X and Y are roughly about 100. And if I moved to the right, you guessed it x will be 200. Why will be X will be now 300 and towards the end, X will come close to 400 so X goes from zero to 400 on this can list. And unlike your math class, why starts from the top from 0 to 400. You notice X is always 100 because I'm on the same x a vertical line. So let's take a look. Why would why zero there and roughly 100 there. Why is 100 there? Can you guess what? Why would be here? 200 right? And X is still 100. And you click on this. X is still 100. Why is almost 300 close to 300? And sure enough, X is still about 100. And why is 400? So I applied the bottom is 400. So let's take a look at the line function now. So if you haven't opened your processing program already, go to file. Open your processing dialogue first, goto file open recent and open your first program. I've got the window open and I'm gonna create a line function. So 104 100 for the first point, where X Hawaii's at the bottom and ah, 100 to 200 where why is sort of the midpoint? Let's see what happens. So the reason it's complaining there is because I forgot to include the semicolon there. That's a good debugging message. Okay, so line first point seconds like let's see what happens. Okay, nothing happens. That's because the line is black on a black background. The way to change the line color is with the stroke command the stroke function. So you go stroke. And just like the Phil and the back background functions, he takes values from 0 to 2 55 0 being black, which is the default in 2 55 being white. Okay, let's see what happens when we run it again. Beautiful. We get a line that's starts at 0.104 100 for X Y and ends with 1000.100 to 200 for X y. So if I wanted this tree line a bit slanted, what would you dio our move? X Maybe just off to the right. Let's see what happens. They got a kind of slanted tree. What I'd like you to do is play with some of the line functions here And what what I'll do here is reset this back to 100. And what I'd like you to do is place a line a couple of lines, one a little off to the right. Another one, a little off to the right so you can come up. You can type along with me. So if I want it further to the right, my ex would be at 200. I still have the why starting at the bottom and still have access to 100. And this time I'll make the tea tree a little taller with the Lord by book value. Okay, let's run that and see what happens. Nice to get a nice tall tree. Try it a couple of line functions and I'll have except 300. Why Still at the bottom ex still at 300? Well, unlike mystery slant of it at 310. And why would be maybe a shrilly short Cree off saying 300. Let's see what happens. They're a slanted tree wise, about 300 from the top and X is 300 going off to 310. But those are not don't look too much like trees, so maybe we can make it a little. The tree trunks a little thicker, and the way to do that is with a stroke weight function, and I'll give it a wayto five. Let's see what happens. Run that That's nice. Little thicker. Uh, I like 15. Beautiful. See? It's also changed the stroke weight off moon kind of looks like the sun like I like that effect. If you don't want that, you can just add a stroke, wait in front of the ellipse function and give it a stroke weight off One run that there was that it had a small, tiny white outline. Or you could have a stroke weight off zero and you get almost no outline. And the the last stroke weight function overrides the previous stroke rate functions. So you get these thicker lines, you can even play with the placement off the moon with the X Y coordinates in the first part. The second part is the size of the moon. So if I wanted to move the moon a little bit to the right, say, two x about huh 150 a little lower for the why maybe a 120. Let's see what happens there. That's a nice effect. In fact, I would like to move be x a little more to the right there. So the trees kind of in front of the moon that gives it a nice effect with these tree trunks. I'd like to see them to be a little more brownish reddish cree trunks. So let's go back into utilities on my website. And if you remember these colors, let's cry and later on with some colors here and maybe give it a little more red. Little rest. Here we go. Okay. I like those values. You can fiddle around with those two, like further adding the stroke function. You can have three values to give it color, so let's try these. 2 34 205 and 144. I'll just minimize this window and let's see what kind of colors we get for the tree trunks . Beautiful. So you can play with these colors a bit more if you like, and experiment with that experiment with lines. Okay, so just to summarize before we close up, we cover the coordinate system. We covered how to place X and Y points for lines and move objects like electives along the cannolis, and we also learned how to change the thickness off the line and the colors of the line. See you in the next lesson 6. Random Trees: Hi. In this lesson, I want to talk about the random function. But first, I'd like you to go and open your first program. Just going to file and open recent open your first program and make your program look exactly like mine. So in the draw function, get rid of everything within the squiggly brackets. Except for draw count equals row countless one. Make sure you have two variables declared with the draw account with type imager and X and y as type float variables. So you've got three variables. Draw Count X and Y, and make sure you're set up. Looks just like mine with the size, background, stroke weight, Phil and Ellipse function. Now let's just test it out to make sure you haven't made any errors. Run it. There we go. And now go into processing and save it. Okay, Now, next, What I'd like to do is show you the random function for the trees. So what I'd like you to do is type this code exactly as you see it in your program window. I'm just going to copy and paste it and paste it in there. You can always put my program pause while you're doing that, let you see that on the screen and you can type it in. So before I explain this, let me just run it and show you what happens there. We get a whole bunch of Krys. Okay, so I've been choosing an X value of random with and a Y value off random height 202 to 400 because my hike is 400 and I've plugged it into the line function x 400 x and y. Let's run that. Take a look. Here we go. They're far too many trees there, so I want to limit the number of trees. What I'm gonna do is I'm gonna use draw count as my counter to to indicate how many trees that I want to populate. So I'm going to say if draw count, he is less than 10. Then I want to execute everything within these quickly brackets. So I want to draw on the nine crease. So if it's less than 10 let's see what happens. There we go. 123456789 Perfect. Hey, five. Close that and say, I wanted more trees like that. Have less than pretty. It can do that. Perfect. So you see, Ex is a random with so any number between zero and 800 because be with us for our screen are can list is 800. So it goes from 0 to 800. And why is a random height between random between 200 the height and the height off the screen is 400 so 200 is about there. So if I were to make it about 100 let's see what would happen. We'd get taller trees and I like that much better. Let's keep it like that. Okay, I'll stop the program, and I want to generate some random colors. So I'm going to declare three variables called red value green value and blue value of type float so bread value, green value and blue value. And then I'm gonna insert these variables with the random function. I just copy knees and paste them into my program. So I've got a red value between 152 to 55 of the semi Coghlan's and just so you can copy them, I'll just correct this. They say that, and so you have a red value between 152 to 55 green value and so forth. So let's insert these into the stroke function and see what happens. So red values, green value and blue value is zero, but will insert it as a variable anyway, so we can play play around with it later. Okay, let's see what happens when I run it. Beautiful. Get all these beautiful colors. Let me run it again. So most reds and browns and oranges there has kind of a nice effect on the background sky. Okay, so what? You saw Waas How to use the random function to generate random colors and place objects placed lines randomly on the screen. So let's run that again. Take a look and what you can do is to get a better understanding. You can go into the canvas grid utility on my website and look at Brandon values here and say in this case, the screen is 400 so you go from 0 to 400 Random X values would get placed their random why values would be from 100 to 400. So you get these Random Creek Heights coming across like this So there you go with the the tree height ranging from 100 to 400. I could even change this to say, um 300 probably end up with a really short trees. Let's try that. Sure enough, the trees. A really short. I'm gonna stop the program and change it back to 100. There we go. Stop the program. So we covered random values for the line function and random colors. See in the next lesson. 7. Fall Leaves: Finally, we're gonna create some beautiful leaves, roams around the top off the tree trunks that we created. But before we do that, let's clean up our code, open your program and we'll get rid off this X equals one because we're already setting initializing the value off X below with the random with Let's get rid off the with the print line function, which I had for demonstration purposes. And if you still have this, X equals experts to get rid of that and we'll get rid off the print line function for the draw count. So I'm gonna explain this code to you have I've cut this code and I've tasted it just below the, uh, the line function, which which produces the three trucks. And I'm going to explain it to you before I explain it to you. It's a very small piece of code. I'm going to run it, and there it creates a bunch of leaves around the top of the trees. I'll run it again. The tree placements, a random leaves a rolls centering around the top of the tree. Run it again. There you go. That's beautiful. Okay, let me explain this code to you and the way I'll do that dragged us to the bottom is I'd like you to go back to my Web page and go into utilities and find the processing cameras. Grid utility. Now I'll just walk you through this piece of code. I've inserted a loop statement. This is a four statement and basically does for inter jury cause I equals zero while eyes less than 2 50 increase it by increase. I buy one. All this is saying is run everything in this quickly brackets 250 times. I could change that value and run it for less or more. Essentially what, 250 years? It's the number of leaves around each crease about to use the no stroke function, which eliminates the border around the ellipse function. And I've selected some random all colors, which gives me these greens and yellows and reds for the need. So random 200 for the red random 250 which is from 0 to 250 for the greens and no blue. Now this function needs a bit of explaining, So if you if we go back to the code, you recall that weeks chose a random X value for the line. So when the line but produced the X started from here to here Andi and the the random Why value waas Basically the height off the tree. So let me go back here and show you what I mean. So we What I've done in this code here is I've taken the existing X value and added a plus or minus 40 random value for the exposition and a plus or minus 50 and 30 for the white position. Let's take a look. Look at what that means. So supposing the top of a tree is here, so roughly your ex is 101. And why is 99? So if I had an ex that was a random, um, plus 40 it would be about there. And if I had a minus, 40 would be about there, so I'd have X values all the way from there to there to there to there any fired a y value off minus 50. Then it would go somewhere there. So about 50 bang on and it will have that. And if I have a why value off plus 30 it would be about there so all my leaves would be placed all around, centering around the top off the streets, which they indeed do. So let's let's try out this program. So I've include created two more float variables ex Leaf and wily, and I'm inserted the X and Y coordinates for the X leaf and the wine if function and also in terms of the size of the Ellipse I've chose, I have chosen a random size off about 10. Okay, I mean, minimize this and let's play with this code a bit more. So let's run this again. So supposing I had larger leaves say, 40 by 40? That's the size of the lips. What do you think will happen? Very interesting looking trees and say I had 20 by 20. That's kind of cute. I prefer 10. My tent. That's the size of the leaves. Now it's entirely up to you for your project, for your artistic expression. If you want to use tiny leaves or leaves of different sizes, I leave. I'll leave that artistic expression up to you. The other thing is, these, uh, 250 is the number of leaves, So if I had just 50 leaves there would be fairly sparse. So that's sort of interesting. It really shows the night sky. And if I had, if I had to say 500 that's very dense, so I maybe 200 may work out well, 200 leaves. Let's run that. That works really well, so it centers the X and Y positions around the top of the tree. I could make, uh, the leaves go lower by adding more to the Y value. So let's try that there. You got some sparser and longer leaves in there, so that's interesting. So all I did was add this piece of code and I declared very variables on top added, uh, ex leaf and why Lethal type float. And I added this four look. Function put no stroke. So there's no lying around the the circles on around the ellipses, and I distributed the leaves sort of around, uh, X plus or minus woody. And why plus or minus 50 I'll leave it like that. And so what you saw is fall colors for the leaves, which I chose a random filth. I placed leaves around the top of the tree, and I used random sizes for the ellipses. See you in the next class 8. Beautiful Grass: hi. In this lesson, we're going to create beautiful grass like you see about Let's get started. So what I've done is I've taken this a little piece of code and inserted it into my program just below the make to the code. We have to draw the trees so it comes after the squiggly book brackets for the grow count less than 10. And I've added a comment in in front of it Teoh to make the code more readable. So if you recall the draw function keeps, uh, looping forever and ever. And every time it loops, we increment the draw count by one. So the first time it goes, a draw account will be one. And then it will go to on day three and so so on. As you saw in the print statement here, we drew about nine crease, and here we're going to draw 299 blades of grass. So if the draw Countess less than 300 I wanted to execute everything within these squiggly brackets. Let me explain the code to you. The stroke function gives you the random grass colors so chosen a random green from 0 to 2 55 a random read from 150 to 200 No Blue. Let me show You run the program, and we've got these beautiful colors and blades of grass that that show up. So we'll have about 299 links of grass in there now if I were to. So the X axis here. I've chosen a random width and the width is from 0 to 800. Let's go back to my program online, and this one is 400. So x would be here would be, say, six 102 103 100 400. And why is always at the bottom? And in my program it's roughly 400. So let me just minimize that the Y value is a random height. In our case, toe height is 400 minus. So let's take a look at what this statement means. Let's go back there and just move it along this side, so the divine well you is height minus 40. So if height is 400 minus 40 would be maybe 3 60 roughly 3 16 So I'm choosing a Y value that's random between 3 64 100 So my grass would be anywhere from 3 62 Any value here, so that would be the height of the grass. So I'll get all these random grasses, as you see in the screen, off random fights. The stroke. Wait, is Random Force. I don't want the grass to be as thick as the tree trunks, so I've chosen values from 1 to 4. So you get these nice, skinny grab grass blades. Okay, let's run that. That's run that again. And we see these different blades of grass. So, for example, keep our doing from increase a stroke. Wait to 10. What do you think would happen when we move this over to this side? Run? Sure. I get these thinker Blaise, That's an interesting effect, and you're free to play around with that. But I like it to be about war. Let me run that again. Reset that. And so we've got these. Beautiful. There are brown and orange and green grass colors £75. An early sort of that sonny terrain, where you've got a slight slight burns on the grass and some new fresh green blaze. So the lines are from ex being at any one of these values from 0 to 800. The first point is always X and y, which would be the height off 400 and the new Y value would be any height from 400 or 3 60 to 400. So let me demonstrate this second point. So you're here. You're the first point from any X value to why value off the height of the screen, which is 400 and the second value second coordinate X and Y second point would be about there. So what if I increase the Y value to 100? So now we should get grasses that are from SE 300 to 400. Let me run this and see if that's the case. Those that tall grasses that's interesting. A. Reset it back to 40 because I like that and you can play with those and make it more interesting. But the other thing that I want to do is I want to make the grass tilt a little to the right and a little to the left. So if I leave my ex where it ISS and my why, whatever the value is and if I moved 10 to the right. I intend to the left and I make this random. I should have lines that tilt left or right, or go straight or anywhere in between. So let me modify the second X point. So you got the first point of the line in the second point of the line to, um, add a Rendon value, say, between minus 20 and plus 20 and let's see what happens. So I'm guessing the blades of grass will sort of lean to the right 10th and left, minus 20 and plus 20. There you go. That's a little too much lean for me, although it does look nice. I would try tip minus Stan and busted to go that I like that much better. But that's entirely up to your artistic expression. Okay, so let me just minimize this window on this program again. And there you have a beautiful treat landscape that's random with the moon in the background with beautiful grass. So in this lesson, I showed you how to use the colors on the stroke function again, and I placed the grass along the bottom with the line function, and I made small lines leading to the left and to the right. See you in the next lesson. 9. Amazing Skies: in this lesson, I'm gonna show you how to create these amazing skies with these blue and purplish backed brush strokes like Van Gogh May might have done. But first, let's go and modify this program to create a random move. So remember, when we run it, the moon's always in the same position. I'd like to move it along the horizon a bit. What I'm gonna do, you guessed it. I'm gonna place a random with and replace that 170 with random Witte so the moon will be placed anywhere along here. Can The moon's there, I'll run it again. Lose their That's interesting. I like that. Okay, let me stop this program and introduce you to rectangles. Wrecked is a function function in processing that's very much like the Ellipse. It takes X and Y point as a starting point and has a width and a height just like the ellipse function. So if I run this program right now, I get a nice, beautiful around move. So if I were to change this ellipse function into rent, what do you think I would get a square moon? There we go. I'll run it again. That's kind of like, uh, probably from a square planet somewhere. Okay, let's stop that King sat back to the Ellipse function, run it just to test it out. Perfect. Works fine. Go back to processing. I'm gonna file save my father and to create that blue sky effect on the background. What we need to do is create a bunch of random rectangles, uh, in the background. And we'll do this just before just after the background function here and before we put, uh, put the moon up. So let me copy and paste this code, and you can type it in. I'll put it right in between there, and it'll taste it in there. Here we go. Just line it up. So what this code is doing? What this code is doing is for I equals zero to the width. In our case, 800 we increment I And so this loop between the squiggly brackets is gonna execute 800 times. So just like the lifts, the rectangle function, I'm having no stroke. No outlined border. I'm giving it a random fill of blue, green and reds, and this is giving the blue and purplish colors in the background and I'm creating a bunch of random rectangles. And the I value here is a is implementing from 1 to 800 the X value the Y value is anywhere from 0 to 400 actually to be to make this program much more flexible. What would we do here, right at the height, variable from processing? And then we'll have the rectangle of random wits from 0 to 50 and random heights from 0 to 30. Let's run that and take a look. Look at that. Those beautiful blue strokes. What if I wanted to make these really kind of pick sloppy strokes that give larger rectangles? Let's see what effect I would get. Wow. Okay, I'll go back to with a 50 and ah, height off 30 because that seems to work. Well, now you can play around and you can play around with different colors, for example, say I wanted to play with more rents and I did that. You'd have another interesting sky there. So go ahead, play around with this code at it just before you draw the moon. So the moon pains 1st 6 It's sort of like layers. The set of function executes once we colors a black background black first. And then we put the thebe brush strokes in the back. And on top of that we could be ellipse and the draw functions and paints. On top of that, the various trees and the grass is on. Believes. That's it. We're done. Congratulations, almost. 10. Cool Project Ideas: This is the final lesson here. I'm going to share some really cool project ideas. What I'd like you to do is with your program. You can play with the number of Crees. You can move it from 10 to 20 or 30. Make any number of priests, go ahead and play with the colors for the sky. The moon's the trees and the grass. You've got some powerful commands that you understand now at your disposal like random, and you understand how to fill colors off. Red, green and blue combinations make the moon bigger, perhaps even making random sizes in places in random places. Experiment with leave shapes, you know, change the leafs from ellipses. Two rectangles or triangles, our boat or all three. So here's the two commands. As we've already seen, Rectangle has an ex wife physician. It has a width and height, so you could try that. The Triangle Command has three points, so an x one y one x two y two in a white X three white chri. So basically a triangle is like that. So try those out here. I'll show you an example of another program. I've written where I'm used triangles for leaves and instead of the grass is at the bottom . I've had the fall leaves fall on the ground. I won't sort of got the moon And I have little tiny stars in the back Those those are essentially really small ellipses off color white. So go ahead and try that out. We stop that now for your final thing. What I'd like you to do is make your program so it runs over and over again. So as I've done it on this side, So after it finishes running, it'll refresh itself after a few seconds and run a different composition. See, have got different different color moons. I've got different placements and it just generates over and over again. That makes it interesting. And you can play an experiment with that. I'll close that. Let me show you how to do that. So just grab this piece of code. I've provided a text file where you congrats, pieces of code and inserted into euros. You can copy and paste it. So what? What I've done here is within the draw function way below. Just just after the draw count, I've put some comments in to reset which basically explain what this piece of code is doing , which is essentially resetting the program. And so it runs over and over again. So when he does, it sets a drug come to zero reruns set up as you know, set up, goes and refreshes the screen does, makes it black, turns a black background to black, does the blue purplish for brushstrokes and paints the moon. And then, after set up his run because the drop down to zero And because draw keeps running over and over, it starts the counter again and you get the trees again. Let's take a look. Is that program and I'll run this my other program just for fun so he can see both of them work together. There we go. The two programs are running with beautiful random colors, beautiful shapes, uh, different sizes off the moon. So thank you for taking this course. I'm really looking forward to see some of your very creative and interesting compositions. One of the beauties of processing is when you make mistakes you get sometimes you get wonderful results. So share your work, Remember? I've got to Foz. I've got this entire power point presentation as a PdF that you can keep a copy off. And I also have a text file which basically gives you all this code in this program. So essentially, what you can do is if you start with a blank program, you can go say, on processing. You can go find new, and you can take that text file and simply paste it in here and run it. And that program should grown fine in case you're having problems. So once again, thanks and happy coating.