Programming Graphics I: Introduction to Generative Art | Joshua Davis | Skillshare

Programming Graphics I: Introduction to Generative Art

Joshua Davis, Artist, Designer, and Technologist

Programming Graphics I: Introduction to Generative Art

Joshua Davis, Artist, Designer, and Technologist

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
45 Lessons (6h 42m)
    • 1. Trailer

    • 2. Introduction: Environment Setup

    • 3. Downloading Processing

    • 4. Working with Sublime Text 2
    • 5. Final Environment Setup Tips
    • 6. Introduction: Processing and HYPE

    • 7. Download HYPE

    • 8. Project Steps 2,3,4

    • 9. Java versus JavaScript

    • 10. HYPE AS3 / Project Step 5

    • 11. HYPE processing / Project Step 6

    • 12. Introduction: Drawing Visual Assets

    • 13. Drawing Visual Assets

    • 14. Drawing Abstraction

    • 15. Drawing Time-lapse

    • 16. Final Asset Prep
    • 17. Introduction: Painting to Screen

    • 18. Basics / Line and Rect
    • 19. Basics / Rotation

    • 20. Basics / Matrix / push and pop
    • 21. Basics / Rotation and Color
    • 22. HYPE / Basics
    • 23. HYPE / Drawables
    • 24. Introduction: Working with Color

    • 25. The Color Thief's
    • 26. Expanding Kuler

    • 27. HColorPool
    • 28. HPixelColorist
    • 29. HColorField
    • 30. Introduction: HGridLayout

    • 31. HDrawablePool + HRect
    • 32. HDrawablePool + HShape 1

    • 33. HDrawablePool + HShape 2

    • 34. HGridLayout
    • 35. Introduction: HShapeLayout

    • 36. HShapeLayout
    • 37. Introduction: Output Files

    • 38. letsRender / bad
    • 39. letsRender / better

    • 40. letsRender / BEST

    • 41. letsRender / final edits

    • 42. Some Parting Words...

    • 43. hexGrid / Randy Steward
    • 44. hypnoWheel / Luke L
    • 45. Processing 3 + HYPE library / update

41 students are watching this class
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class


Generative art is all about using programming to generate artwork that is algorithmically defined and created. In this project-based class, you'll learn how to create your own series of patterns using generative art techniques and computer programming!


What You'll Learn

  • How to setup your programming environment for making generative artwork.
  • An introduction to Processing and the HYPE Framework. With the HYPE Framework you'll be able to create work quicker and more effectively.
  • We'll start by drawing your shapes and preparing a bank of assets for you to use in your piece. These can be any sort of image that you have created.
  • Painting with HYPE using different variables to create and infinite range of possibilities. 
  • Adding and controlling color throughout.
  • Using HGridLayout and HShapeLayout to create your final piece. These will give you ability to create grids and shapes with your assets. 
  • How to output your files to Photoshop of Illustrator. You'll be able to manipulate and edit them to arrive at the final piece.


The Tools You'll Use

  • HYPE Framework is a collection of classes that performs heavy lifting tasks while using a minimal amount of code writing.
  • Processing is a programming language, development environment, and online community. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology.


Who Should Take This Class
This class is perfect for anyone looking to learn about making generative art and programming.

Even if you're already a master at Processing, you will get a new look at it by learning how to use the HYPE Framework to improve your workflow and the way you make art.

Meet Your Teacher

Teacher Profile Image

Joshua Davis

Artist, Designer, and Technologist


Joshua Davis is an award-winning designer, technologist, author and artist in new media, and is acclaimed for his role in designing the visualization of IBM's Watson, the intelligent computer program capable of answering questions, for the quiz show Jeopardy.

Joshua's work has been exhibited at the Tate Modern (London), the Ars Electronica (Austria), the Design Museum (London), le Centre Pompidou (France), the Institute of Contemporary Arts (London), PS.1 MoMA (New York), the Smithsonian's Cooper-Hewitt, National Design Museum and more.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Trailer: My name's Joshua Davis, and I'm a designer, I'm a programmer, I'm a technologist, lover of open-source, lover of random chaos and we're going to take a class on learning how to program generative algorithmic compositions. What is generative art? It's making art that is mainly driven by a computer program. I like this idea of being able to look at the screen and have the composition make decisions that are totally outside of gesture. It may take me a while to teach you how to set up this process, but once you're done with that process you have a system for generating an infinite number of competitions. I think where I'm more excited is to see what other people do. What kind of drawings do other people make? What kind of colors do other people use? Again that artwork that gets generated in the end, is going to be unique to that individual because they've made all the decision making within the parameters. I'm just giving you the tools to set those parameters. 2. Introduction: Environment Setup: So, right now we're going to concentrate on setting up the environment. I relate this back to skateboarding. I remember looking at pros that I admired and the way they skateboarded, and when I found out how they set up their boards, maybe what kind of bearings they used in trying to replicate that setup, helped me get a better understanding of how that person did, how they skated as good as they did. So, I relate that back to the technology that we're doing. We're going to be working in the processing environment, but I actually don't write code inside of the processing authoring environment or the IDE. I actually write code in a program called Sublime Text 2. So, we're going to take some time to download Sublime Text 2. I'm going to show you how to install the processing bundle to get processing to build within Sublime Text 2, and I'm also going to show you how to set up snippets. For example, we're going to set up one for setup. So, I'll start to type S-E-T-U-P, and it'll actually autocomplete a very large chunk of code that is typically the code that I rewrite over and over and over again. So, why not set up a snippet for executing this large block of code. So, working within Sublime Text 2 is going to be super helpful in terms of optimizing how we actually author in this environment. 3. Downloading Processing: Hey, this is Joshua Davis and welcome to Programming Graphics, an introduction to generative art. We are going to have fun. We're going to have fun, and we have a ton of content to cover. I'm going to break these into a bunch of independent videos so that you can digest at your leisure, and this first section that we're going to cover is actually environment setup. For me, it's the most crucial. It's a window into how people set up their environments, and I'm going to show you how I set up my environment and I find it fascinating and helpful. What sort of shortcuts do people take in order to make the work that they make. So, in this class, we're going to be covering processing. We're going to be covering a little library that I work on called Hype, and we're going to be working with SVG, Scalable Vector Graphics, which means that we're going to be drawing assets inside an illustrator and then mapping those drawings into programs that we write using processing, okay. So, the first thing that I want to do is move on to downloading and installing processing. So, if you open up a browser and go to, you'll notice up at the top of the page there's download processing. If you click download processing you can make a donation. If you would like, you can click no donation and still download processing for free. You can see that there are Windows, Linux, and OS X installers. Obviously, I'm going to be using OS X. When you go ahead and click download you should get a zip file, and when you unzip that zip file you actually get processing the application. Now, if I were to run processing the application it would look something like this. The first thing that you should be aware of is there's that processing that's a text editor. It's an environment that allows you to write code, run that code, and view the visual results. So, let's say that I wanted to paint something on screen. What I could do is, I could just type right into the processing IDE, and I'm going to say void setup. I'm going to go ahead and say that the fill color is orange, and then I'm going to go ahead and draw a rectangle. Let's say that this rectangle is 20 pixels on the x-axis, 20 pixels on the y-axis, a width of 50, and a height of 50. Now, I've just written a little bit of code here inside of the processing editor, and if I was to go ahead and save this file, I'll go ahead and save this as processing IDE and I'll put this onto my desktop. If I were to click run right here on the processing IDE, it's actually going to compile the code that I wrote, and again I can actually view the results right here on screen. So in fact, it did draw an orange rectangle at 20 on the x axis, 20 on the y-axis, a width of 50, and a height of 50. Now, for the next video, I'm actually going to show you how to work with Sublime Text 2. So, while I love authoring in processing, it actually isn't my editor of choice. Actually I like to write my code into Sublime Text 2. The reason for this is it has a ton of shortcuts for, in my opinion writing code, faster, easier, and a little bit more efficiently. So, while I like processing. I don't like authoring in its editor. So, next video working with Sublime Text 2. 4. Working with Sublime Text 2: Okay. In this video, we're going to cover working with Sublime Text 2. So, if you return back to your browser and go ahead and type in Sublime Text 2 into a search engine should be the top result. If you go ahead and click, you'll notice that the URL Sublime Text 2 At the very top, you have the option to download and again also has Windows, Linux, and OSX flavors. I'm going to go ahead and click to download the installer, which I've already done. I have already installed. Again, if I were to run Sublime Text 2, you will notice that it's a text editor, just like the processing IDE has but it has some interesting advantages. If I start to write some of the same code just as I had done before in the previous video, you'll notice that if I go ahead and type void and if I go ahead and type setup and I do open paren, you'll notice that it automatically generates the close paren, and if I go ahead and type open bracket, you'll notice that it completes it by doing the closing bracket. If I were to do a hard return, it puts that closing bracket on the third line and automatically tabs my second line. So, it has ways of making writing code much more efficient in my opinion. Now, and again, this is just a text editor and I can do things like make the type bigger for the case of these videos so that you can actually see the code that I'm writing. So, it's got these enhancements that I just think are a little bit more efficient. Now, if you go into the bottom right-hand corner, you will notice that these are all the different language packages that come with Sublime Text 2. You might notice that processing is not part of this base install. It's something that we have to add. So, if you come down to the Ps were processing should be, its PHP to Python but there's no processing okay. Now, it ends up that there is a processing bundle so we need to let Sublime Text 2 know that processing exists. I'm going to go ahead and return back to my browser and I'm going to go ahead and type in Sublime Text 2 processing bundle. When you do that, you're interested in the top two links. This is the GitHub repository that hosts the package and there's this great second link that actually has a video on Vimeo for you to digest the content. Ice tea. So, I'm going to go ahead and open up this Sublime Text 2 Vimeo video. It's about a minute long. Again, it's super helpful in showing you how you can tie Sublime Text 2 to processing. Now, I'm going to go ahead and click this top link because obviously I've already watched the video and here is where you can get all of the information that you need in order to add processing to Sublime Text 2. Now, I am going to do it using Package Control. Now, in order to use Package Control, you'll see here that we want to look under installation and the first one is using Sublime Package Control. Now, if you go ahead and click this link. If you are using Sublime Package Control, you can easily install the processing bundle via and then it shows you the steps. Unfortunately, by default Package Control is not installed. So, if you come under preferences, Package Control is actually is not here. So, I'm going to click this link, if you're using Sublime Package Control. The Sublime Text Package Manager that makes it exceedingly simple to- install now. So, when you click install now, you'll notice that there's some code that you have to copy and paste into Sublime Text 2's console. Now, Sublime Text 3 is actually in Beta, so you'll see some information here. I'm going to go ahead and click this link for Sublime Text 2. Now, you're going to copy this one long string of instructions. So, I'm going to go ahead and copy that and I'm going to come back to Sublime Text and I want to open up the console. So, if you go ahead and click view, you'll see right here it says show console. Now, when you say show console, it's going to load that bottom section of Sublime Text 2 and right down here, there's an input, cursor's blinking, all I'm going to do is actually paste what we just copied from the browser. So, I go ahead and paste that and I go ahead and click return, and you'll notice that a bunch of stuff happened and then it just said, please read start Sublime Text to finish installation. So, the instructions for adding Package Control has now been added to Sublime Text 2. So, it's at this point that I can close the Package Control installation instructions. I need to quit Sublime Text 2 and actually restart it. So, when I restart Sublime Text 2, it'll seem like nothing is different but actually, if you come into the main menu here, Sublime Text 2, if you come into preferences, you will now notice down at the bottom is a Package Control, where Package Control previously was not there. Now, if I click Package Control, it's going to give me this little sub-menu up at the top with things that I want to do with packages. Do I want to add packages, delete packages so on and so forth? So, what we want to do is actually install a package. We want to install the processing package. So, I'm going to go ahead and click install package and you'll notice that a list of packages has come up. All I have to do is start to type in processing and you'll notice it's the top result. So, it says, processing a Sublime Text 2 package for the programming language processing. So, I'm going to go ahead and click that and notice down here at the very, very bottom, it says package processing successfully installed. Now, what that means is that not only is the processing package installed but I can now click the bottom right-hand menu and you'll notice that processing has now come up as a language in the language selection list. So, I'm going to go ahead and click processing and I'm going to start to get things like color coding and all of that. So that's super fun, but it even does some other stuff. You might notice that when I first wrote this code I typed void. I typed setup, shaven minutes off my life, man. I want to do things quicker. So, what the bundle does is packages a lot of processing's features into shortcuts. So, for example, I can actually delete all of this code, and let's say that I want to do setup. All you have to do is type S-E-T, and you'll now notice that it gives us a list of actions that we can call. So, I want to go ahead and do set up, I go ahead and hit Enter, and you'll notice it spits out my void setup function, my void draw function. So, I don't have to keep retyping that code anymore. I actually can use that shortcut to do stuff. So, again, let's say I wanted to do a For Loop. You can go ahead and say For. Again, you'll notice that it pulls up the sub-menu, I can go ahead and click Enter, it automatically spits out the structure for For Loop, and it does tab highlighting. So, you'll notice it says, integer i equals zero, that's fine. If I go ahead and click the Tab, you'll notice it moves on to the zero. If I press Tab again, I could type in 100. If you press Tab again, it puts you in the middle of the For Loop. So, this idea of not only executing shortcuts but being able to tab through those shortcuts is super-helpful. So, I want to make a rectangle, and you go and click Enter. Hey, where do you want it on the x axis? From before, 20 on the x, Tab; 20 on the y, Tab; 50 for width, Tab; 50 for height. So, Sublime Text 2 makes it super easy to write code just quicker, easier, it's pretty, it's a game changer. Okay. So, we've got processing installed, we've got Sublime Text 2 installed. There's only a couple more things that I would say that we need to do. One of the last things is that we're actually going to write code in Sublime Text 2, but when we click Build, we need to create this bridge between processing the application and Sublime Text 2. So, what the last thing that I need to do is actually launch processing again, and you'll notice under Tools, there's Install Processing Java. You need to do this, other words you can write all the code you want all day long in Sublime Text 2 and nothing is going to happen because you haven't actually installed Processing Java yet. So, I'm going to go ahead and click Install Processing Java. It's going to say, "Do you want to install it for all users?" Blah-blah-blah. "You may need a password." I'm going to go ahead and click Yes, I'm going to go ahead and put in my password, I'm going to go ahead and click Okay, and that now has successfully installed Processing Java into my environment. So, at this point, I actually can quit processing again, okay? Because now I've installed Processing Java. So, if I close this window, and if I close this window, and if I close this window, and let's go ahead and save this file. Another thing that I would say that's kind of nice about processing IDE is that when you actually click Save File, it would create a folder and then put your file inside of that folder. In fact, that's how processing works. Processing has to have a sketch saved into a folder with the same exact name. So, if your sketch is called JoshuaDavis.pde, then your folder needs to be called Joshua Davis otherwise you'll get compilers. Sublime Text 2 doesn't know how to do that yet, it knows that it can save this file, but it doesn't know to create the folder for. So, that's one I would say mild annoyance with working with Sublime Text 2. So, let's go ahead and create a new folder on my desktop. I'm going go ahead and call this folder, let's say it's called Test One, right? Now, this is typically what I do, is I will open up Test One and I will create a new folder called Build, okay? I will then take this code that I've written, in this case I don't want this For Loop, this rectangle is fine. We're not going to cover draw just yet. In our original file, we had it with a fill of orange. I'm going to go ahead and save this now. I'm going to go ahead and save this on my desktop. I'm going to save this into Test One folder, and then I'm going to save it in the Build folder, and I'm just going to call this Build.pde. Okay. So, let me just move this to the side and let me just show you my folder structure here. So, we've got Test One, we've got Build, we've got Build.pde. So now at this point, you can actually come to tools and you can click Build. If I click Build, what it will do is actually run Processing Java, and you'll notice that I'm viewing the visual results just like I did in the processing IDE. Okay. Now, there's a couple of things that you should be aware of. I'm going to go ahead and quit this. One is Josh. Why do you do this as Test One, Build, Build.pde? Because if I want to make a bunch of mutations of Test One, all I have to do is drag and copy, drag and copy, drag and copy, drag and copy, right? So now I've got five tests of maybe this initial sketch that I had developed. But instead of, how do I put this? Because the sketch name has to be the same thing as the folder name, if I did this kind of copy and duplication, I would have to go and rename the pde file, test1.pde, test2.pde. Again, shaven minutes off my life man. I would much rather have this kind of nesting, so that way I've got Test One. Inside of Test One is Build, and inside of Build is Build.pde. So, I never have to rename Build.pde. So, I can duplicate that initial sketch and not worry about having to rename my pde every single time I make a new mutation. That's just me and I'm crazy. Now, this class is going to be fun, fun class. Another thing that you should notice is that something that happens in Sublime Text 2 that doesn't happen in processing IDE, and that's this build-temp directory. So, every time I build a file, it's going to build this Build.temp directory, okay? In a little bit here, I'm going to show you some shortcuts for how to just delete those files so that you're not accumulating all these Build.temp files. Unfortunately Sublime Text 2 is always going to generate that build.temp file, and there's no way to turn it off inside of Sublime Text 2. Again, processing IDE doesn't do that. Processing IDE has no reason to create this build temp file where Sublime Text 2 does, okay? So, we now have processing downloaded, we have Sublime Text 2 downloaded, we have the Bundle installed. We are learning about shortcuts inside of Sublime Text 2. We opened up the processing and we installed Processing Java. In the next video, I'm going to show you some further steps inside of Sublime Text 2 as well as some essential apps that I use only on OSX, and we'll talk about why and how these are helpful. See you in the third video. 5. Final Environment Setup Tips: Okay. In video three, I want to outline just a few more things that I do as part of my environment setup. Now, we've got this file that I just whipped together very quickly, we call that test one, build, build.pde. You can see here from the code we're setting a fill of orange and we're drawing a rectangle. Now, I have that same exact file opened in both Sublime Text 2 and Processing.The reason why I have done that is because there's a difference between these two programs when you actually build the code. Inside of Processing, if you click this icon, it's executing run but if you highlight Sketch, you'll see that run is actually Command+R. So, I can actually bang out a bunch of code, I can press Command+R and that's going to compile my code and it's going to run and we can view the visual results. So, if I come to Processing and press Command+Run, there it is. Unfortunately, in Sublime Text 2, if you come under Tools, it's actually Command+B for build. So, I find this a little bit mildly confusing because in Processing it's Command+R and Sublime Text 2 its Command+B. I had spent like a year working in the Processing IDE before using Sublime Text 2 and so my brain is wired a certain way. I would be writing code in Sublime Text 2 and I would press Command+R and it would do something completely different. So, I actually want to change the preferences in Sublime Text 2 so that build is Command+R just like it is in Processing. So, that way I can work between these two environments and I don't have to worry about remembering, Command+B in one and Command+R in another. So, what I'm going to do is, I'm going to come to Sublime Text 2 and under preferences, you'll see Key Bindings. Now, you'll see Key Bindings for Default and Key Bindings for User. Now, I'm first going to open up Key Bindings for Default and you'll notice this huge document opens up. You'll see here you can move this and there's a lot of different key bindings associated with Sublime Text 2. Now, I'm an individual user. So, I want to open up Sublime Text 2, Preferences, Key Bindings, User. When you do that, you'll notice this document's blank. You haven't specified any specific user-related key bindings. So, what I want to do is, I want to go to Default and I want to find the binding for build. So, I'm just going to do Command+F for find and down here at the bottom, you'll notice I typing build and I click find. When you click find, you'll notice that these guys highlight right here. Sure enough, this is the one that I'm looking for on line 232, keys, super plus b or Command+B is the command of build. So, I'm actually going to select this line right here, not the comma at the end, the comma's only if there were multiple Key Bindings that I want to set, but I'm always setting the one. So, I don't need the comma at the end. I'm going to go ahead and press copy. Then I'm to head over to the user-specific key binding and I'm just going to give myself a little bit harder turn and I'm going to paste. So now, I have pasted build into the user-specific preference. Then I'm just going to change this to super plus r.So, that way I'm not messing up default, default loads but then it's going to load this user-specific and then override the default. So now, if I actually click Save and then come to Tools, you'll notice that build is now set at Command+R, the same that it is inside of Processing. So, I can close this, I can come back to my code and just press Command+R and it executes just like it would in Processing. So, that's just another thing that I like to set up so that these two are similar and I don't have to remember to build that's one thing and one in one thing in another, I don't want to do that. So now, it's Command+R in both environments, which I'm super happy about. Now, Macintosh specific applications. For your Windows users, you'll understand here in a second why this conversation doesn't apply to you. I'm writing code and I like to have things organized a specific way. So, Mac users really need this application called SizeUp. So, if you actually open up a browser and typed in "size up," you'll notice it's the top link, "Irradiated software, SizeUp," and it's the missing Window Manager for OS X. PC people, you've got this built-in. You take a window, you drag it to one side and it snaps and you can organize things that way. On OS X we don't have that. So, SizeUp is a super efficient for organizing your workspace for writing code in my opinion. So, once you have SizeUp installed on OS X, you'll see what all the shortcuts are here, but it's super helpful I can say I want this to the left, I want this to the right, I want it to the top, I want it to the bottom, I want it for each of the corners or you can press to actually have it centered. So, it's just some nice keyboard shortcuts for the Mac to help organize things. So, you'll notice that just like I have here, got this little Processing window on the upper right, I've got my finder in the bottom right and I've got Sublime Text 2 in the left. If I were to start a new document again, I might not like this idea of having to toggle back and forth and tabs, I can actually pull this aside and then position it to the right-hand side of the screen and then work on two documents side-by-side. So, I find using SizeUp to be super helpful in organizing the space in which I write code.Second app that I really like is Caffeine. Caffeine you can get from the App Store and it puts a little coffee cup in your task tray. That is to not make your computer go to sleep. Because it's all hopped up on caffeine. So, if I fill the coffee cup with caffeine, it just means that I can walk away or I can watch something and I don't have to worry about my computer going to sleep and my screens going black. This is the same as launching your System Preferences and then going into Energy Saver and then inside of Energy Saver, you're going Never and he goes, are you sure? You click okay. You say Never and then you say, "Okay, don't put hard disks asleep." So, rather than having to do that every single time, Caffeine just overrides this and basically just always sets it to Never always sets not setting things to sleep. So, I like having Caffeine installed just so that I can write code, make pauses when I need to, step back when I need to walk away when I need to and then not have to worry about that everything went to sleep while I was briefly absent. So, two apps that I really like SizeUp and Caffeine and again Caffeine, you just get from the App Store. So, you just type in Caffeine and it will install. So, we've talked about this third video, Caffeine, we've talked about SizeUp. We've talked about build system. Now, the last thing that I want to talk about a Snippets. Snippets gets into a more expert level of writing code but I want to give you at least one Snippet and show you how to use it. You can see why it's super helpful, and as you get more comfortable with working with code and specifically with Hype and with specifically Sublime Text 2, you're going to find that Snippets are just awesome. So, let me just quit and do some stuff here. Now, what a Snippet is, let's say that you always set up your environment a certain way. For me, I find myself always doing the same thing which is, I'll say, void setup and I'll say I want the size to be 640 pixels by 640 pixels and maybe I want the background to always be black and maybe I always want smoothing. Maybe I always want a draw function. I find myself in processing always writing the same stuff over and over and over again. What Snippets allow you to do, is package up stuff that you as an individual content creator type on a day to day basis, package up all that stuff into a snippet. So, let me just show you what a snippet look like. This is my initial snippet and it's geared towards using hype and weren't obviously not up to the videos where we're covering hype just yet but what's nice is that I want you to install the snippets so that later when we start covering this content, we can execute this the shortcut. So, remember when we typed in a for loop and it automatically spit out the for loop and it even had all the tabbing and allowed you to jump to all the different tabs.? That's a snippet. So, this is just a setup snippet that I always use with hype. Again, what's nice is you can open up the snippet inside of sublime text two and you can see how things are structured. You can see how to execute the tab code, so on and so forth. Now, in order to install this snippet, we need to put it into processing's snippet folder and it's a little bit buried. So, what I want you to do is actually go to folder and then I'm going to type in ~/Library. I'm going to go ahead and click Go, and you'll now notice that you're now viewing the library folder. By default in OS X, this library folder is hidden. So, if you just open up your hard drive and try to find the library folder, you can't because it's a hidden a folder. So, by going to go, connect to folder ~/Library with a capital L we now can see the library folder. Now, inside of this library folder you'll see Application Support. Under Application Support, you'll see Sublime Text two. Under Sublime Text Two, you'll see Packages and you'll see that these are all of the packages of all the different languages, the one that we just installed, right here processing. So, if I click Processing, you'll now see that there's a folder called Snippets and inside of Snippets are all of these snippets that you can use within Sublime Text two like, setup, that four loop, rectangle. Now, somewhere I'm going to give you this snippet file and all you have to do is just copy it to the Snippets folder. So, it's now been copied in there. This is called hype_set up so, if you were actually to go to the Hs, you would see that it's right there, hype_setup. Now, what that means is, is I can go back to Sublime Text two and I can just go ahead and start to type this shortcut. So, down at the bottom. I need to make sure that you have Processing selected, since this is a processing snippet. HY and look, hype_setup comes up. This is the snippet that we've just add it and if I go ahead and click Enter, you'll notice that it builds my setup, it builds my draw, it constructs my size like I always like it. Do I want it to be 640 by 640? I don't know. Look, I can click Tab, I can click Tab. Do you want it to be 3D? No, not just yet, so, I can go ahead and click Delete. So, now this processing sketch is not going to be using 3D coordinates. Line three, we totally haven't covered yet but again, I can click Tab if I wanted to change the background color. Do we want to use 3D? No, we actually turned that off. So, I can click Delete. Auto clear, do you want that? Yes or no? If you do want it, do you want it to be true or false? I click Tab again. Down in the draw we're firing draw stage. Am I recording this? We'll talk about outputting to image formats. In this case, this would render out 900 tiffs, which would be equivalent to 30 seconds of film. So, do you want to say frame? Maybe yes, maybe no. I'm going to say Delete. So, it's a way for, if you find yourself getting comfortable with programming and you find yourself doing stuff over and over and over again, rather than having to type them over and over again, you might be interested in creating your own custom snippets. That way you can just start to partially type something and go yeah, I want to do hype setup and click hyp_setup and you know that it's always going to auto-generate stuff that you're constantly reusing. That wraps up this section, this is environment setup. So, again, we installed Processing, we installed Sublime Text two, we installed Processing package, we learned about some applications that I like using, we got our environment setup. So, that now when we move on to section two which is just an introduction to processing and hype and what these two things are and why they work together and how they're slightly different than writing code and processing and so on so forth. That'll be the next section but at least now we've set up our environment exactly how I work. So, as we start to write code, we've got some of the shortcuts, we've got some of these processes to make writing code just a little bit easier, a little bit more efficient and fun. So, see you at the next section Intro to Processing and the Hype Framework. 6. Introduction: Processing and HYPE: For the next step, we're going to talk about processing and we're going to talk about writing code and processing. All that Sublime text to is, it's an authoring environment. It's a text editor. It's where we'll actually write all of the code that does whatever it is that we want to do. When we actually write the code and run it, what happens is, is that code is then compiled by processing and something happens on screen. So, if I say I want to set up a canvas, I want the background to be red and I want to draw a green square, that's stuff that will actually type inside of the Sublime Text-to editor. When we actually click Build, processing is going to build it, it's going to read those instructions and actually display something on screen. Now, what is hype? Hype is that third thing which is, let's say that we want that green square over and over and over and over again because we really love green squares. So, we could create something called the green square class. So, instead of having to write all the code for make this rectangle, make it green, put it here, we'll actually write one line of code that says "Green square here". So, it's a shortcut. Hype is a series of shortcuts for doing larger, more robust actions inside of processing. 7. Download HYPE: Welcome to Section two. Very emotional. Section two. We're going to talk about the HYPE framework. So, we're working in processing, but I also work on this external library called the HYPE framework, which is a collection of things that do things. Okay? Now, if you go to, you can see the project site here. You can see all of the different examples that I've been publishing, but this is only the site for the project. The actual source code exists up on Github. So, you'll see up here in the upper left hand corner, there is Okay? So, you can see URL here Now, in the project steps here on Skillshare, I've actually put a different URL. I've put tree staging. That's because the master build of the code doesn't contain all of the changes that we're currently working on. So, if you see right up here, it says branches. There's one branch called staging here and if you click staging, this actually is the most up to date collection of the code. Again, the URL is down below in project steps. Now, if you're new to coding completely, you can kind of ignore a lot of the stuff. We're going to talk about it in a little bit here. The only thing that you're really interested in is right here. It says download zip. So, if I go ahead and click download zip, you should notice that it's downloading the zip file onto your desktop. Now, that zip file is going to contain everything that exists, that you're seeing here on the website. So, for example, it's got a folder for documentation that we're working on where we're documenting some of the bits of the source code. It contains an examples file. The examples is where I'm taking certain things that we've written and I'm just making some barebone examples to help you through the process. Java, our source code. PDE, our source code. Website, that actual website that you view right here, that's actually when it's updated, it actually lives in the website folder, and there's obviously a bunch of other stuff. Okay? Once you have this zip file downloaded, the only thing that you're going to be interested in 100% in order to make all the examples that we're going to be making is this one file called HYPE.pde. So, HYPE.pde contains every single class that's in the library. It contains every single thing that we're going to use for all of the projects that we're going to make. So, after you've downloaded this zip file, just look at that HYPE.pde because that's the file that we're going to be using in every single project that we make. Okay. I'm going to end this video. I'm going to create a new one where we talk about some additional stuff that's inside of this zip file. See you in the second video. 8. Project Steps 2,3,4: Okay, second video. So, we have the zip file downloaded. We have it unzipped. Here, I can show you the contents of the folder, and again, you see it replicates exactly what you're seeing here on GitHub. There's the documentation folder, here's the examples folder, so on, and so forth. Again, here's what we're totally interested in, is HYPE.pde. So, now, in terms of the project steps that you're seeing here on the Skillshare website, we're going to cover at this point, two, three, and four. Now, in section two of the project steps, it just basically says, hey, dig around this HYPE staging folder and just get familiar with some of the stuff that's in here. Two things that are of great interest: obviously, the HYPE.pde, I told you we're going to use that in all of our projects, but then, this examples folder. This examples folder has more examples than I actually have on the website for couple of reasons. The website publishes the sketches to Processing.js, so it runs in the Canvas object HTML5. Not everything in here is supported by Processing.js. So, there's some examples I can never put on the website because they just won't work in browser. Now, some other things that you should take into consideration when looking at this examples folder, and I talked about it a little bit in the project step. For example, if I go to Swarm, you'll notice that I give you, actually let's change that. Let's say, HOscillator, because I know HOscillator has a lot of examples in it. HOscillator, you'll see that there are 14 examples. Usually, the top ones, example one, is the most bare bones example. It means that I haven't introduced a lot of other things, I've just set up an example that simply illustrates what HOscillator does. However, all of these classes can actually work together. So, for example, in this class, we're going to cover a grid layout, where you can mix a grid layout with ColorPool, with an Oscillator, with HPath. So, you can combine aspects of HYPE into one folder. So, the first example here, example one, if I were actually to publish this, again, it's just showing you what oscillation is. It's a wave, it's a way to describe a wave. As you navigate down through the example projects, they're going to get more robust. So, for example, this one is only 50 lines of code. If I were to jump to number 14, for example, you would see number 14 is 76 lines of code. However, if I actually run this movie, in the case of this particular one, I'm actually using 3D. So, I'm oscillating these 3D boxes. So, just take into consideration that the examples folder, usually example one or the examples towards the top, are the most simplest expression of that particular class that you're looking at. As I go down, I give you some suggestion ideas to mix and match possible classes together. So, by all means, check out the examples folder, because there's a ton of stuff in there that, again, is not represented on the website. Now, one thing that you may want to start with is this particular folder right here called H_BASICS. H_BASICS tries to document the foundation essentials for working with HYPE. So, what is method chaining? How do I draw shapes? How do I define where an anchor position is? How do I rotate around an anchor? How do I attach images? How do I attach SVG? So, H_BASICS is really the starter folder, where I'm giving you some of the things that, hey, in order to really get rocking, these are the things that you should really digest first. So, outside of the examples folder, HYPE.pde really is the file that we're going to use across all of our sketches. Now, you'll see in the project, steps number three talks about how we're going to create our folder structure. So, for example, I might create a new document, and then, let's just say that this document is called project 1, and in that, I'm going to create a new folder called build. Inside of that build folder, I'm going to copy HYPE.pde. If I were to open up Sublime Text 2 and switch this to Processing and click save, I'd go to my desktop, I would go to project 1, I would go to build, and I would call this build.pde. Now, I'm not going to write any code, but I'm showing you the structure that inside of this build folder is your build.pde and HYPE.pde. Now, what is HYPE.pde? I'm going to talk a little bit about project step four here in a second. What HYPE.pde is, in fact, if you try to open this up in Sublime Text 2, you'll notice that we're going to be waiting for a little bit. HYPE.pde contains every single line of code inside of the HYPE universe. So, what is the HYPE universe? For example, if you look at the pde folder, these are all the different classes that we have. Now, check this out. See? It's all on one line, and actually, if you were just [inaudible] , you'd be there forever. So, HYPE.pde is actually every single one of these 53 pde files, but with all the hard returns stripped out and minified down into one line. So, this is the HYPE universe. So, for example, let's say, we talked about HOscillation. If you open up HOscillator.pde, this is actually the code that contains all of the instructions that deals with any kind of oscillation that you would want to use in one of your projects. So, it just so happens that this one file right here, which is 244 lines of code, is, all the tabs are removed, all the hard returns are removed, and it's buried somewhere in HYPE.pde. So, again, just reiterating, HYPE.pde is every single one of these individual pdes placed into one file. So, as we add new classes, we add onto HYPE.pde. You might want to keep checking back to the GitHub site, you might want to listen on Twitter to see if I announce any new classes that we've written, because if so, HYPE.pde will get updated. Now, step four in the Skillshare class, JAR versus pde. What the heck does that mean? There are a lot of external libraries that you can use with Processing. The problem is is that you cannot use an external library and output to JavaScript using Processing.js. You can't use any external library that's packaged as a JAR file, and you can't output to Processing.js, which means, all of that functionality of being able to output to HTML5, being able to view it on my iPhone, being able to view it on an iPad, all of that gets thrown out of the window when you actually build the library as a JAR file. So, this is why we have decided to make HYPE a bunch of pde files. By making them pde files means that we can publish to HTML5, we can publish to Processing.js. Now, you might be wondering, well, how do I publish to Processing.js? So, if you actually launch Processing 2 here, you'll notice that up here in the upper right hand corner, it says Java, and that's the only mode that's there. But you can click Add Mode, and you'd get this little mode manager, and you'll notice right here, JavaScript mode. If you actually click Install, it's going to download JavaScript mode into Processing 2. So, now, if I actually close this, I can write a bunch of code, I can publish to Java when I click Run. You know what? I might have to restart. Processing 2, and now, we have JavaScript. If you actually click JavaScript, now, you could actually open up your sketches and click Build. It will actually package up all of the files for use in a web browser. It'll generate the HTML, it'll spit out the JavaScript, and now, a lot of these sketches that we make, we can actually load and view in a browser. So, project steps two, three, and four, we talked about looking at the zip file, digesting all the content there, lot of good stuff, lot of good examples. Project step three, locate HYPE.pde. Remember the folder structure that we're going to use because we're going to use that folder structure in every single one of our projects. JAR versus pde. I don't want to use a JAR file, want to use pde so that you can actually publish to the web. Now, in the next video, we're going to talk about HYPE, and specifically, we're going to talk about what is Fluid Interface and what is method chaining, because these are concepts that are actually part of HYPE's foundation. So, in the next video, we're going to talk about what happened in the AS3 version of HYPE, and what has happened in the Processing version in HYPE. See you in the next video. 9. Java versus JavaScript: Changed my mind. Before I move on to the next section, I just want to show very quickly the Java versus JavaScript scenario. We were looking at HOscillator and if you actually open up example one, into Sublime Text 2 for example, here's the code. And if I click "Build," I'm actually viewing this content in Java. Okay, so this is Java running right here, okay. Now, if I were to take that same exact file, example one and actually open it in processing two, okay. You can see both of the editors here, right? These are both identical, and again I have Java selected in the upper right-hand corner. If I were actually hit "Click" and run this, okay, out of processing two. Again, these two are identical, you're running them in the mode of Java. Okay. However, if I now close this, and I run over here to mode and switch to JavaScript, okay. I want you to watch this folder here. The fact that I switch to JavaScript, added a file, and when I actually click "Run," what you'll notice is, is that it actually publishes it to the web. You'll notice that it's made a new file called web-export. It contains the index.html, it contains the PDE file that is performing this animation, and processing JS which is interpreting your PDE file to run in canvas in HTML5. So look, these two are absolutely identical. The one running in Java and the one running in the browser, the performance is the same. So again, that's just one reason why we decided not to author Hype using the JAR format. We decided to use the PDE format so that we could take advantage of being able to publish our content to JavaScript. Okay, see you in the next video. 10. HYPE AS3 / Project Step 5: What I want to do now is actually look at how the old version of Hype was actually structured when you are writing code. Now, the old version of hype was developed for Flash and ActionScript 3. It was a fantastic joint project between a good friend of mine Brandon Hall and myself. It performed the same service which is, I want to do stuff and that stuff can be packaged up into separate classes to make life easier. So, it's going to be helpful to look at how the old version of Hype was constructed because it'll give you some insight in the departures that we took when we went to do the processing port. So, imagine for a moment that we want to draw a grid on screen. In the Hype AS3 version, I might do something like this where I would say var numAssets is an integer equal to 25. So, that's a variable representing the number of things that I want to touch on screen. Now, we had a GridLayout in the AS3 version and the nice thing about the GridLayout is you could call GridLayout, pass it some arguments and that those arguments would be information in how to visually construct the grid on screen. So, to do that, I might write something like this where I would say, var layout is a GridLayout equals new GridLayout. Then, you might see in some of my examples, some numbers being passed to GridLayout. So, it might be something like 50,50,100,100,5. Now, probably the biggest complaint with this code is that you would have no idea what those numbers represented. No clue what 50, 50, 100, 100, 5, is. You'd actually have to open up the GridLayout class, look at the function and then look at what those arguments are and what they set. So, that meant that in all of the examples, I'd have to put a comment telling people what those five arguments were. So, it ends up that the arguments or xStart, yStart, xSpacing, ySpacing and columns. Now, since we're building a grid on screen, the first two arguments were, where do you want that grid in its entirety to exist on screen? So, I would say, "Okay, well, I want it to be 50 pixels, start at 50 pixels on the x-axis, start at 50 pixels on the y-axis. The next two arguments, xSpacing and ySpacing would define the spacing between each of the cells in the grid. So, it would start attaching the first item and then 100 pixels later it would attach the second item. Now, the last argument is columns. So, in this case, we're building a grid that contains 25 assets, and so if you take 25 divided by five you get five. So, it knows that it's going to do a five by five grid by taking 25 divided by columns. So, that fifth argument would describe the number of columns that are inside of this group. So, I think looking at this gives you some insight into how we took a departure when we decided to do the Hype Processing port. So, in the next video, we'll pick up the same exact structure but we'll showcase how it's different in the process important. 11. HYPE processing / Project Step 6: Okay, so now we are addressing step six in the project guide, and this is really addressing what changed in the processing port of HYPE. Now, the HYPE AS3 version, great project between Brandon Hall and myself. However, when I decided to leave working in Flash as a development tool, and really wanted to move on to processing, and having this desire to port the HYPE AS3 version into the processing environment, it was an opportunity for me to really address some of the things of how the code was structured just to make it easier for me and for others. So, the processing port is a project between myself and a wonderful gentleman in Manila, Philippines, James Cruz. Again, we started to look at success stories in the programming community and was there anything that was beneficial in the programming community that could make the processing port of HYPE better than it was before. With that said, this idea of Fluent Interface, and this use of Method chaining would redefine how the processing port of HYPE is fundamentally different. Okay? Really, this was an opportunity for us to look at the jQuery community and say, "Yeah, this is the way to go." Now, these links have been provided in the project steps so you can read up on fluent interface, you can read up on method chaining. But, let's just look at what we did in the HYPE AS3 days and how that code has changed in the processing port. So, let's say I open up a new document here, I'm obviously going to set processing as my language and then I'm just going to paste the initial code from the AS3 days. Var numAssets 25, var GridLayout, and then we talked about that line two, that need to put in the comment so that you can give some instruction to what those arguments are. Now, what fluent interface and method chaining allows us to do is, actually write this code a little bit more elegantly. So, let's just say that this is HYPE processing. Okay. If I were to write that same code but in the HYPE processing port, I would probably do something like this, integer numAssets equals 25, okay? So, that's written a little bit differently but still does the same thing. I'm creating a variable that's going to represent the number of things that I want to draw on screen. Now, if you remember, we need to call the grid layout class. So, I'm going to go ahead and say, HGridLayout, layout equals new HGridLayout, like so. Now, let's just talk about this. Anytime you're using HYPE specific calls, most of the methods are going to be preceded with an H. So, HColorPool, HGridLayout, HOscillator, so it's just a way for us to identify what's regular processing code and what's HYPE specific processing code. So, here I'm creating a variable called Layout, I'm casting it as HGridLayout and I'm saying it's a new HGridLayout. Now, at this point, you may be thinking, "Oh, yeah, Josh is going to put a bunch of numbers in there." No, I'm not. I'm actually going to define the variables a little bit differently. So, what I'm going to do is, is on the next line I'm going to say, "Hey, Layout, I just want to let you know that you have this variable called start X and that's going to be equal to 50." Okay? If I was to copy and paste this and then change this to start Y 50, I might say layout dot spacing, all right? Up at the top, it was X spacing and Y spacing. In the HYPE processing version I'm just going to say layout dot spacing, and then I'm going to say 100 on the X, 100 on the Y, and in the last argument, I'm going to go ahead and say, "Hey layout the columns is five." Okay? So, this code now conceptually is a duplicate of what the AS3 version is going to do in terms of calling a class and passing it some arguments. Now, you may be saying to yourself. "Wow, okay, that's a lot more code than the one up above." The one up above you only have it in three lines, but we can actually make this shorter by showing you what method chaining is. But, before I do the method chaining version, let's just talk about some stuff. One is, you don't need to put a comment anymore because you're actually calling what it is that you're setting. So, you're saying, "Hey, layout dot start X number." So, obviously, line 12 is setting start X position. So, structuring the code this way means that you're putting in identifiers to what the numbers actually are. Which I think, makes this a lot more helpful for beginners. Not only that, but you could say that you wanted to define start X here, it doesn't have to be this rigid order up above. Remember, I told you the first argument was always X start, the second argument was always Y start. So, it had to be in that order. By developing the code this way, you can specify in any order that you actually want, and it ends up that each class actually has some default settings. So, if you actually decided to not write X start, Y start, and you actually ran the code, it would actually work because the class itself has some initial numbers for start X and start Y. So, in my opinion, this is a great new addition to HYPE. This idea of helping the beginner understand what the numbers are associated with each class. Now, let's get back to, "Josh, up above it's only two lines of code and obviously, this is a lot more." The interesting thing is, is that we can do this method chaining. So, if you want, you could write the code this way. However, you could also write the code this way which is, you could say, integer numAssets is equal to 25, and then you could say, HGridLayout equals new GridLayout and then after you do the open paren closing paren, you could say dot start X, you could then say dot start Y, you could then say dot spacing, and then you can end it with dot columns. So, that is method chaining where you're calling a method and then chaining each of the arguments that you want to pass that method after it. So, now we're back to using two lines of code, all right? So, you're saying, "Hey, I want to do a layout, and dot this, dot this, dot this, dot this," and you could just keep going. So, this idea of using method chaining, again, you could put this in any order or you could do spacing first, then start X and start Y, you can rearrange how you write them. It's not as rigid as the one up above. Now, in a lot of my examples, you might see something like this, where I actually start with the code this way, but I actually do this which is, I'll put the closing semicolon on its own line at the end, and then I might do hard return, tab, tab, I'm just putting in hard returns and tabs just to clean up the code, so that the argument is just are a little bit easier to read. However, all three of these will work, and all three of these are doing exactly the same thing. So, again, you could do it this way, where you call layout and then say layout dot argument, layout dot argument, layout dot argument, or you could do the method chaining way of writing it, where you're calling layout and then chaining the arguments after. This obviously, is the same exact thing except for I put in hard returns and tabs so that I can just visually look at the code a little easier. You're going to see like with some classes like HOscillator, you can actually specify a lot of arguments in HOscillator, and if it has a lot of arguments, that line 20 could actually be really long. So long that I might not see what's at the end. So, doing the line 24 through 30 you'll find is what I often do, just because it makes it a little bit easier to visually look at all the arguments that I'm passing into the HGridLayout. Okay. At this point, we've done section one which is environment setup. We're now wrapping up section two, which is just an introduction to what is HYPE for processing and what, again, it is is a whole library of things that do things. So, that if you want to work with color, we've got a color pool. If you want to work with grids, we've got a grid layout. So, it's a series of classes that help you do things quicker and more efficiently so that you're not having to write this code all over again. Now, we're going to move on to section three. Section three is, drawing visual assets. In fact, we're actually not going to start writing real code for our project until step four, where we're actually painting to the screen. So, step three is, we're going to draw our visual assets. So, we're going to toggle over to drawing some artwork. How do we prep that artwork? Then we're going to save that artwork off to the side because when we go to move into section four painting to the screen, we have some banks of artwork that we can actually start to paint with. So, section two, just an overall universal view of what HYPE is, how it's going to be easy to use, and next let's move on to drawing some visual assets. See you in the next section. 12. Introduction: Drawing Visual Assets: So drawing. Really, this isn't complicated. It's just how do we prep the artwork that we're going to make. The type of programming that I make, the type of programming that we're going to make together is completely artwork agnostic. So, this is the part that gets really exciting because the program is going to randomly generate a composition based on the type of artwork that you create. I got this when I was in Malaysia, and like think of those, not the whole composition, but think of these as individual assets that could be the drawings that we make that get populated into the programming that we write. Look at this stuff, these two are from Istanbul, Turkey, and look at the patterns of these warriors. I may make this entire drawing, but I may break this up into six different assets. So, sometimes I only have to be inspired by one drawing but I'm going to break that drawing up into six different abstract assets. Specifically, I'm going to be outputting them from Illustrator to SVG, which is scalable vector graphics, because we can pull those SVGs into processing quite beautifully and we're going to use these drawings to randomly generate compositions. You want to do something with kittens and chainsaws? Kittens and chainsaws. 13. Drawing Visual Assets: Okay, welcome to section three, Drawing Visual Assets. This section, we're going to talk about mapping artwork to the programming that we write. So, this has been my kind of thinking for years and years and years. There's people who use only code to draw the visual assets. So, for example, there's a huge group of people that just draw with rectangles, lines, and ellipses and that's fine. But processing, obviously, supports working with images, it also supports working with SVG, Scalable Vector Graphics. So, what I want to do is actually draw vector base assets that I'm going to map into these programs that we're going to write. So, for example, grid layout. Why don't we make a grid, but that grid is actually visually hand-drawn assets? So, right now you're seeing some stuff on screen that I'm going to spend some time drawing. I am a total freak when it comes to hunting down cultural aesthetics and content. We could spend this entire class just looking at stuff that I have collected around the world. So, for example, let's I check this out. Here's a book gram 4000 Flower and Plant Motifs. Again, this is just filled with different plant motifs. For me, this could be a start of a departure, a start of inspiration, or maybe there's stuff in here that is going to work perfectly just as is. So, I collect a lot of books that I'm constantly inspiration hunting. But sometimes, I just sit down with a sketchbook and I work out ideas on paper. So, there's a floral motif that I just drew on paper. Maybe I sit down and draw the house plants that are in my house. And again, I'm looking for form, I'm looking for shape, I'm looking for texture. Maybe I sit down and I just work out some sugar skulls, and so, these are some ones. Initially, I got tattooed but the initial kind of planning was just sketching on paper. Sometimes, I'm just thinking about geometric shapes. So sometimes I just sit down and I'm just thinking about some geometric forms. Or you could even go outside, and this is from architecture, so, there's a window awning rate here, the building number was 314. These are frames from a window, and this one had a sign. Sometimes, I'm just getting forms from an abstracted view of just life around me, in the case of this being architecture. I spent a great trip in Istanbul, Turkey. So the last project that I did was based on these warriors that I ended up buying in Istanbul, and just sort of re-imagining some of these forms from these warriors. Again, I'm thinking about them abstractly. So, I may draw an entire composition, only to tear it into individual sort of abstract parts. So, right now, you should see some stuff on screen. This is actually from a book that somebody sent me knowing that I was going to freak out, Mongolian National Ornament. So, the scan that you're seeing on screen is actually from this book, and obviously, I've lost it. This one is just bananas. Some of the stuff that's in here, again, is just an interesting start for a conversation. But it's a mystery, it's a mystery. I have to warn you, I have no idea if this is going to work. I think it's going to work. I've done this long enough to know that I think this is going to work. But a lot of times, I sit down and I draw stuff with the sole intention that I'm going to map it to a program, and visually it doesn't work out. So, there's that kind of trial and error. This page for me is pretty safe. It's what you're seeing on screen right now. I think that this is going to work pretty well. So, I've scanned it at 150 DPI, and now I'm going to go through the process of drawing it. I want to vectorize it, and of course, there's a lot of tools out there for creating vectors. Believe it or not, I'm actually going to draw this using flash, and there's a bunch of reasons why. I actually like drawing in Flash, because it's as close to freehand as I can get. And initially, I was a freehand user. I like this idea of being able to draw vector lines and stuff and then cut away. So, any time a line actually intersects, I can actually sculpt or cut away those sections, just by selecting and deleting. So, something that Illustrator for a long time didn't support. Now, it supports it with live paint, you can actually convert something into live paint and then you can go through the process of sculpting. However, Illustrator is also, for me, like an amazing vector tool, almost too amazing. Flash, in a lot of ways, is not amazing. I like that. I like the distortion that Flash gets me. So, you're going to see in this next video, I'm probably going to do a time lapse thing, or you're going to see me drawing very quickly so that you can see how I vector up one of these pieces. But what I love about flash is that, I'm going to use the pencil tool and I'm going to use a Wacom tablet, and the lines aren't perfect. You can see like I'm going to draw a line and they'll be a lot of distortion in the line, and I actually like that. I like that it's not perfect, because it gives it more of this hand draw feeling to it. I talked about records a lot. I still have a record player here in the studio, I got records hanging out up here. And there's actually an analog warmth to records, that digital audio will just never have. I mean, we can have this argument but that's the truth. I like that I've got this really technical process for generating the composition with programming, but it's using assets that are not perfect. They're using assets that are hand-drawn. If I want to do a circle, sometimes I'll hand draw that circle, so that that circle is not a perfect circle. I don't like to use the pen tool in doing perfect bezier curves, it's too clean for me. I like distortion, I like that my hand shakes, I like that sort of, it's symmetrical but it's hand-drawn, and then taking those hand-drawn assets and put them in a very pristine and orderly situation, like programming. So, next video I'm going to move over to the Wacom tablet. I am going to probably not have audio on. So, the screen that you're seeing right now is a Wacom's antique, and I'm going to be using that to draw. Also, I pick this up which is great, and it's a glove that's made specifically for working on this antique, because this antique is a monitor and it heats up. What will happen, is that my hand will tend to stick. So, what's nice is, is that this allows me to do curves without me having to worry about my hand sticking to the screen. So, if you are a Wacom user, I highly recommend the glove, the power glove, because you can get these nice fluid curves without your hand actually sticking to the surface. Whether it be this antique or even if it's just a regular Wacom tablet, the ability to not stick to the surface and do this kind of nice curves, is super helpful. So, I recommend the glove. So, next video, no audio, time lapse, and we're going to draw up one of these assets. I want you to watch how I use Flash to actually intersect and sculpt away these drawings I'm going to make. Now, I'm going to end this video with, you should be thinking what visual assets do you want to use to map to this environment? Again, it can be floral, it can be organic, it can be geometric. I'm going to obviously zip up some assets for you to use, so that you can see some of the drawings that I make. They'll be attached to the project steps as zip file downloads. But you should be thinking, "Josh is going to teach us this programming, and this programming wants to attach things on screen, what are the things that are being attached?" It's going to be drawings that you make. And that's where the individuality is really going to show through with all of the class submitted stuff, because the programming is going to be using your assets, programming is going to be using my assets, so on and so forth. So, each piece should be unique, because each of you are going to be mapping different assets into this environment. So, watch me draw, and think about, what are you going to be making to map into this environment. Okay? See you in next video. 14. Drawing Abstraction: I just wanted to take a minute to show this image on-screen. Here's a perfect example of a starting point of inspiration that gets abstracted. So, for example, this is that trip to Istanbul. So, I end up redrawing this guy, but maybe this becomes one of my visual assets which happens to be part of his arm. Notice that I don't use the faces. I don't want to use any type of imagery that becomes recognizable, where you go "Oh, that's a face." I may change, but I try to keep my stuff kind of abstract so that you don't know initially maybe what you're looking at. Look at this independent shape right here which just happens to be a selection of this torso. So, sometimes you can take one drawing and break that one drawing into six different assets, or five different assets, or whichever. So, keep this in mind, that when I say look for imagery to turn into assets, it could be one image. Then that one image, you could break apart into separate independent SVG files. So, again, this is just a quick example of how one drawing or two drawings become my content. Okay. 15. Drawing Time-lapse: - good. - All right. 16. Final Asset Prep: Okay. So you've just watched the previous video which was a drawing time-lapse. You should be seeing on screen now the artwork that we drew. Now, you might have noticed in the time-lapse, I actually started to block out some color in the actual drawing that I did. I do this because it helps me organize how I want things to be blocked in terms of color. Okay. So, for example, like maybe these particular shapes right here, I want to all be the same color. So, I've already done some initial greyscale blocking. Now, I need to get this out of Flash and actually get it into Illustrator so that I can output it to an SVG file. Now, if you're not drawing in Flash at all, if you're just drawing in Illustrator, then obviously you can skip this whole next set of steps. But what I'm going to do is actually highlight the drawing that I just made in Flash and then I'm going to go ahead and say File, Export, Export Selection, and when I say Export Selection, it's going to want to save that as a FXG file. Okay, and I'm going to go ahead and just put this on my desktop. Now, after I've done that, I can go ahead and minimize Flash or I can close it, and you'll see here on my desktop, I've gotten FMLA and I've got this FXG file. Now, it just so happens that you can open up this FXG inside of Illustrator, and when I do that, I can see that it's outputted all of the vector information. So, let me just clean up this document, let me go to the art boards and I'll make this a width of 300 and a height of 300, and I will simply center, try that again, Josh. Try that again, one more time. Let me just center this like so. Okay. Again if, I were to click View Outline, you would see that this is all vector information. Alright. Now, the thing that I want you to focus on at this point is actually the layers' palette, because this is super important. You might notice that there are seven layers inside of Illustrator, and the layers are actually compound paths. If you were to hide each of the layer and look at them each independently, you would see that the grouping, it's gone through and it's grouped all of the individual colors that I set in Flash. So, that's important, like you can see here all of the shapes that I made this particular dark grey have all been grouped together as one compound path. Alright. Now, another thing you need to take note of is that the top layer usually always is the stroke data. So, the fills or actually the bottom six, the top is this stroke information. Now, at this point, I can go ahead and click "Save as" and I can save this as a SVG document. So, from format, you just select the SVG and I'm going to go ahead and put this on my desktop and click "Save". You'll get this option palette that opens up, you can actually ignore all that stuff and just click "Okay". Now, I'm going to close this document and so now I have an SVG document on my desktop. So, what is SVG? Well, you can actually drag this to Sublime Text 2, and you would see very quickly that an SVG document is actually a text file. It's a text file that contains all of the point data that made up the particular artwork that you saw on screen. So, again, super important to to note that an SVG is a text document. Alright. So, what I've done is, in this particular section, we're just talking about drawing visual assets. In the next section, we're going to talk about painting to the screen, how do you paint stuff to the screen, and in the fifth section, we're going to talk about working with color. So, it's really a know sections that I'm really starting to talk about code, but I need to share some code with you right now and I'm actually going to attach a file to this particular video because we're actually not done prepping the artwork, because you're going to notice that if we just went through those steps, pulled it into Illustrator, we're going to notice some strange happenings. So, look at what I did here. I created a folder on my desktop called Mongo 1, I created a folder called Build. Inside of Build, as my build PDE and my hype PDE and then I've created another folder called data, and it's actually in the data folder that you put your external assets. So, in this case, here is Mongo.SVG. Now, if I were to open up this PDE file, I've written some stuff. Okay. I've written that I want the stage to be 900 by 900, I've specified the background, is a light grey, I've actually specified selection of colors that I want this file to use. Here's white, there are three greys, there are two blues and there are two oranges. This particular block of code right here handles the loading in and attaching of the external SVG file. I've said that I want the stroke weight to be 0.5, I've said I want the stroke color to be black. I don't want any phil, I want the anchor point of the artwork to be in the center. I've specified its location to be attached in the center, so width divided by two, height divided by two. Now, the artwork is small, so I put it in a scale three so that it would just be a little bit larger. Scale one obviously being 100%, scale three being 300%. Now, line 19 is where we actually run through the artwork and set some color to only the phils. Now, I'm just going to comment this out because I actually want to run this file and I want to watch what happens. Now, when you run this file, great, look it did exactly what I thought it was going to do which is, it loaded in the SVG file, it attached it to the center of the screen, it looks identical as it does inside of the Illustrator file. Now, it's not until we start applying random color that we start to notice that we need to do some more prep inside of Illustrator. So, I'm going to go ahead and put this comment back on which is apply random color to just the fills. Alright. Now, watch what happens when I run this particular file. When I run this file, it freaks out. I just can't understand what's happening, like it's doing some weird blocking here, something really funky happened in this section. Something's not right. Okay. So, I'm actually going to close this file and head back to the Illustrator. So, if I go into Mongo, go into Build, go into my data folder, there's Mongo.SVG and I'm going to go ahead and open this back up in Illustrator. Okay. Now, there's my plot. Let's open up the Layers Palette, and let me try to explain this. When this is exported to SVG, that SVG document contains all of the vector information for all of the art that you're seeing on screen. So if, and it doesn't matter, that vector information doesn't matter whether you've set a fill or set a stroke. Set a stroke weight, set a stroke color, set a fill color. Forget all that. All it contain is the points to draw this artwork. Now, the part that's freaking out right now is actually the top layer of the stroke. The reason why the strokes are freaking out is because this top layer is just strokes and when you load this into processing and say, "Hey I want to do random fill," it thinks, "Oh you want to do fills on all of the vector information." So, what it's doing is it's trying to apply fill color to this stroke output. So, what I'm going to do is trash that layer. So, all I've got left on my layers is what appears to be just fills. Now, if I go ahead and click Save and let me just move this to the side and let's actually go back to our code and now let's run it, let's see what happens. Boom! It totally works as expected because what it's doing is, it's randomly applying color to the fills. But then you might be saying, "Wait a second Josh. Why did the strokes come back?" Well, the strokes came back because we specified the strokes right here on line 11 and line 12. On line 11 and in line 12 you said, "Hey, these fills that you have, these fills that you have that have no stroke. Yeah, I want strokes on them." Give me a stroke weight of 0.5, give me a stroke color of black. So, even though the artwork in Illustrator is just fills. I'm actually applying a stroke on those fills, inside of processing. So, it was that top layer that had the stroke information that started freaking out because it was actually trying to apply random fills to that compound path. So, by deleting it, I get back to where I wanted to be. Now, you might notice that it's also applied the color symmetrically across all of the artwork. All right. So for example, this is light blue, this is light blue, this is light blue, and that same exact light blue is on this one, on this one, and on this one, all right. So, let me go ahead and close this and let me actually toggle back to Illustrator. Now, let me look at that particular set of colors and it's actually this compound path right here. So, if I were to do that, we're now looking at all of the artwork that got the same exact color. In fact, because it's just one compound path, it actually just apply, it just thinks that's one piece of artwork. So, it actually applied one color to what it thinks is just one piece of artwork. So, watch what happens when I come up to Object and say Compound Path and say Release. Release it from being one shape, when I released it from being one shape, look at what happens to the layer palette. It broke away from compound path and is now treating each of these as independent pieces of artwork. So, now if I were to turn on all my other fills here. Save my SVG document, toggle back to my code and click run, watch what happens. What it's now doing is it says, "Oh, man. This is a bunch of independent shapes so I'm going to color them each independently. Now, for colors I've got 1, 2, 3, 4, 5, 6, 7, 8. I've got eight colors, so I don't really have that many colors. So, if you look here, it looks as though it picked the same color, but I can tell you right now this is FFFF and this is F7F7F7, it's slightly different. Look, it made these two different colors, it made these two different colors because that grouping as a compound path treated this artwork as just one piece of artwork and thus, that one piece of artwork just got one piece of coloring. So, if I were to close this and I were to go back to Illustrator, you can imagine that if I selected all of these compound paths, and then went to Object, Compound Path, and Release, all of a sudden your layers palette is going to freak out. Because now, every single shape is an independent piece of artwork. Now, if I click Save, toggle back to this document and were to run it again, you would have no color symmetry at all. Because it thinks that all of these shapes are independent and because all of these shapes are independent, they're all gonna get colored differently. All right. So, really super important to keep into consideration while you're prepping these visual assets because if the group is just compound path, you're going to get this universal coloring. If you break them all apart into separate assets, then you get a non-harmonious color situation because it thinks that every single one of these shapes are different. Now, you might be saying, "Well Josh, how do I break all these things up and then how do I applying, coloring two specific object?" So, let's toggle back to illustrator and let's look at something. Look at this shape, this shape, this shape, this shape, this- woah there, whoa. Let's try that again. Let's try that again dubby. Oh, I broke apart my compound paths. Try that again Josh. I just released the Compound Path because you did undo. All right. So, what I'm doing is selecting, like so. So now, actually in here, can I just do it like this? Yes, there we go, much better, this is much easier. All right. Oops. Here we go. There's actually two separate shapes here that I wasn't getting. All right. So, what I did was, is I use the Selection Tool just to select all of the artwork that I'm interested in. So, if we look here in the Layers Palette, a bunch of things are highlighted. Now, all I'm going to do is group them. If I do Command G and group this all as one piece of artwork. Go ahead and click Save, toggle back to my code and run it. You will now notice that one color got applied to all eight of those shapes. Right? So, orange, orange, orange, orange, orange, orange, orange, orange, orange. So, super important to take into consideration while you're prepping your visual assets, is that if all of the shapes are independent, they'll get colored independently. If you start to group things together, so for example, if you were doing a face and the inner parts of the eyes were separate assets you'd get David Bowie. You'd get blue, you'd get green, you'd get David Bowie. Might be good. Maybe you want David Bowie. If you group them, you will get the same color in both of the eyes. All right. So, just remember this, when you are prepping your visual assets, that keep things separate, all of the color is going to be separate. But because I like some harmony to stay consistent through my randomization, I actually do this shape grouping. So, that way I know that when the code runs and the color gets applied, all of those are going to get the same exact color across all of them. This section is done, we are actually going to start writing some code now. Painful but true. So, we're going to move on to painting to the screen and we're going to start talking about how to start writing some simple code. We won't start attaching SVG right at the beginning. We'll start with ellipses and rectangles and then eventually, we'll move into attaching SVG. See you in next video. 17. Introduction: Painting to Screen: In the last section, we talked about making drawings and prepping those drawings. In this particular section, I want to talk about painting to screen and how do we paint objects to screen. I come from Flash. I spent like 10 years working in Flash, and it's different enough that we should spend a section talking about it. How do we actually draw things to screen because it's very different than how we used to draw things to screen in the Flash environment? Not only that, but processing has some limitations in terms of how do we draw things to screen. So, again, a great time to introduce how we actually paint things to screen using the HYPE Framework. Doing stuff like HRectangle, HEllipse, HShape, HImage. Doing some 3D stuff like HBox and HSphere. So, we're going to really dive into how do we make these things and then how do we actually paint them to screen and what's actually happening when you're painting to screen. 18. Basics / Line and Rect: Are you ready to rock? Yes, I am ready to rock. We are in section four, painting to the screen. This is where we're just going to work out some basics, we're going to write a little bit of code, and we're going to understand how processing works, why we're frustrated with some aspects of it, and introduce height. So, let's just write a little bit of basic code for the beginners, to get you started. Now, I'm going to create a new folder. Let's call this folder Basics. Inside of Basics, I am going to make a new folder called Step one. Inside of Step one, I'm going to make a folder called Build, and then I will open up Sublime Text Two, I will change this to be, let's say, Save, Desktop, Basics, Step one, Build, and let's call this build.pde. When I do that, the bottom right-hand side should change to Processing. Now, to start with, I'm going to have us write five different files. So, you'll notice here that, let's just take this guy, and notice that, we're going to do Basics, Step one, Build, build.pde. Build.pde is where we're going to write all of our code. We're going to work on five files right now. So, watch what I'm going to do. I'm just going to hold down the Option key, or the Alt key, and I'm just going to click and drag, there's step two, step three, step four, step five. We're going to work on five different files. The nice thing is that in each of these is Build, and build.pde. So, we've got this base structure happening, which is nice. All right. So, let me just throw this in the bottom right-hand corner. Let's go ahead and write our very first processing file. Now, this is like the Hello World exercise for every processing document. What you're going to do is, you're going to type void setup, open paren, close paren, and we're simply just going to make a line. So say, line, we'll start at 25 on the x-axis, 25 on the y-axis. So, that's the first point of the line, and now we want to draw the second point of the line, and the second point of the line will be 75 on the x-axis, and 75 on the y-axis. Semicolon and we're done. So, if I actually save this document, and then press Command R to Build, what you should notice is that Java starts, and sure enough, there is our very first sketch. So, we specified the first two points, x and y, 25, 25, and the second point 75, 75, and because we specified line, it just drew a line in between those two points, that were specified. Okay. So, good. We've made our first sketch. So, I'm going to go ahead and close this document, and I'm going to move on step two. Go to step two, going to open up build.pde. Let's find some ways to make writing this code a little bit faster. So, inside of Sublime Text Two, you can type S E T, and you'll notice that setup gets highlighted. So, if I just go ahead and hit Enter, it automatically spits out all the code that we just typed in our previous file. Now, when you type setup, it will give you two functions, setup and draw. Setup runs once. It's where you set up all of your information, like num assets equals 100. It's where you specify all of your preparatory things like variables, and so on and so forth. Draw is your loop, that's what runs over, and over, and over again. So, if you wanted animation, the draw function is where you would actually specify how stuff should animate to screen. But again, we're not doing any animation just yet. So, we're going to go ahead and delete the draw function. Now, I want to go ahead and make a rectangle in this exercise. So, go ahead and type rect. Again, you'll notice that it automatically starts. So, I'm going to go ahead and press Return. Notice that the first variable gets highlighted, it wants to know x, y, width, and height. So, I'm going to go ahead and say, start at 25 on the x-axis, tab, 25 on the y-axis, tab, the width should be 50, tab, and the height should you 50.' Now, using this shortcut functionality snippets inside of processing, just means that we can write code a lot easier instead of having to write stuff over, and over, and over again. Click Save, command R to build, and you should notice that you get a rectangle in the center of your screen. It has some default values. It has a black stroke, it has a white fill, so on and so forth. Okay. Let's take the time now to move on to the next video where we start to add some desired enhancements, and some frustrations that we'll encounter when adding those enhancements, and maybe getting a bigger picture about what's actually happening when you're painting to screen. See you in the next video. 19. Basics / Rotation: Okay. In this video, let's add some enhancements to our basic sketches that we're making to get a better understanding of how processing actually paints to the screen. So in basics, step three, build, I'm going to go ahead and open up build.pde. Now, I'm going to go ahead and type setup. I'm going to remove the draw function. I am going to add something new. I'm going to change the width and height of my sketch. So, I'm going to go ahead and say, "Size 600 pixels by 600 pixels." So, now my stage would be 600 by 600. Now, I'm going to go ahead and specify my rectangle, but this time I'm going to say, "100 on the x-axis, 100 on the y-axis, with a width of 50 and a height of 50." Now, if I press Command R and build my file, again, I should see my sketch of 600 by 600 with the rectangle at the desired position, and the desired width, and the desired height. Now, it was at this point that I decided, "Well, I'd like to rotate that rectangle. I'd like to rotate that rectangle 45 degrees." So, I wasn't quite sure how to do that. I wasn't quite sure how to actually talk to the rectangle and rotate it. As a matter of fact, you don't. You actually don't talk to the rectangle at all. The rectangle is not even an object that you can talk to. So, then how do I perform a rotation? Well, it ends up that what you're actually going to do is rotate the entire stage of the sketch. So, if I were to come in here and write rotate, and specify 45 degrees, and if you were to save and run this, you would notice that your rectangle is now missing. So, then I had to do a little bit more reading to figure out that in order to use rotate and if you wanted to rotate it 45 degrees, you had to specify that number in radians. So if I were to go back and say, "Rotate", you then would have to call radians, and in radians you could pass the number 45. Now, if I save and build my movie, I can now see that my square is all the way to the left. Why is this happening? So again, I was having a difficult time understanding how to paint specific stuff. So, I needed to try some tests. Let me show you the tests that I ended up conducting to get a better idea of how processing actually paints to the screen. So, let's move on to step four. Step four, build, build.pde, again, I'm going to go ahead and type setup. I'm going to remove the draw function, and inside of setup, I'm going to specify size 600 by 600, and I'm going to go ahead and say, "Rotate radians, let's say 10." So, now I'm only rotating 10 degrees. Now, what I want to do is, is say a rectangle, but this time, I'm going to change the x-axis. I'm going to say 400, 100 with a width of 50 and a height of 50. Now, the experiment that I wanted to conduct was, what happens if I had five of these onscreen? So since I have the one, I'm going go ahead and just copy these two lines, and I'm going to paste until I have five. So, now I have five instances of this rotate and rectangle, and I was just curious to see what was going to happen. So I saved my movie, I build it, and I get this. So, I started to get a better understanding that what was happening in this file was, if I take a sheet of paper is that it was taking the stage, here's zero, zero, for you guys, and it was rotating 10 degrees and then drawing the square. Then it was rotating 10 degrees again and drawing the next square. It was doing that five times. So, I began to get a better understanding that I was actually rotating the world, attaching the square, rotating the world, attaching the square, and I started to get this kind of shape. So, let's move on to another test. Again, I want a better idea of what's happening here. Just for the heck of it, yeah, we'll write the code again. I'm going go ahead and close this, I'm going to move on to step five, build, build.pde. Again, I'm going to go ahead and do setup, I'm going to remove the draw function. I'm going to come in here, and I'm going to setup my size. Now, I'm going do something a little bit different. What I want to do different is I want a visual representation of the stage. So, what would happen if I typed rectangle and then I said that the x-axis was zero, the y-axis was zero, and then the width was 600 and the height was 600? So, the width and height was the same exact size as the stage size. I just want to test the movie and see what happens. So, I test it and visually, it seems like that that's the stroke on my rectangles. So yes, I think it's working. I think I have a rectangle that is basically the size of my stage. So, what if I were to take this and copy it five times? Two, three, four, five. Now, the next thing that I want to do is, is that I want to say that there's no fill. I just want to look at the rectangle without a fill, just a stroke. So, I'm going to go ahead and say, "No Fill." I'm then going to copy that, two, three, four, five. Then what I want to do is I want to look at that rotation. So, I'm going to go ahead and say, "Rotate radians." But this time, I'm going to say, "10." Then I'm going to copy so that I have it in front of all five of my rectangles. Now, if I go ahead and save and build the movie, you're starting to get a visual representation of what's happening, which is, I'm rotating the entire stage 10 degrees because again, zero, zero is still the same exact spot, my rectangle is 600 by 600, and I can see that what I'm doing is, is rotating the whole world, attaching this rectangle, rotating 10 degrees, so on and so forth. So in fact, if I were to add that smaller square back, I could say something like this, I could say, "Fill is white," and that rectangle that we initially had was at an x-axis of 400, a y-axis of 100 with a width of 50 and a height of 50. Now if I copied that fill, and again, pasted it four more times, and then saved and build my movie, you can now see that initial rectangle, that's the size of the width and height rotating, but now, I get an understanding of all. So, that's how it's creating that curve. Let's move on to the next video and start to fix some of these annoyances by learning push matrix and pop matrix and understanding how to reset the stage after we attach something so that we can really get back to maybe building a row of rectangles, and those rectangles are rotated 45 degrees. So, I want to fix this. I want to take these five, and actually put them in a row, and have them rotate 45 degrees. So, see you in the next video. 20. Basics / Matrix / push and pop: So, let's fix some of these annoyances in the basic steps with learning pushMatrix and popMatrix. So, I'm going to go ahead and create a new folder called matrix, and inside of matrix I'm going to go ahead and make a file called step one. Now, on this case, we're also going to do five files, but I want to mutate this one file as I move along. So, right now, we're just going to work on step one and then we'll copy and make changes as we go. Now, inside a step one, I'm going to make a folder called build. I'm going to go ahead and start a blank document in Sublime Text 2, and I'm going to save this on my desktop matrix step one build and we'll just call this build.pde. Let's go ahead and start to write the same code that we did before, but make some changes. So, I go ahead and type setup, I go ahead and remove the draw. I'm going to go ahead and specify sizes 600 by 600. And what is pushMatrix, popMatrix? So, if you remember in the previous one, if you are attaching five squares, it was rotating the world attaching the square, rotating the world again attaching the square. What pushMatrix and popMatrix does is it says, look at what's happening on screen, do some stuff, and when you're done doing that stuff put it back like it had never been done before. Reset. Okay? So, that's what pushMatrix and popMatrix does. So, watch what's going to happen here. I'm going to go ahead and say pushMatrix. Give myself a few hard returns and type popMatrix, okay? Now, because pushMatrix and popMatrix is remember what's going on, release what's going on back to the way it was. I actually like to put another tab inside the pushMatrix and popMatrix so that I can see that whatsoever between those two is happening at that moment and then it's being reset. So, let's go ahead and put in our rotate, let's go ahead and put in our radians of 45 degrees, and let's go ahead and draw our rectangle. Let's put this one at an X axis of 100, a Y axis of 100, and a width of 50 and a height of 50, okay? Now, if I go ahead and press command R and build this file, I should be back to that weird scenario where my rectangle is all the way to the left-hand side. Now, if I were to copy these four lines of code and paste them four more times. Two, three, four, five. I now have five instances of pushMatrix popMatrix rotate and rectangle, but let's change the X axis for each of these. So, let's go ahead and say that this particular rectangle is going to be in an X axis of 200, the next one is going to be 300, the next one is going to be 400, and the last one is going to be 500. Now, if I test this movie, you'll notice that it now does this down the row. Okay. So, pushMatrix and popMatrix is resetting the rotation back to zero, zero. Sorry, setting the rotation back to zero. So, we rotate it 45 degrees, we attach the rectangle, popMatrix resets it back to zero again and then the process starts all over again where it rotates 45 degrees, draws the new rectangle, but this time at an X of 200. Then popMatrix puts the rotation back at zero starts the process all over again. So, again I was confused as to why was it doing this kind of pattern. So, at this point let's learn something new. Let's go ahead and save and close this, and I'm going to take this step one, hold down option Alt key, drag to create step two and actually reopen this file again, right? So, now we're going to make an enhancement to this file. It ends up that, if you just say that the rectangle is at an X of zero and a Y of zero and actually do that for all of them, because what we want to do is add something new called translate. What translate does is, if rotate is rotating the canvas, translate is moving the canvas. It's moving the stage canvas on an X axis and a Y axis. So, if I were to come up to this pushMatrix I could say translate and I'm just going to put in 2D coordinates. I'm going to say translate to 100, 100. So, translate to an X axis of 100 pixels over 100 pixels down rotate the stage, then draw the square. PopMatrix resets translate back to zero, zero, sets rotate back to zero and starts the whole process over again. So, let's go ahead and copy our translate into each of the push and pop matrices, but at this time I'm going to say translate to 200, translate to 300, translate to 400, and translate to 500. Publisher movie and oh, my God we're getting somewhere. So, what happened was is that it said this is zero, zero, okay. Move 100 pixels 100 pixels, but this is still zero, zero, okay. Rotate 45 degrees, attach the square. PopMatrix, put it right back to where it started. But the new one says go over 200, down 100, rotate so on and so forth. So, now we're starting to get what I wanted visually to begin with, which was a row of rectangles rotated 45 degrees. Okay, so that's cool but I actually want these little diamond shapes to appear in the center of the stage, so the Y axis should be in the center. So I'm going to go ahead and close this, and again I'm gonna hold down the option key. I'm going to go ahead and drag this to create a step three and let's go ahead and reopen this build.pde. Okay. All right. So cool. I want the translate to be at the height of the movie divided by two. That sounds great. So, let's go ahead, copy that, and paste it for each of the translates. Go ahead and run your movie. That totally does not look like its the center of the screen. It looks like it's downsome. Well, let's confirm that it's downsome. Let's go ahead, and say that we want to make a line. Okay. Let's go ahead, and say that the first of the line should be at zero on the X, and it should be at height divided by two, so that's going to put it on the left hand side middle of the stage. Let's go ahead and say that the width of the line should be width, and its next position should be height divided by two. Okay. So, that I should draw a line in the complete center of the screen. So, I'll go ahead and test my movie, and I realize, oh, yes of course. When you draw the rectangle, the rectangle is zero, zero. So, when it rotates like that. Right. It's hanging off of this zero, zero rotation point. In fact, if I were to add some ellipsis here, let me just say ellipse. Oh, you can type Josh. Try that over. Let's say that the ellipse is going to be the same that the translators. So, for the first ellipse let's say 100 height divided by two, and I want the size of the ellipse to be five-by-five. Okay. So now, if I were to copy 2,3,4,5, the next translate is at 200, 300, 400, 500. Test the movie, test the sketch. I come from Flash man. Test the movie, test the sketch. So, I've I'm drawing that little circle to represent where zero, zero is on my rectangle. Okay? So now, I'm in a bit of a dilemma. In fact, if I were actually to do this, right? If I said, "Hey, I'm rotating 45 degrees divided by five rectangles, you'd see that 45 divided by five is nine. So, if I actually change the radius to be nine times one, nine times two, nine times three, nine times four, and nine times five. If I ran my movie, I can actually see it rotating to 45 degrees. I could see that pivot. I get representation of how it's pivoting off of zero, zero of the rectangle, right? So, okay. Oh my God! I've got to try to figure this out. So, let's go ahead, save and close this movie. I'm going to option drag step three to step four. I'm going to reopen the build.pde again. So, I had to like think like, okay, how do I center the rectangle? Again, this is me not knowing anything about processing. I hadn't dug through all the documentation. I didn't know all the tricks. I was trying to just figure this out on my own, okay? So, cool. Let's put the radians back at 45 in this example. Okay. What I needed to figure out is, if I rotate a rectangle that's 50 by 50, that's not the size of the rectangle. In fact, if you take a rectangle, and rotate it 45 degrees, that rectangle is now 70.711 for a width and 70.711 for a height. It's not 50 by 50 anymore. So, I was like, okay, I'm going to take the height divided by two, and then I need to subtract, right? Then, I was putting this in parentheses. I was going to say, "Oh, 70.711 divided by two. That would be the middle of the width and the middle of the height." So, if I actually copy this. This is painful. This is painful that you're writing this code with me, because this is this is ridiculous. So, if I were then to save and test this sketch. I was like, yes. I now have this doing what I need it to do, which is I wanted to take these rectangles, rotate them 45 degrees, so they'd become diamonds. But then I wanted to center them, and that's how you do it. I have to tell you, I was beginning to think that the processing was crazy, that I was going to have a really difficult time as a visual artist, just thinking about how I was going to make things on screen. Now, save and close this movie. Save it as a step five. This is the last one that we're going to do, because I then dig around some of the documentation, and realized that this was just nuts. I didn't have to do this at all. If I actually get rid of all of this, all I had to do was write one line of code to specify the rectMode. So, if I come up to the top here, and say, rectMode, you could then pass CENTER in all caps. So, what that meant was, is that whatever a rectangle that you make, the anchor point is actually in the center of whatever width and height specified. So, if you were to save and test this sketch, you would notice that you get the same exact thing. Okay. In the next series, I want to talk about how do I rotate this stuff? So, cool. I've got this artwork attaching in the center of the screen, where I want it to go. But what if I wanted to apply some animation? Now, the reason why I'm showing the animation as an example, is because eventually, we're going to get introduced to Hype. We're going to get introduced to how all of these kind of annoyances for me could be simplified by using the the Hype Framework. Okay. See you in the next video. 21. Basics / Rotation and Color: So, the way I see it is before we actually move on to talking about hype, there are two extra files that we have to make so that you can see what scenarios happen in a non-hyperfied scenario. So, the first is applying rotation. So, I'm going to go ahead and make a new folder and I'll call this folder "Rotation", and inside of this folder, rotation, I'm just going to copy step five from matrix. So, I'm going to take step five and just copy it over to rotation from matrix and into rotation. Now, let me just change this to step one and I can go ahead and close the matrix folder and I can go ahead and open up this build.pde. Now if I run this sketch here, what I want to have happen is some rotation of these squares so that, again, you can see how processing handles certain aspects of painting to the screen. So, let's go ahead and say something a little bit different which is I talked about earlier that a setup functionally runs once. It's a draw function that runs multiple times, and so I want to actually move some of this stuff into a draw function. So, if I come down here and type void draw, open paren, close paren, and what I'm going to copy is everything from the ellipse, the line, and the pushMatrix and popMatrix. So I'm going go ahead and cut that, and right now you'll see that the only thing that's in setup is setting the size and the rectMode. Now inside of the draw which is a loop, it runs over and over again, I'm actually going to paste this pushMatrix, popMatrix, the creation of the line, and the creation of these ellipses. Now if I were to build the sketch, you notice that it maybe doesn't look much different because, again, there's no animation happening here. All right. So, I've got five assets. So, I'm actually going to create five variables. I'm going to say integer r1 for rotation one equals zero, and I'm going to go ahead and copy this two, three, four, five and change this to two, three, four, and five. Now, what I'm going to do is, is instead of rotate radians 45, I am going to actually change this to the variable that I set up above. So, I'm going to say radians plus plus r1. So that means add one onto the value of r1. So zero becomes one, one becomes two, two becomes three, three becomes four, and basically, it's a counter, that thing is always counting now. So, if I were to copy this and make this plus plus r2, plus plus r3, plus plus r4, and plus plus r5. Now the rotation, all five of them have five different numbers that are counting 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. So, if I test the sketch, you should notice that it's rotating, but what happens is, is that you're actually not clearing the screen. So I'm actually just painting the rotation and so as the square moves, it's leaving a residue of the artwork in it's previous position. So in order to clear the screen in the draw function, I'm just going to say background is CCCCCC. So, what happens there is, every time the draw function runs, it clears the background then draws the square, clears the background, draws the squares, clear the background, draw the squares. So now, when I actually test this sketch, you should notice that it would appear that each of the squares are rotating on their own. So, we've moved the content out of setup, we've put it inside of draw. We realize that if you don't call background on line 13, it's going to leave a residue of the artwork because you're not actually clearing the background. So again, these are things to think about as we're going forward. Now, there are sort of one last double-whammy here. I'm going to go ahead and save this, and I'm going to copy this whole rotation file to color. So I just copy it and I'm going to rename it to color and I'm going to go ahead and open up the build PDE. Now this is the same exact file as rotation, but I want to set a random color. So, I've got these squares and I just wanted to have a random fill color. So, inside of the pushMatrix and the popMatrix of each of the five, I'm actually going to paste this, and this is setting the fill color. Now, fill is RGB; red, green, blue. So I'm saying pick a random 255 number for the red, a random 255 number for the green, and a random 255 number for the blue, so that should give me a random RGB values, that's RGB is a number from 0-255. Now, if I was to copy this into each of the pushMatrix and popMatrices, you would see the last and final straw for me personally, when I test this sketch. Instead of me thinking that it would just set one color, what happens is, is because the draw function is running over and over again, it assumes that you want to pick a random fill each time. So wow, this was just a huge difference for me coming from the flash environment because you could do this kind of thing in the flash environment and actually the fill color would only get set once. Again, I understand these are completely different languages, but for me this was the final straw. I really needed to think about like how could I build a library to help assist in doing some of these things that I think are complicated. So, for example, you could pick a random color up inside of setup and then the draw will just access that random color that you're already pre-picked. So, let's move on to the next video where we actually start to look at some hype code and understand how we can take the same exact ideas, the same exact animation, but we'll see how it's much simpler actually using hype. See you in the next video. 22. HYPE / Basics: Okay. So, let's start with a HYPE file. So, everything that we just covered, cleared out of your mind. Cool. Let's go ahead and start a new document, a new folder, and I'm going to call this HYPE_basics. Inside of HYPE_basics, I'm going to create a folder called step one, I'm going to create a folder called build. Now, you can open up this HYPE processing folder that we downloaded from Staging, because here is HYPE.pde, which again contains the entire HYPE library. So, I'm going to option drag and copy that into Build. So, now I can close that. So, I've got HYPE_basics, step one, build and HYPE pde. So, I'm going to go ahead and create a new file called build.pde on the desktop, in HYPE_basics, step one, build, right there with my HYPE pde file. Okay. So, let's understand a few things that are a little bit different than in processing. So, let's go ahead and construct our visual rectangles like we did in the last file. Now, I'm going to go ahead and say void setup(). I'm not going to do a shortcut just yet because I'm going to show you some differences. The first thing I'm going to specify is the size, 600 by 600, and I'm going to move on to the next line. Now, in order to use an external library, I need to initialize the HYPE library. So, I need to tell Processing that HYPE exists. I'm going to do that by saying H.init(this). Now if you've downloaded other libraries in the past, you're probably very familiar with firing a library's constructor. So, right now, on this line four, I'm telling Processing to be aware that the HYPE library actually exists. So H.init(this). Now, rather than have Processing do the drawing, I'm going to have HYPE do the drawing. So, whatever I type from here on out, I'm going to be saying, HYPE. So, at the very very end, I need to tell HYPE to actually paint the screen. So, I'm going to do that, give myself a few hard returns by saying H.drawStage. It's that line right there that's actually going to take all the stuff that we've pushed into HYPE and actually be able to paint it onto the screen. So H.drawStage is always typically going to be one of the last things that I do. Now, let's go ahead and make our first rectangle. So, up at the top here, I'm going to create an instance of HRect, and it's a capital R, HRect, I'm going to say d1, d is for drawable. So, there are a lot of drawables inside of HYPE. There's HRectangle, there's HEllipse, there's HBox, there's HSphere. Those are all drawables of HYPE. So, I'm going to say HRect d1, the d is for drawable. Now, inside of setup, I'm going to say d1 is equal to a new HRect. So, rather than calling Rect, we're calling HRect. Now, I can start to do some method chaining. I can say, hey, d1, I want your size to be 50. I want your rotation to be 45. I want your anchor position to be in the center, so that when it rotates it rotates, this is Rect mode, so that it rotates around the center point. I do that by saying anchorAt. AnchorAt has a bunch of things that we can pass. I'm going to say H.CENTER, just like it was Rect mode center, I'm saying anchor at H.CENTER. Now, where do I want to put this first square? That's location and under the location, I'm going to say 100 on the x-axis and height divided by two. All right. Now, if at this point I were to save and test this, you would notice that we don't see anything. So, where is my rectangle? So, you're missing one last line, which is adding this drawable to HYPE. So, I'm going to say H.add this d1 guy. So, you're now adding this drawable to HYPE. So, when we get to line 12 and it says H.drawstage, this drawable has been added and it can actually paint it to screen. So, by adding that line, if I now test the sketch, you should notice that the rectangle is right there in the center. Now, let's add some stuff here. After H.drawStage, I'm actually going to copy and paste the line and ellipse information from the previous files that we were working on. So, drawing the line across the middle and then putting in those five ellipses. Now, if I were to run this file, you would notice that it is in fact right in that center of the screen. So, size, set it to 50 by 50. Rotation, I didn't have to say radiance, I could just say I want to rotate it 45 degrees. Anchor, I'm specifying where the registration point is. In this case, I'm saying anchor at H.CENTER. Location, I just said 100 pixels on the x and height divided by two. Now, if I was to take this and just copy this five more times, two, three, four, five, now, obviously I would need to change this to d2, d3, d4, d5. So, up at the top here, I'm going to say HRect d1. There's also going to be a d2, a d3, a d4, and a d5. So, I can list them all on one line. Now, I can start to make the modifications here. I can say d2, d2, add d2, d3, d3, add d3, d4, d4, add d4, and d5, d5 and add d5. Now, the only other last thing I had to change is the location. This one was at 200, this one was at 300, this one was at 400 and this one was at 500. All right. I'm going to run my sketch and you should notice that it is exactly as the previous one. So, cool. We're starting to learn a little bit about HYPE. We are initializing the HYPE framework. We're using HYPE's drawables, in this case HRect. We're adding those drawables into the HYPE universe. Then, on line 27, we're asking the HYPE universe to take everything that it knows, that we've pushed into it, we've added into it, and actually paint it to the stage. So, if I was to save this and close it and then do a Step two and opened up the code here, watch what I'm going to do here. I have a class called HRotate. So, remember, before, we had to create a void draw and we had to copy all of the code into the draw. Well, I'm going to take a little shortcut here, and I'm going to say, hey, HRotate, again, it's a capital R. Let's call this r1 for rotate one, equals new HRotate, and who do I want to rotate? Who is the target? Well, in this case, the target is d1, that is our HRect, d1. What kind of speed do you want to have? Go ahead and just do a speed of one. Now at this point, if I was to test the sketch, you will notice that nothing is rotated. The reason why nothing is rotating is because, again, this is all in the setup. So, if I was to come down here and say void draw, open paren, close paren, and just copied the ellipses, the line and the H.drawStage, that's all I have to copy, and actually paste this into the draw. So, what's happening is, is that inside of draw the loop it's firing H.drawStage over and over again. So, it's really drawing the universe of hype over and over again. So at this point, if I actually test the sketch, you should notice that that first square is actually rotating, and it's rotating a speed of one. Now if I then copied this, and pasted it, pasted it, pasted it, and pasted it, and let's change this to r2, r3, r4 and r5, and change who the targets are, d2, d3, d4 and d5. Now if I test the sketch, you should notice that we're back where we started. Now, notice some stuff. Inside the draw, you didn't have to recall background. It actually does that automatically built by default. We'll learn a little bit later how to add the code back so that it doesn't clear the background. So, it just draw stage automatically clears the background unless you specify otherwise. Now if I said that the speed was negative one, that would obviously go the other direction. So now, the first one is going counterclockwise and the next four are going clockwise. I didn't have to create any variables for the speed, I didn't have to say plus, plus the variable to count each rotate, will just handle the rotation for us. Well, great. That means, this one I could say it has a speed of 1.5. This one I could say it has a speed of two. This one I could say has a speed of 2.5, and this one has a speed of three. Again, if I were to test the sketch, you would notice that all of the speed rotations are different. Moving right along, I'm going to save this. I'm going to close it. I'm then going to copy to a step three and reopen up that built PDE. Now, this is super important. I can't tell you how much I love this. Inside a flash, you could create a piece of artwork and you had this registration point, and where you moved the registration point was super important because if the registration point was here, and you did it in a rotation, it would rotate this way, and if you had it in the center, then it would rotate this way. So, you might have noticed that inside of processing by default you're either doing 00, or you're doing rect mode of center. You can't do any kind of like lopsided rotations, or maybe the point is up here, and this like swings around. You can't do that quickly, you actually have to write a bunch of code in order to support how to do those kind of rotations. So at this point, I want to talk about anchor. So here anchor at always has a constant, like, H.up, H.left. If I change it to just anchor, then I can actually specify any X and Y that I want. So, I'm just going to get rid of my H.centers here, and let's just see what sort of fun we can have with anchor. Let's say that the first anchor is five on the X axis, five on the Y axis. Let's say that the next one is 10 on the X axis, 10 on the Y axis. Let's say that the next one is 15 on the X, 15 on the Y. Four, I'm actually going to make 25, 25, and the reason why I'm going to make it 25, 25 is because the size is 50. So, anchor 25, 25 is the same as anchor at Taking the width divide by two, the height divide by two, 50 divide by two, 50 divide by two, 25, 25. The last little drawable, I want to do something unusual or I want to say, okay, cool, here's the artwork. I want to, on the X axis come to the middle, so the middle would be 25, and on the Y axis, I want it to be negative 25. So it actually puts the point up here. So, I'm going to say negative 25. Go ahead and save and test this sketch, and you should notice that now, we're getting all sorts of fantastic rotations. Just auto-magically without having to write any additional code, you can use anchor to actually specify just like the old flash days where the registration point is and where that registration point is going to affect the X and Y position of where things get attached and obviously the rotation. Now, final thing that I want to do, go ahead and close this, and I'm going to save this as a step four. This is the last one that we're going to do in this particular series, and that's I want to add color. So if you remember, I could say, again, I could change it. But this is starting to get long. So, let's just say d1.fill, and then something. So, what do I want to do with this fill? Well, if you remember in the previous file, I wanted to randomly pick a red green blue. So, if I was to just copy some code that I already pre-baked here, where I'm saying d1 fill random r, g, and b, number from 0-255. If I were to paste that into each of these, so let me just copy and paste and paste and paste and paste, then of course, I need to change it to d2. This one, I need to change to d3. This one, I need to change to d4, and this one to d5. Because all of this asset creation is happening in setup, you can actually run the file and it's only going to paint one color. Whereas, in the previous one, it was picking the color over and over and over again. So, huge advantage. Huge advantage to being able to use hype, and just in the draw function, just putting that H.drawStage, and whatever we do in setup, that just gets run once, and it's that H.drawStage that's actually looking at all the parameters that you set in set up and doing the computation. So in this case, it being rotation. Now, I could do some other stuff here on the H.init this. I could say.background and I could specify 666666, a dark grey like so, so I could set the background color, and I can then do autoClear. An autoClear is blue in value. So if you say autoClear true, and actually run this file, what autoClear true is doing is wiping the background. So if I changed autoClear to false, and actually run my movie, you would get that painting effect. So, we're going to move on to looking at some of the hype drawable objects. So, we're just going to do a quick run through of all the different types of drawable objects that you can use using the hype framework. Moving on. 23. HYPE / Drawables: Okay. So, now we're going to move on to a folder called HYPE underscore objects, and you should notice that it's been zipped up and it's been attached to this video content. If I'm not winning some kind of award for the Skillshare number of video content in one class, I'm going to be really bummed. There's a suggestion when I add these videos that says, "Make each video between three and seven minutes." Sorry, I have failed in that department. There are lot of drawables in HYPE, and I actually haven't added all of them. There's a few that are missing. This video would be three hours long if we actually wrote all of the code to talk about all the different drawables. So, what I'm going to do is, we're just going to look at some of the drawables here, and we're going to look at the code, and you can be working side-by-side, and we can get through this. Now, the same structure is going to be in every single one of these folders. I've tried to strip it down to its absolute basics. Let's look at what's happening here. There's a void setup. There's no void draw. I say H.init(this), I go ahead and I put in a background of a dark gray. Line six I said smooth, which sometimes will make the pixels a little bit nicer. Line 22 H.drawStage, so whatever we add to the HYPE universe, paint to the screen. Now, on line 8-20, I'm doing a for-loop. A for-loop is something that runs a set number of times. So, in this case, I've said that I want this for-loop to run 100 times. If you're not familiar with programming, a for-loop is three basic steps, where to start till when how to count. So, integer i equals zero, start at zero, run while i is less than 100, an i++. So, if you remember from before, add one on to i. So, zero becomes one, one becomes two and this keeps counting until it reaches 100. Then, when it reaches 100, this for-loop stops. Now, inside of this for-loop, we're creating a rectangle, an HRect. So, that would mean that we're going to be attaching 100 HRects onto the screen. So, let's look at some of the parameters that we've passed. I said that I want the strokeWeight to be one. I said I want the stroke color to be FF3300, nice dark orange. I want the fill to be 111111, nice dark gray. I want the size to be a random number. So, notice that we're only passing one number for size, so that means it's going to be a perfect box. The width and height are getting the same exact number. But, I've said random 25 comma 125. That's a range, which means that it's going to pick a number between 25 and 125, and whatever number it picks, it gives that to the width and the height. Rotate, I ask it to pick a random 360 degrees. For the location, random.width random.height. Now we haven't covered this yet, width is equal to 600 and height is equal to 600. So, you can just specify with the sizes up here, and this size can then be called as width and height throughout the rest of your document. AnchorAt( so, we're setting that registration point to the center. After we're done, we say H.add(d), d being drawable. It's a shortcut for drawable. So, if I were to test this sketch, you should notice that there are 100 HRects added to the stage. They're all given a range between 25 and 125. They got a random rotation. So, now, maybe you're starting to see some of this prior thoughts and conversation I had about randomness. I don't know if this is necessarily good-looking or not. In fact, it's just random but, it's random with a range. It didn't get too small because it didn't go any smaller than 25 by 25, and it didn't get too big because it didn't go any bigger than 125 by 125. So, if I can add randomness but have boundaries on it, usually, the better the results. So, cool. We like that one. Let's look at the next HRect and see what's going on in this particular file. This one, I've changed the fill color to have an alpha of 200. So, alpha is a number between zero and 255. So, I said that I want the fill to be this dark gray comma and then alpha. You'll notice that the alpha here is, you can see some of the strokes from the rectangles that are actually behind. HRect also supports rounding of the edges. So, you might notice on line nine I said,.rounding and then I put in a radius of 10, so my rectangles actually have corner radius of 10. Very nice. Moving on to the next one. If we were to look at this one, I changed size on here because, if size is past one number, then it applies it to width and height. Here, I'm randomizing the width and I'm randomizing the height. So, in this case, HRect becomes a series of rectangles rather than perfect squares. So you'll notice we're getting a bunch of rectangles on screen rather than a bunch of perfect squares like in step one and in step two. HEllipse, not much different than HRectangle. Again, you specify a size. That size is the radius of the circle. So, very similar to HRect except we're doing circles rather than rectangles. In step two, I believe rather than doing perfect circles, I changed the size to be the width, a random set of numbers, and the height to be a random set of numbers. So, again, if you test this, we should be getting some ovals. In step one, rotation, random 360 I didn't do because you can't see a randomly rotated circle. But, in step two, because these are ovals, I can do that random 360 rotation, and I can rotate ovals around. Now, there's also H.path. H.path is where you can do things like polygons. In H.path we can do stars, we can do triangles. So, we're not going to look at all of these. I want you to look at all of them but, if you were to run a polygon, for example, you'll notice that I can get things like octagons and hexagons, and so on and so forth by specifying that it's a polygon and then how many sides that polygon has. So, in the case of this one, I've said, "Hey, H.path is a polygon and that polygon has five sides", and so I get a five-sided polygon. Of course, in polygon two, I randomize it. I say, "Hey, polygon randomize between three and nine." So, when you run this file, you'll get everything from triangles, to octagons, to hexagons, and so on and so forth. So, pulling on. Star. Believe it or not, it's a star. Star has two arguments, depth and edges. So, if you were to run this, I think this one ends up being like a traditional perfect five-sided star. So, each path can also do stars. Of course, there are a bunch of different triangles that we can have. There's isosceles, there's right angles, so on and so forth. So, here I'm saying I want a triangle, I want that triangle be isosceles, and I want it to point towards the top. So, look through H.path and look at all the different kinds of shapes that we can actually make in there. Now, let's move on to HBox and HSphere. HBox we're still working on, but the nice thing is is that HBox is a three-dimensional shape, so you might notice a little bit of difference is that in the size here, I had to tell it to use P3D. By default, it uses P2D, two-dimensional matrices and vectors. So on line four, I need to specify that I want to use three-dimensional coordinates. I also have to tell HYPE that I'm using three-dimensional coordinates, so you might notice I say on line five, H.init and then I do use3Dtrue, so that way it toggles HYPE to use 3D coordinates rather than 2D coordinates. Line 11, 12, and 13, since it's a box, I have to specify its depth, I have to specify its width, I have to specify its height. And again, I put in a bunch of random numbers here. So, if you actually run this sketch, you'll notice that we're actually getting a bunch of three-dimensional boxes in space. Okay, very cool. I did a step 2 for HBox. What did I do for this? I did rotation X, rotation Y, and rotation Z, which I thought was pretty cool. So you can actually create a box and then start to change the axis that it's rotated on, X, Y, and Z, and so I thought compositionally that started to get pretty interesting. I also put that alpha into the fill so that you could see some of the other shapes that are happening behind the box. Okay, Sphere, I'm not sold on Sphere just yet. It's really slow when doing animation. Look, I turned on the stroke of this Sphere and you should get something that looks like this. I'm still working with Sphere. I'm still trying to make something fun here. That step 2, I probably did the rotation X, rotation Y, and rotation Z, so if you go ahead and run this, it's going to just spin the axis of these spheres. So on some of them, you might see the bottoms or the tops of the Sphere, again compositionally, it's interesting. Now, the last two that we want to look at is H.image, and H.image, step 1, there's a build folder and there's also a data folder, and inside the data folder, I just put a little JPEG that I did for my buddy Joel here. Now, if you look at the build.pde, you might notice I say, "Okay, cool, I'm using H image, " and then I actually in quotes specify which image to go get. You don't have to specify the data folder, it just knows automatically to get it. You might notice on lines one through seven, if I wanted to publish this to processing JS, you have to have this line of code so that it pre-loads the images for use within the browser and JavaScript. And if I run this, this should just attach a 100 of those images on screen. So, there's a bunch of them there. Again, in step 2, I added some rotation, I added some alpha to the images. A lot of times, I think in Java, it becomes a little bit pixelated. You can see that the image becomes a little bit chewy. Interestingly enough, this doesn't happen in the JavaScript version, but in the Java version, you kind of get the stair-stepping on the images. Now, the last one that I want you to digest the most because it relates to this class, is HShape. HShape is going to have a data folder, but inside of that data folder is going to be SVG. So we're going to take our assets that we drew and use them in these series of sketches. So, check it out. HShape D, drawable, line nine, D equals new HShape, "Hey, load in this SVG file. " And you might notice that there's some things that I passed here, like enable style false which is don't use the styling that I used in Illustrator, actually kill it, because I'm going to specify the styling here in processing. So, enable style false kills the styling and allows me to set it here. Stroke weight 1, a nice orange for the stroke, a dark grey for the fill, so on and so forth. Now, when I run this sketch, you should notice that I am now painting with that SVG file that I made in Illustrator. So here's where it starts to get really exciting, where we're going to take some of these drawings that we make and map them into these environments. Now, this sample sketch is like a good one because you can see how things are going to mix onscreen. Case in point, look at step 2, where if you look at the data, SVG, it's huge. It's a very large SVG file, and it's very complex in the forms that it uses. So, when you actually open up build.pde and you actually run this sketch, it actually doesn't look that good. I have to remind you that if we're generating a complex composition, if the artwork is complex, then that's double complex, and double complex don't look so good all the time. Actually, the simpler my forms are, the better these results will turn out, so be careful about making your artwork too detailed. In this case, this doesn't work out so hot. Let us look at step 3. Step 3 is some of those drawings that I made on the Wacom tablet. In fact, I made a bunch of them, so I'm going to give you a bunch of these sort of sample SVG files for you to play with. So, a nice little SVG here. Now, inside of this build.pde, you might notice, don't kill the style, keep it like it is inside of Illustrator. Do some random rotation, do some random size, just go ahead and throw them around on the screen and let's see what happens. So, I'm going to run this sketch and I had to turn the for loop down to 20 because the artwork was so detailed, you're going to get this error like I just got, which is I'm trying to draw 20 of these SVG files and because I'm trying to do 20 of them, I basically run out of memory. It says, "Whoah, dude, you are trying to create 20 things that have way too much vector information." So, it gives you some instructions of how to actually increase the memory inside of preferences. Now, let me just quit these and rather than going in and changing the memory preferences, I'm just going to change my four loop to five, so it's only going to attach five pieces of artwork. My hope is that this will run. Okay, so you can see that it attached these SVG files onto the desktop, and again, it's just taking them- attaching them to the desktop, oh my God, I'm talking so fast and my brain is going so fast that I could say that I wanted you to shave a giraffe. Please, go out to the Serengeti and shave a giraffe. Where were we? Let's just move on. Okay, step 4. Step 4, I put in that enabling of style. Let me knock this down to the four loop being 10. Hopefully, I won't run out of memory and you can see here by enabling the style, I could go in and put in a fill, put in some stroke information, and I'm starting to get this composition, but you might notice that when I do this in the setup and I specify a fill, its just a universal fill that gets populated across the entire set of artwork, but this is actually a bunch of individual things. So, what I did was, is even though I'm skipping ahead, the next section is going to be about working with color, if you actually go to step 5, I just showed you an example of what happens when you have specified some colors and then ask the artwork to randomly start picking colors for the fills. Now when you do that, you start to get something that visually is going to look a lot more interesting, so rather than applying one color, it's running through here and it's coloring all of those groupings individually, like we covered in the other section. Okay, cool. Now again, even skipping farther ahead, moving forward into time, step 6. I actually just wanted to show how did you import processing PDF, how do you say that you want to capture and record what gets rendered on screen, and if I press the S key on my keyboard, capture everything that got drawn. So, if I were to run this movie, press the S key, it would actually generate a PDF, and this PDF file you can actually open up in Illustrator. So, I now have an environment for writing code, attaching some artwork, and then outputting that random composition back to Illustrator, and obviously in the upcoming sections, we'll figure out how to do all sorts of different stylings and whatnot. Okay. Wow, a lot to cover in this section, about how to paint to screen, how HYPE helps you paint to screen much more easier than I think processing does. In the next section, we're going to move back a little bit and talk about color. Conceptually, we're going to talk about color and then we're going to talk about applying color to some new sketches that we create. So, color. See you in the next section. 24. Introduction: Working with Color: Color. Very important. We got to talk about color. Do you know why we have to talk about color? Because you suck at color. I don't know any better way to put it. People are terrible at color, and my goal is to get people not to be bad at color. Color is super, super important to me. Not only that, but I have some secrets for working with color. Again, the metaphor that I often use is a box of crayons. We're going to write code that says, "Hey we just spent all this time drawing this artwork. Hey, we spent all this time running this program, and now we've just defined this box of crayons.'' This box of crayons has all the colors that we're allowed to color with. So, what will happen is that, when we actually run our file, it will randomly pick from the bank of assets that we've drawn, it will randomly generate stuff on screen, and then it will access this box of crayons and say, ''Hey, my job is to randomly color the things on screen, but I can only use the colors that have been specified in this box of crayons." Now, that idea may seem simple. In the first exercise that we do, it will be very simple. You'll literally set up this box of crayons, and it will randomly pick from the crayons, and it'll color things on screen. But then we can start to get into things like color waiting. Like, how do we wait more colors than others? We can do it with one color and we can actually do it with multiple colors. Which means that, when stuff gets generated on-screen, we can force a specific color aesthetic and the composition. So, that's working with something called color pool. But then we have another trick called pixel colorist. Pixel colorist, allows us to actually take photographs and strip the color out of a photograph. I have to name drop Eric Nowitzki, because he's one of the first guys that ever saw do it. Where he would go out and actually shoot photographs, blur them, and then actually use the color information out of that photograph to populate the color that we're going to paint on-screen. The third step, is a class called each color field. What each color field allows us to do, is actually setup points of color in space. So, as we're randomly generating a composition, if I wanted it to be green at the top, and then yellow in the middle, and then blue at the bottom, we could use each color field to actually create that color transition. So, we're going to spend a lot of time on color, because I think it's a super awesome thing to be obsessed about. I think it's going to resonate in the work that you create and finally, you can tell all your friends that you don't suck at color. 25. The Color Thief's: Hey, we are in Section five which is working with color. Got my fellow Skillshare teacher John Conteno's t-shirt on. Feel the power? Where to start? Color. Super, super important, I'm obsessed with it. I love color to the point where I'm always searching and hunting for form inspiration, I'm always hunting for color. Now, in the past, this was it. We used to be print designers and you'd have your Pantone book and you would go through and you would find, but you're always looking one color at a time, but this is where we started to get color. There's a lot of places for color inspiration, for example, Kuler, you could go to Kuler. Kuler is nice. I'm going to show you some tricks for hacking with Kuler. My problem with Kuler is that it's only five colors, and in some cases, that's great to start with those five colors, but I'm always looking for a range of colors, a much broader range, especially when it comes to adding these colors programmatically, what you're going to find is that, if I was randomly generating a bunch of artwork on screen and I only used five colors, it would end up looking very flat. So, what I want to do is I want to get a much bigger range of colors. So, the question is, where does color come from? Where can I search for color inspiration? Well, it ends up that most of the time it's from photographs. If I was to open up a browser, for example, and let's say I went to Google and typed in Beach and Ocean, maybe, and clicked on "Images," I could run through this selection of images to hunt for color. For example, like this one, if I like this, if I was looking for these kind of blues with this kind of sand color and maybe that punch of yellow, then this might be a great place to steal color. Well, as it happens is I spend a lot of time on Flickr looking at what friends do. This is some friends of mine, Kozyndan, and they are avid scuba divers and they're always posting these just amazing photos from underwater. I ended up seeing this one and I freaked out. I was like, "Wow, that's got some really amazing blues. It's got this great gold and it transitions into this amazing rich chocolate color." So, how can I use this as a point to steal color? Let's go ahead and pull that image off of Flickr and open it up here in Photoshop. Now, again, here's the image. A lot of really good stuff going on and this is a JPEG, and because it's a JPEG, it supports millions of colors, so the color information in here is massive. This idea of taking the Eyedropper Tool and selecting a color and then, "Oh, do I like that or do I want to go a more muted?" This would take me forever to run through this photograph and find color. Well, I've got some tricks. What I'm going do, is I'm going to come up and say "Save for Web." When you say Save for Web, you get this nice little window open here, and the thing is that if you were in JPEG, you would notice that the color table is blank, and again, it's because the JPEG and the PNG can support millions of colors. But you might have seen that if you actually save this as a GIF, you reduce this image down to a color table and that color table can have up to 256 colors in it. Now, if I selected "GIF32 Dithered", what you'll notice is that the color table again, reduced down to the top 32 colors averaged throughout the piece. However, I have a bit of a problem with dithering, and what dithering is, is that it is going to disperse the pixels around so that your eye actually blends them a little bit better on screen. However, if I came here and said "GIF 32 No Dithered", then I'm going to get just much bigger pools of color. Now, the nice thing is that while I'm in this Save for Web, and while I'm viewing this color table, I can say, "Hey, you know what? I really don't want this dark color, let me go ahead and trash it." So, I can actually start to remove maybe some of the colors that I'm not interested in. So, again, this is pretty good. I actually see one right here. This is not a very good sandy brownish green, so I can use the eyedropper tool to actually select it. It highlights in my color table and I can go ahead and trash it. Maybe I'm not that crazy about this color and I can select this one and I can go ahead and trash it. So, I can go ahead and start to go through and do some initial editing by removing some of the colors maybe that I'm not really that interested in. Okay, so what I'm going to do is I'm just going to click "Save" and I'm actually going to put this on to my desktop and I'll just call this Color1.gif. Now, the thing is that what you might have seen is that this photograph has some real clear divisions, especially, this section right here, there's a real clear division between the kelp and the blue, right? So, one thing that I typically will do, I saved out that one GIF, but I'll come up to filter and I'll say "Blur", and I'll say "Gaussian blur", and I'll go ahead and throw a Gaussian blur like 10. Now what that's done is it's just mixed. All of the colors. So now, there's not that hard edge between one color and another color. Actually, all the colors are blended together. What you'll find is, is that if I actually do save for Web again, and sometimes it will keep the color table data from the previous image. So, I always make a point to click on jpeg, show me all the millions of colors and then repick GIF 32 No Dither. When I do that, look at this nice big pools of color it repicked the color table here. Again, I might take the eyedropper tool and get rid of this particular color. Again, I could go in and edit maybe some of these colors that I know I'm not really feeling. So, I save out one that is the photo exactly as it was intended, and I do the second one where I do this Gaussian blur. So, I'm going to save this as color2.gif. At this point, you can go ahead and close the image that you have, and you can go ahead and close Photoshop. Now, what I used to do is I used to have a Web app, where you would go to a URL and it would say, "Hey, why don't you give me a GIF and I'll look at all the color information that's in there and spit it out in code." I used this for years and years and years and I ended up teaching a class in Aspen, Colorado, at the Anderson Ranch Art Complex and one of my students was this really great guy Michael Swenson. Michael said, "Hey, do you mind if I take that concept and actually package it up as a standalone app?" That app should be attached to this video. What it is, is the Color Picking tool. So, when you launch this, you can see you can say load image and you've got some other values here. All I'm going to do is I'm going to click load image and let's go ahead and just load in the first color1.gif and click Open. You might notice that what it's done is, it's actually extracted the colors out of this GIF. Now, you can sort. You can say, "Okay, show it to me in HSL. Show it to me in HSV. Show it to me in lab." I kind of like lab because it sorts it from, I will update later thank you very much. So, I like lab for the sorting. Now, there are some colors in here that I don't want, and maybe now that I can see them a little bit better instead of that little swatch chip in Photoshop. What I'm going to do is, I'm going to hold the Ctrl key down and I can actually start to edit some of the colors I know that I don't want. When I edit them out, actually this starts to organize. Now, let's say that I wanted to just view the blues, you actually can move the swatches over and I could actually start to look at the blues all in a row to get a sense for how these colors are mixing. Do I want to remove some of them So here, I'm just moving these puppies over. When I do that, now I get a much better sense of, oh, okay. I really don't want that color, I don't want that color. These two right here have a little bit too much green in them so they're not really gelling with some of the others. So, I might remove that and remove that. So now, I start to get a little bit better harmony with those blues. Now, let's just say I want to throw in a sand. So, I might pick these two sand colors, and let's say I want this series of oranges. So again, I might remove some of these browns that I don't really think are working out, and as I edit actually the swatches get bigger. So, they help me organize a little bit better what's going on. So, cool, we're done. Great palette. I've got one, two, three, four, five, six, seven, eight, nine, 10, 11, 12, 13, 14, 15 colors that's great. So, instead of using cooler and having five, I actually have 10 extra colors here which is great. Now, if I was doing animation, you could actually click use swarm view, so I could actually look and see what it would be like if these colors were moving around on screen and having some fade to them. You can click use GridView to get back to looking at this in a grid. Actually, these colors are mixing quite well. So, what I want to do is click View Color List, and you'll get this little output here. Let's say that I go ahead and start a new document in Sublime Text two and I can actually click View for processing. If I click View for processing, it actually spits out all the colors as hexadecimal. You could save it as an ASE file which you could then import back into Photoshop or Illustrator, or I can copy data to the clipboard. So, I'm going to go ahead and copy the data to the clipboard, go ahead and click Paste and now I've got all of those colors extracted from that photograph and ready for use in code. So, I may save this on my desktop as colors.text. We'll just put this on the desktop. So, now, I'm actually starting to save some of the colors. Now, if I close this and actually close the Color Picking tool and actually relaunch it. If I were to import in that second photo, there you have to update. You must update. You are insisting that you update immediately. So, I will let you update because you have to update. There's no question that you are updating. It updated. Clipping tool. Load image. Let's point to the second one. Sometimes with the second one, with that Gaussian blur, the colors are actually in a lot of cases, may be a little bit more harmonious because again, you don't have those hard divisions between colors, you have a nice subtle gradation between the colors. So, sometimes if I want the colors to just transition a little better, again that Gaussian blur, as you might see, sometimes does a better job. So, wow. Great tool for extracting color from images. So, let's start a new video and I'll show you a little trick on how to keep using this technique but in conjunction with cooler. See you next video 26. Expanding Kuler: Okay. So, how can we use Kuler maybe as a place to take five colors and expand it into something greater? So, for example, let's look at the set right up here up at the top. It's actually not bad. It's two good blues, two good greens, so on and so forth. So, what I'm going to do is I'm going to screenshot. I'm actually just going to take a little screenshot of these colors and then I can go ahead and close the browser and I've got the swatches right here on my desktop. Now, let me go ahead and open this up in Photoshop and again, I can see the colors are. Now, what I'm going to do is I want to take this limited set of colors and actually expand it into something a little bit bigger. So, let's say that I'm going to make a new document and I'm going to say that this document is 600 by 200. 600 pixels wide, 200 pixels high and boom! We can go like that. Now, what I'm going do is I'm going to pick that blue and then I'm going to hold down the Option key and select that dark blue. So, now I've got both colors happening in my color swatch business thingamajig. Then, what I'm going do is, is toggle over to this new image that I created and I'm actually going to go ahead and do a gradient, and when I do a gradient, I can see up here at the top I'm going from a lighter color to the darker color. So, I'm just going to hold down the Shift key and I'm just going to drag from one end to another end, and so now I've created a gradient. And of course, I can say, "Save for web," and I can go ahead and say, "I'd like a gif please." And how many colors would you like to transition from the light to the dark? So, let's say I wanted six blues. You could come over here to Colors and just say, "Hey! Give me six," and look at that. You start to get the movement from the lighter color to the dark color in six steps. So. I'm going to go ahead and click Save. We'll go ahead and call this Blue and go ahead and save it on my desktop. Great. Let's go back to the image and let's do the same thing with the greens. So, I'm going to click the lighter green, hold down Option and click the darker green, toggle back to my image here, go ahead and do the gradient tool again, and just go ahead and draw that green. Again, I'm going to do Save for Web. Maybe I don't want six this time. Maybe I just want four, so four steps from the light to dark. I can go ahead and save this on screen as green.gif. Okay, and I'm going to go ahead and toggle back to our image here and I might try some other things, like what does it look like when you toggle from this light green to this dark green? What kind of color is that going to produce? And if I go ahead and create the gradient and go ahead and do Save for Web, again, I could maybe change this to eight colors and I can start to see that transition from the lighter color to the darker color. So, let me just save this out as Trans for transition, who knows. Okay. So, now that we've got that done, I can go ahead and close all of the images that I have. Now, I think this is just white. Right? No, it's not just white. See what they're doing. So, let's do this. Let's go ahead and take these new images that I just created and actually reopen them in Photoshop again, okay? Oh! I didn't want to do that. Continue placing additional files? No, thank you. Sorry about that. You may click Open, and let me click the Blue, the Green and the Trans and click Okay. All right. So, now again this document right here is 600 by 200. So, what I might want to do is create a new document that's 600 by 800. Okay? And let me just go ahead and grab that blue and paste it up here, up at the top. Let me go ahead and grab this green and paste it up at the top and let's go ahead and grab the trans. Maybe we want to use that and just go ahead and paste that there. Cool. Let me go to the background color because this actually isn't white and let me fill the background with that color. Now, here I have five on the top, four in the middle and eight on the bottom and then my whitish color here. So, now that I have these all compiled into one kind of master chip, I could actually go ahead and say 32 No Dither and it's just going to find all the colors that are in this. There isn't 32, this is all the colors that it could find. Right? So, then I can go ahead and click master.gif. All right? So, now I've got a gif that contains all of these colors that I have extracted from Kuler. All right? So, let me go ahead and close the rest of these dogies, and now, I can go ahead and launch the Colorpicking Tool. I can go ahead and say Load Image. I can go ahead and point to master.gif. Again, it wanted to do 32 colors but they're not 32 colors so it generates a bunch of these blacks. I can go ahead and hold down the Option key and again, I'm sorry the Control key, and remove these extra colors that we couldn't find. All right? Wow! Yeah. These two here on the end or not working out for me. I'm going to go ahead and remove that. So, there is some additional editing. These two colors are kind of okay, but they're the transitions between this green and the blue. Who knows? Maybe I'm feeling it, may maybe I'm not. But the point being is that you can go to Kuler. You can start with five initial colors and then start to do some gradients on them to actually take those five base colors and expand them into a much bigger list. Again, you could come over here and say View Color List. You could say View For processing, Copy To Clipboard. I could come over to my text file here and pay some new colors into this document. So, I literally start to build these color tables off of images. I may take an image that I find and just keep refining the palettes, refining the palettes. I'll have text files that maybe have 10 or 20 different groupings of colors that I end up swapping in and out of programs that are right. Awesome. Great trick. Internet high-five. Put your hand on the monitor. So, now what do we do with this? We've stolen these colors out of photographs. We found these really great ways for compiling color tables. Now, we're going to move on to taking these colors and putting them into our programming. So, now when these assets randomly generate on screen, we're asking them to pick a color out of this color table. See you in the next video. 27. HColorPool: Okay. So, in Hype we have three different ways to deal with color. In this video, we're going to be starting with HColorPool. Now, what I've done is, you can see here on screen that I'm using the example in H drawables the, one of the drawables is HRect. Here you can see step one, build, build.pde. Now, in this particular file, we're running our setup. We are running a for-loop that's going to run a set number of times and we're just adding them to the stage. We're doing some randomization for size, for rotation, and for location. So, if you test this movie, you should notice that it just randomly throws a bunch of stuff on-screen. So, what I want to do at this point is use this as a starting point. So, I'm going to create a new folder here called HColorPool. I'll open up this folder and in HColorPool, I am just going to grab this step one out of HRect and drag it to ColorPool. So, let me just put that there. So again, folder called HColorPool inside it, step one, build, build.pde. Again, when I run the sketch, you should notice that it's just randomly generating a bunch of squares onscreen. So, let's have it so that the fills get some kind of random color. Now, in order to do this, up at the top here, I'm just going to write HColorPool and I'm going to call it colors. So again, this is a class inside of Hype for working with color. So, let's go ahead and add some colors to this color pool. So down here I would say, "Colors equals new HColorPool();" to end the line. Now, inside here is where I'm going to put some colors. So, right now, just for the heck of it, I'm going to put in four grays and I like to define colors as hexadecimal like you saw them coming out of the color picking tool. So, let's do a white. So, I'll say FFFFFF, let's do a light, even like a light white gray F7F7F7 and let's do another light gray, ECECEC, and then let's do a dark grey 333333. So, the first three are very light; white to a very light gray and then that fourth is actually a dark gray. Now, I'm going to put in two blues. So, I'll say 009a58 and I'll also put in another blue, 00616f. To finish it off, I'm going to put in two orange colors FF3300 and FF6600. So, awesome. We have eight colors in our coloring pool and again, treat it like a box of crayons. It's going to go up there, randomly pick one of those colors and we're going to paint them to the fill. So, let's make a couple of changes. Right now, our stroke is actually this orange color, so I'm actually going to change the stroke to black. So, I'll say 000000 and now for fill rather than actually putting in a color, watch what I'm going to do I'm going to create a little bit of space here. Then I'm going to say, "Hey, colours. I want to.getColor()". Now, what that's going to do is that line when it goes to set the fill, it's actually going to go up to line nine, it's going to randomly pick one of those colors and add it to the fill color. Now, if I go ahead and test this sketch, you should notice that everything should be working as expected, it did a black stroke and randomly is picking colors from the color pool. Now, the interesting bit is that every single one of these colors has an equal probability of getting chosen. So, every color gets a one in eight chance of getting picked. So, what I want do is add this idea of color waiting. How do you add weight to specific colors more than others? So, let me show you how to do that. I'm going to go ahead and close this file, save and close this document. In HColorPool for step one, I'm going to go ahead and duplicate this to a step two. Now, let's go ahead and open up this file again and instead, what I'm going to do is, is I'm going to take out the colors outside of the color pool. I'm going to go ahead and put the semicolon end of line, given a few hard returns down. What I can do is, is I can say, "Okay, create a color pool and I will add the colors manually and tell you how many of them I want to store." So, let me give you an example. I can say.add and inside of.add I could say FFFFFF and I could keep doing this, let's pick some new colors. Let's do EC, C3 or blues and our oranges. So, let's change this to ECECEC. Let's change this one to CCCCCC, let's change this one to 333333, let's change this to that blue 0095a8, let's change this one to 00616f. Then of course there are two oranges; FF3300 and FF6600. Now, it's typed a little bit differently but I actually like to do the color this way because I can specify the importance of certain colors over others. Again, if I were to test the sketch it should look absolutely identical in the sense that it randomly picked colors out of the color pool. Now, in the past, I used to do some pretty funny things where I would say, add white, white, white, white, white, white, white, white. I would do that so there were more instances of the color white than these other colors. So, when it would randomly go to pick, fit picked this one it would get white and if it randomly picked and I got this one, it would get white, and if it randomly picked this one it would be dark gray. So, I was just adding more instances of a color in order to say that I wanted it to pick more of these than another. Now, in color pool there's actually a shortcut to doing that. So, if you specify the color pool this way, if you say.add, you can say FFFFFF, and then you can do comma and then specify how many of them that you want. So, in the case of this, I've said that I want 20 of white. So, if this was to randomly pick, if it picked the numbers 0 through 19, I would actually know that it's getting color, that color of white. So now, if I test my sketch, white should be the predominant color throughout this piece which in fact it is. So, I can start to now specify what colors I want to show up more than others. So for example, if I were to get rid of this and then I would just say like, okay, cool. I want 15 dark orange and five light orange, and I test the sketch, again you should see that the orange is predominantly dominating this sketch. So, by specifying color pool this way, I could actually tag which colors should happen more than others. So, I would say in this final sketch, I actually did something like this where I would say, there were nine of these, there were nine of these, and there were nine of these. With for the threes, I just did three of them and for the blues, I put two. So, you can see that I've specified a lot more of these lighter gray colors and then just a few dark grays and then two of the blues over the orange. So, if I test the sketch, you should see that again, you get a lot of this light gray happening, a little bit of the blue, and then the orange. Because I didn't specify it, a number is obviously the rarest of the colors. So, really great trick for using color pool to take those colors that we pulled out the color picking tool and to weight them, to specify which colors are happening more than others. Now, in the next video, we're going to move on to the second type of color class which is Pixel Colorist. So, at this point, I would invite you to grab some images, steal some colors, run them through the color picking tool, and use color pool to randomly have your artwork colored by the colors that you extracted on those photographs. Okay, next video is Pixel Colorist. See you there. 28. HPixelColorist: In this video, we're going to cover working with HPixelColorist and I really love this class. It's a trick that I learned from Eric Nowitski. It's using a photograph and the color arrangement, and flow, and positioning of color on a photograph as a map to steal the color and pull into the artwork. I'm going go ahead and create a new folder called, HPixelColorist and I'm literally going to start over just like I did with HColorPool. I'm going to go ahead and open up HYPE objects, I'm going to Hrec and copy step one again. Let's leave color pool alone. It's done so let's start new. Again, if I open up step one, open up build, open up build_pde, test the sketch. You should see just an arrangement of scores. Now, what I want to do with PixelColorist is use an external assets so anytime we have to use an external asset inside of the build folder, I'm going to create a new folder called data and inside of this folder is where again, you're going to put any kind of external asset. A jpeg, a typeface, an SVG so on and so forth. If I toggle over to Photoshop, you can see here I've got that kelp picture, I've got a gaussian blur of 10 on it so the colors are kind of mushed around and I'm going to go ahead and say, "Save for web, jpeg, maximum," and I'm just going to save it right on my desktop. I can minimize Photoshop, I've got the image here on my desktop and I'm going to go ahead and drag it to the data folder. For this first example, I want to load the photograph into the background so that we can kind of get an idea of what's happening. In order to do that I'm just going to do a little shortcut here. I'm going to say, "H.add," and in H.add, I'm going to say, "New HImage," and inside of HImage, I'm going to say "kelp.jpg." If I test the sketch, it should go to that data folder, it should go to the jpeg and actually loads that jpeg into the background so now I can see it picking through the rectangles. The rectangles are a little big. Let's make them a little bit smaller by changing the size to random, 25 to 75. Now, the square is going to be a little bit smaller. Now, I'm going to go up to the top and I'm going to say, "HPixelColorist," and we'll call it colors, just like we did in HColorPool. Then I'm going to write a line here that says, "Okay colors, you're equal to a new HPixelColorist and you should go get kelp.jpg for color information." Another thing that I can also do is specify what I want it to color. So in this case I'm going to say, "fillOnly." So it's only going to be coloring the fills and not the strokes. If I were to come down to my four loop here, unlike ColorPool, we're not going to use getColor in our first example. In fact, I'm going go ahead and keep the stroke of one, I'm going to change the stroke color to black 000000 and because it says, "Fill only", I can actually remove this line or actually specify the fill color. That's because down here at the bottom on line 23, I'm going to say, "Hey colors, I want you to apply color to D," so that line 23 is going to run through all of the D's that got created here, it's going to go up to line 11 and look at the jpeg and pull the color into the fillOnly." Now we get a better representation of what's actually happening here and it's all tied to the anchor. If this is the artwork and the anchor rod is in the center, when it randomly gets positioned on screen, that anchor has a specific X axis and Y axis, so 100,100. What happens is on line 23 when applyColor fires, it goes up to HPixelColorist, goes to the jpeg called kelp, goes to the X position of a 100, Y position of 100, looks at that single pixel that's residing at 100 to 100 and says, "Oh, this is what the color is," and then pulls that color into the fill. So it's doing that every single time one of these things gets randomized onto our screen. It's looking at the same exact coordinates on the image and pulling the color into the fill. Let's go ahead and close this and let's work out some extra builds here. So, I'm going to option drag step one to a step two and I'm going to go ahead and open up build_pde and in this example, I'm just going to remove line nine. In the first one, I show you the image in the background but honestly we really don't need to see it. I'm going to change my size back to 1.5 and I'm going to run my sketch. So, I'm using the image for the color information but I actually don't need to see the image. I only did it in the first example so that we can kind of get a representation of how its position is grabbing the same color in that position. But honestly, we don't actually need to see the photograph in the background. Let's go ahead and do a step three, and if we do a step three let's go ahead and open up build_pde and in the case of this one, I want to change this from fillOnly to strokeOnly. Let's change the strokeWeight to be three and I don't need to specify the stroke color but I am going to specify a fill color and I'll change the fill color to a dark grey, 111111. Now, if I test the sketch, that line nine should only be applying the coloring to the strokes. I'm going go ahead and close this file and I'm going to take step three and copy it to a step four and I'm going to open up build_pde and in the case of this one, I'm going to say fillAndStroke. We'll keep the strokeWeight at three but I can go ahead and remove this call for fillColor. Now, if I run this sketch, you can't really tell that actually a fill and a stroke is getting colored at the same time. If I actually put in one little line of code here if I said, "Alpha(100), " and then ran the sketch, you would see that in fact a fill is getting colored and a stroke is getting colored and only by putting in that alpha(100) do we get a sense that there are two separate things that are getting colored. With that said, maybe I should do another example like a step five and that will be the final one that I do here. So let's go ahead and copy this step four to a step five. I'm going to go ahead and open up the build_pde here and in the case of this one, I'm going to change the code up a little bit. Instead of calling fillAndStroke, I'm just going pass it the jpeg for coloring, and instead of line 21 calling the applyColor, I'm going to go ahead and delete that. I'm going to go ahead and keep the strokeWeight of three but let's get rid of the alpha and let say, "Hey, I want to do something with the stroke and hey, I want to do something with the fill." Now, in the case of this file, I want it to grab the color and put it in the stroke and I wanted to grab the color and put it into the fill but with the fill, I want to apply alpha. So I don't want to apply alpha to both, I only want to apply alpha to the fill. Now, just like an HColorPool, I can say, "Colors.getColor," and I'm going to copy this and paste it into the fill. Now, getColor in the HColorPool example, was going up to the array of colors randomly picking one and pulling it down. What we have to do here is getColor in the case of HPixelColorist as it needs to know an X coordinate and a Y coordinate so it can look that up on the jpeg. I'm going to do that by saying, "GetColor," but then get d.x axis and get d.y axis. So, I'm putting in that d.x and that d.y and I forgot to put in a comma. So d.x, d.y. I'm going do the same thing for the fill. I'm going to say d.x, d.y except for on the fill, I'm going to say, "I want the alpha to be 100." So I say, "colors.get colour(), " and inside of that I'm saying, "Get d.x, get d.y," and then outside of this function call, I say, "100 for the alpha." Watch what happens when I run this sketch. When I run this, all of a sudden, all of the colors are the same. The reason why all the colors are the same is because d.x and d.y actually doesn't have a location yet. The location isn't set until line 19. So right now, it's just returning 00 which happens to be all the same color. So, If I were to take this line 19 right here where I'm actually setting the random location, the random x and y axis, and actually move that to be the first thing so that it sets the random location first. When d.x and d.y gets fired on lines 16 and 17 now, they are now unique x and unique y. So now when I run this sketch, you should notice that all the colors now are unique but only the fill is getting alpha and the stroke is not. HPixelColorist again another really great tool for sampling colors out of an image, and again that image doesn't have to be a photograph. You could open up Photoshop right now, start doing gradients, start doing pools of color. "I want pink here, I want green here," and then when we randomly generate our composition, there's actually a structure to what's happening color wise on screen because we've defined the stealing of the color from this particular photograph. ColorPool, really great. Specifying the box of crayons, grabbing for those boxes crayons. HPixelColorist stealing from an image. So, right now, I want us to move on to the next video which is going to be using a new class called colorField and colorField will allow us to define radial gradients of color in space. Good stuff. See the next video. 29. HColorField: So, the final color class that we are going to work with is HColorField. Now, HColor field is probably best described as what you're seeing on screen right now. It's a way for us to specify a point and then attach a radial-gradient to that point. What's going to happen is, if I randomly attach artwork if anything happens up here on these outer corners, then it's going to get colored black. As it starts to make its way onto the inside, it's going to transition from dark red to medium red to the bright red in the middle. Now, the fun thing about this particular class is, if I was to put this over here and then if I were to create a copy and put the copy over here, you would notice that there's no interaction between these two points. So, if I was to change this to a blue for example, again artwork would get colored blue here. It would slowly transition to a dark blue. Eventually it would return black here in the center and then would make its way into doing red. So, the nice thing is that, if I was to change the size of this radial gradient, so let's change this to 600 by 600 and let me change this one to 600 by 600. Notice what's happening now. As soon as the two colors actually start to overlap, they blend purple in the middle. So, each color field is going to do the same exact thing. You can specify points in space, specify what color exists in the absolute center, specify the radius of that radial-gradient and if the radial-gradients happened to overlap, then what's going to happen is it's actually going to start to blend the colors on screen. So again, we would get yellow at this point. It would start to transition to an orange, eventually find its way to a red, so on and so forth. Cool. So, let's go ahead and make a new folder on screen called each color field. You guessed it, we're going to go right back into hype objects and we're going to go right to HRect and copy step 1 again. Love starting from scratch. Now, let's go ahead and open up HColor field, step 1, build, build.pde, and just to reiterate, randomly generating a bunch of boxes onscreen. So, let's go ahead and go up to the top here and say HColorField is colors is what we'll call it and let's see what I'm going to do here. Let's say, let's get rid of the strokeWeight and let's say that there's noStroke. So, we're just going to be coloring fields. Now, the fill color I want to set to black, 000000 and you're going to see why here very shortly. Now, let's go ahead and add our color. So, I'm going to go ahead and say, "colors = new HColorField();" end of line. Now, what I'm going to do here is, with HColorField, you have to specify what the width and height of the field is. Now, in this case, I want the width and height just to be the same size as the sketch. So, I could type 600, 600 or I can just do width, height. All right? I'm actually going to chain on a color here. So, because I don't want this to be one long line, the semi colon I'm just going to give myself a hard return to drop it down a few lines and use tab to come over. So, let's go ahead and add an orange. So, I'm going to go ahead and say, addPoint. In the point, I want, so I've got got my canvas and I want to point to be in the exact center of the screen. So, in order to get to the center, I'm going to go ahead and say, "width divided by 2, height divided by 2." So, the first arguments are the position of the point. You can put in 100, 150, you can put in width divide by 2, height divided by 2. Now, the third argument is the color that you want to use. So I'm going to go ahead and use orange. So, I'm going to say FF3300 and then, the fourth argument is the radius of the gradient. So, I'm going to say 0.3. Now, much like Pixel Colorist, you can specify what is getting colored. So, I'm going to go ahead and say, fillOnly(), like so. Now again, also like Pixel Colorist, I'm going to go ahead and add colors.applyColor to d. Okay. So, then again, that should run through all of the randomly generated ds which are HRect and should map to colorField. So again, it's very similar to a Pixel Colorist because it's about color being at a certain location in space. So, the ultimate FF3300 is located at an x and y axis of width divided by 2, height divided by 2. Then it would slowly gradates out. Now, let's test the sketch and see what we get. All right. So, we get that orange right in the center and then it slowly gradates out but gradients out to black. It gradates out to black because we said on line 18 that the fill color was 000000. So, if for example I was to change this to white; FFFFFF, let's see what happens. In the center of the screen, we would get the orange and then it would slowly transition out to white. So, that's the nice thing about colorField is that you're specifying a field of color but if it falls outside of that field of color, then it's transitioning to whatever you said the base fill color was, in this case on line 18, I've said that the full color was FFFFFF. So again, it starts at orange and then slowly transitions out to the white. Now, I'm going to toggle back to the black here. Again, you can do that with any color. I could say a blue, I could say 0000FF. Again, if I test my movei I would get that orange in the middle and then it would slowly transition out to blue. Can I get a hallelujah? It's good stuff, this is good. That looks good. Are you happy? Pretty happy. Awesome. Let's go back to black, 000000. Back to black, that's definitely an ACD reference. Cool, saving, closing, lets do a step two option drag. Step two and reopening build PDE. Now, in step two let's add two points of color, but let's put one on the left and one on the right. So, for the one on the left here, I'm just going to say that the x axis is zero. So, the x, x is going to be zero but the height is still, height divided by two, so it's going to be in the center. Then I'm going to copy this line and I'm going to paste it. On this one I'm just going to say that its position is width. So, now it's the width of the canvas. Let's change this to a blue, 0095a8. But look at what I'm going to do, I'm going to keep the radius at point three. I'm going to go ahead and test here. Again, just like that example in Illustrator, I've got orange happening on the left, I've got that teal blue happening on the right, but because the colors don't interact with each other, that center still is picking up the black. So, I'm going to go ahead and save and close that. I'm going to save step two to a step three and I'm going to go ahead and open up build PDE. So on this example, all I'm going to do is change the radius. So, let's say I say 0.5 and 0.5. Now, that should be big enough where both colors actually interact with each other. So, if I test this sketch, you should notice that you get the orange on the left, the teal blue on the right, and then again as those colors start to interact with each other, we get a grey area here in the center. Now, let's do one last build here. So, I'll save and close this. Let me save, this is a build four and open up build PDE. So, let me just do this. So, we know that this is orange. Oh, my God. Josh you are amazing. That's spelling, orange. This is a teal, and let's go ahead and add two more colors. So I got one on the left, one on the right, let's do one on the top and one on the bottom. Let's make this color yellow on the top and we'll make this color green on the bottom. Now, I'm want to say with divided by two, and the height is zero, and the color is FFFF00. So, that's the width divided by two. So, it's in the center point of the width, but zero on the Y. So get the one on the bottom, I'm going to say, width divided by two and height. Let's say that this color is 00FF00. Now, look at this. I've got 0.5, 0.5, 0.5, 0.5, those radiuses are big. So, if I test the sketch here, you should notice that everything is mixing. So, maybe I've got too much yellow happening, too much green happening, and I just want to turn those down. So, I can change the radius. I can say that it's 0.3 for the yellow, 0.3 for the green. So really, my orange and teal are the bigger radiuses and my yellow and green are smaller radiuses. Now again, if I test this sketch here. So, now I'm getting a sense of that. I see a smaller radius for the green, a smaller radius for the yellow. Cool. I want to change this a little bit more, I want to say, fill and stroke. I want to copy the fill and paste it. Instead of saying no stroke, I'm going to say, stroke color is black. Let's also add a stroke weight of two, and let's make the fill with an Alpha of 100. So now, when I save and test this sketch, I've specified these points of color. I am coloring both the stroke and the fill, but only the fill is actually getting this Alpha. So, really cool technique for putting color in space. I love using this with the connect in the Leap Motion. You literally can put points of color in space. So, if I'm using the Leap Motion for example, and I'm painting with hand, I can actually map colors to certain quadrants. So, you might have seen some videos that I've posted where I come to the right and it paints blue, I come to the left it paints orange, I come to the top, yellow, the bottom, the green. So, I really like using color field to map colors in space. So, we've got three really great color classes. We've got each color pool, we're just doing a little recap here. We've got each color pool where we're saying, "Hey, box of crayons. These are the crayons. Pick these crayons. These are the only crayons you can use." We've got pixel colourist which is sampling color information from a photograph, but then we also have color field specifying radial gradients in space, and again, we get this nice beautiful blending happening. So now at this point, we're done with section five, working with color. We're now going to move on to sections six and seven which is layouts. So, we're getting so close in terms of having this entire process and structure in place. We're drawing some visual assets and outputting them to SVG. We are working with color, so we're going to set color off to the side. Then we're going to move on to each grid layout and shape layout, where we're actually attached. See, this is just random. We're just randomly attaching artwork on screen, but why don't we have this attach artwork based on a pattern, or based on a specific layout, and both of these layouts will help us do that. So, we almost have all the pieces of the puzzle in place. We're going to draw visual assets, work with a bank of color that we tear out, and then work with layouts to generate some pattern onscreen. So, I'm getting excited because we are getting close to the dark magic. Getting very close to dark magic. See you in the next section. 30. Introduction: HGridLayout: Let me give you an example. I'm in Linz, Austria and I'm having dinner with some friends. One of the guys that I'm having dinner with, his job at picture was actually to program the hair on Sulley in Monster's Incorporated and we were talking about randomness. Randomness on his own, isn't particularly pretty. In fact, if you were actually to randomize Sulley's hair in Monster's Incorporated, the hair would be going every direction and there wouldn't be any sort of pattern or elegance to it. Inside of the hype framework, we have several classes for actually generating layout, generating random layout. Okay? So, for this particular section, we're going to cover each grid layout. So, it's sole purpose is to align things in a grid. So, you may be thinking into yourself, "Why would we be using a grid layout to help us with randomness, a grid layout seems very structured?". Yes, it is. But where we'll start to mutate is, how did the objects rotate randomly within the cell of the grid? How do they scale randomly within the confines of the grid? I think what you'll find much to that conversation that I had with the gentleman who programmed Sulley's hair in Monster's Incorporated, we're starting with a base structure and we're randomizing off of that base structure. You'll find that a lot of that stuff, is going to be more aesthetically pleasing, because I think as humans, we don't like randomness, we don't like chaos, we like things to be ordered, we like lists, we like magnets on our refrigerator and each line has an item that we need to purchase from the grocery. We like structure. We like things to be organized. So, how can we randomize that organization? 31. HDrawablePool + HRect: All right. Welcome to section 6, which is H-Grid layout. Now before we actually start diving into the layouts, there's one last thing that I want to share with you, and that's this code that you see up on screen. Right now this code up on screen is using a four loop. Four loop runs a set number of times and it's attaching this asset. Now the problem with this code is that you're only attaching one thing. On line nine, it says, D equals new HRect and that's the only asset that we're actually painting with. But what if I want to do this idea where I have multiple assets? I'm assuming that we're going to draw a lot of different pieces of artwork and map a lot of different pieces of artwork into this composition. Right now, this code only supports one thing, HRect. So, in order to fix this before we get into layouts, we're going to cover something called HDrawablePool and what HDrawablePool does is very similar to a four loop. It allows us to run something a set number of times, but it also allows us to specify the art assets that are being used. So, instead of just one thing, we could actually point to five different SVGs or an HRect and an H-loop. So we can point to a lot of different assets in HDrawablePool. Now HDrawablePool has a lot of other functionality like if we were doing animation you can do things like asset recycling which is really great for memory, you can attach something to the screen, release something from the screen. So HDrawablePool has a lot of functionality, but we're just going to use it very basically and let's just work through a little step file here and we'll get a sense of it. So, let's keep this up on screen just so that we can see the subtle differences here. So, I'm going to create a new folder called HDrawablePool, and I'm going to go ahead and open up this folder and obviously inside of HDrawablePool I want to create a folder called Step 1, and inside of there I'm going to create a folder called Build, and inside of Build I am having a build PDE and a copy of hype PDE. Now, this build PDE I'm literally just copying this one that you see on screen right now. So, I'm going to go ahead and open this up and I'm just going to delete a few of the bits here. So, on the left we've got using a four loop, on the right we're going to use HDrawablePool. Now you'll see I do void setup, I set the size H.init this, I set a background color as a smooth on line ten yes I know I want to do H.drawstage. So, let's go ahead and start to write some pool code. So HDrawablePool and we'll just call this pool, and then what I'm going to do is I'm going to say pool equals new HDrawablePool and here is where you specify how many assets you want to paint with. So here in the four loop we said 100 so on line eight I'm going to say HDrawablePool. You're going to draw 100 assets. Now, some of this is going to get a little abstract, but let me just write the code and we'll work this out. So, let's go ahead and add the bit that actually specifies the artwork being used and creating that artwork and requesting that artwork to get painted. So, I'm going to go ahead and say add two stage. Now here I would put a semicolon, and then of course I can chain a lot of events on. But we're going to chain so much that I'm going to go ahead and do what I've been doing in all the files which is bring that semicolon down a few lines and we'll just start adding a bunch of stuff that typically we would chain just all in on string. But this is going to get this lengthy. So the first thing that I want to do is just say.add and. add is where I specify what I'm going to be painting with. So, let's just say in this case new HRect. It's capital R like so. So that's one of the things that I would like to paint with is an HRect. Now I'm going to flush out to other bits of code here. I'm going to say, "On Create," and then I'm going to say, "request all." All right. Now, it's the on create that I'm going to flush out a lot of code right here so stick with me, but these are the three fundamental things that we're working with when we're saying auto add to stage. One, who are we painting with? So I said, ".add HRect." Request all basically says give me all 100 of them. So, it's this request all that basically is going to fire all 100 things all at once just like this four loop does. Four loop executes all 100 things at once. Later if we were doing animation you wouldn't use request all you could do a timer and then you could actually pace the creation of the assets with some kind of timer. But right now we just want to throw everything out on the screen. So, I'm going to say request all. Now when request all fires and it's going to fire you know 100 times it's this on create. That is what happens to each individual thing getting drawn on screen. So think that on create is going to run a 100 times. So, it's in the on create that I want to specify basically this code here from line 17 to line 11 like the type of stuff that that the properties that gets set on a HRect. Now I'm going to say that this on create does have a little bit of code structure to it and let me just flush that out. So, the on create here this I'm going to push this close paren down a few spaces, and let me just work out some of the code that I have to type here. So, the on create is actually going to be a new HCallback and then the callback is going to have some information inside of it, and I'm going to say something like public void run and object OBJ. And open bracket close bracket. Now in this public void, I'm going to say something like HDrawable. D equals HDrawable- so close Josh, so close OBJ. So, it's this line14 now so what happens is is that a 100 times this on create is firing and inside of this on create we've got this callback. This callback creates an instance of our drawable called D, and we're saying, "Hey, D is equal to this drawable object that you've specified here on line 10 which happens to be a new HRect." Now that we've got this cast as D we can start to use the same exact code that we did here. So, I can actually take this a little bit of code right here and again give myself a little bit of hard returns and actually paste it and I would say d and then you're setting stroke weight so on so forth semicolon to end the line. Now, it is a little bit more code than just using a four loop, but there's a lot of other enhancements that we can do if we structure everything this way. Now, let's just run this sketch and see what happens. So, I'm going go ahead and save this. I'm going to go ahead and run the sketch and it should look absolutely identical to the four loop example. So, you might be saying like well Josh do I really want to use a pool you I'm not entirely sure, the answer is yes, and the reason why is because you can start to do stuff like this where this.add is where you're specifying what it's painting with. So, why don't I just copy that paste another one so another HRect, but on this HRect I do something like rounding and I say that the rounding is 10. So right now this pool is drawing a 100 items, but it's randomly going to pick one of these two HRect either an HRect without rounding or an HRect with rounding. So, if I were to test this sketch, if you look on screen here, you would see that in the case of this it used the HRect without the rounded corners and this one with the rounded corners. Now the other reason why I really like using HDrawablePool is just like color pool. We can actually wait these assets that are going to be used. So for example if I wanted to have more HRects without rounding. I could come up here and say comma 20 and that would mean that there are 20 instances of the HRect that does not have rounding. So, if I were to test this sketch here, you should notice that square corners should be the majority, but low and behold right down here we do have one that has the rounded corner. So, I prefer to use this because we can use the same exact kind of waiting of assets in this environment. Now in the next video, I'm going to take this one step further and actually point this to SVG. So let's go ahead and close this video, let's move on to the next one and I'll take the same exact HDrawablePool functionality, but we'll tie it to our SVG assets, okay? 32. HDrawablePool + HShape 1: It is really coming together at this point. We're going to work with HDrawablePool and attach some SVG assets into it. So, here is six SVG assets using some nice triangles. Here's number 2 here's number 3, here's number 4, here's number 5, and here's number 6. So, just worked out some really basic shapes. You should note that, this artwork is 50 pixels by 50 pixels. So, these little sketches themselves are, these little vector assets are tiny. They're 50 by 50. Now, what I am going to do is, here I've got them on my desktop, here I've got this folder called HDrawablePool. I'm going to go ahead and take the step one that we just completed, and take this and pull it into a step two. I'm going to go into Build and I'm going to create a new folder called Data. Inside of the Data folder, I'm going to put these external assets. I'm going to go ahead and drag SVGs one through six, and dump it into that Data folder. Now, let's go ahead and open up, build PDE and start to make some adjustments here. The first is, here we're just working with HWrecked. Instead, I want to work with these SVG assets. So, let's go ahead and just modify this to say, new HShape and you can specify svg1.svg. I don't want to do any asset waiting just yet, so that line should look just like that. Now, there are six of them, so let's go ahead and copy and two, three, four, five, six and modify this to two, three, four, five, six. So, now each drawable pool has been specified six external SVG assets in which to paint with. Awesome. I'm going to make a few more adjustments here. I'm going to change HDrawable to H shape an H shape Obj. Now, I'm not going to change anything. I'm going to keep everything as it was with a track, where I'm going to keep the stroke weight one, the stroke and orange color, the fill a dark grey, the size, random 25 to 125, not quite sure how that's going to work out, rotate random 360, location random width, random height. Now, if I run this sketch, you should now notice that HDrawablePool is now painting with these SVG assets. So, now whatever you draw, in whatever vector-based tool you want, you can start outputting these SVG files and adding them to HDrawable pool, and just like color pool, every single one of these SVG assets has a one in six chance of getting painted. Now, you'll notice that none of the styling took effect and the reason for that is because we didn't add this line of code, where we said, "Enable style and turn it to false". So, please override the styling in Illustrator and apply this styling down below. Stroke of orange and fill of dark gray. Go ahead and run this file and now we should be overriding the styling inside of Illustrator and using what's specified here. Now, if that's the case, I want to add a few more things. I have found that using stuff like strokeJoin of Round and using strokeCap of Round, tend to give me better results for what I am viewing on screen and subsequently when I actually output this back to a vector-based file at the end of this class. So, anytime I'm working with SVG, I typically set my Join and Caps to round. Now, let's go ahead and add in some of that random coloring, for example, right? So, we've got HDdrawablePool working, we've got randomly picking some of our six SVG assets, let's go ahead and add in some colors. Up at the top, HColorPool colors. I'm going to copy the colors that we did before, which were these white, these light grays, this dark gray, two blues, and two oranges. I want to change the stroke color to be black 000000, and I don't want to specify a fill because I'm going to have a color pool do that for me. So, I can come down here, and I can say d.randomColors, and then, I can say hey colors.fill only like so. Now, at this point, I should be able to run the sketch, syntax error, missing semicolon. Yes, that's absolutely true, line 34, boom end of line. Try again Josh. Run. Super. So, now you can see. Oh my God. It's totally coming together, right? HDrawablePool is the glue. It's that thing that's going to tie all these pieces together. So, lines 13 through 18 talking to a bunch of external assets. Line nine specifying some colors, line 34 setting those colors, fill only. But, what I love about HDrawablePool is you can do asset waiting just like we did in HColorPool. So, for example, this asset right here is SVG6. I love it. So, we can come here and say, hey SVG6,give me 20 of those. Now, when I actually run the sketch, you're going to get more SVG6 attached to screen than the five others right? So, this is key because, a lot of times I'll draw a bunch of stuff and one is the focal point. Like one just compositionally works out really, really well. I'll do this kind of waiting, so that I can specify that that asset will get painted more than the others. The others kind of support, but maybe I don't want them to be the focus. So, it's that line 18, where I can actually specify how many instances of that SVG gets added, allows me to control the amount of things that we're seeing on screen. So, awesome. I'm going to close this. We're going to save this. In the next video, I'm going to do a step three, and I'm going to show you some new SVG assets that even make this composition more complex. As soon as we finish that, we'll move on to organizing this. Because, right now we're just randomizing the width, randomizing the height, and that's just throwing things around on screen. How can we use a class like grid layout to actually organize this into a structure? Great. See you next video. 33. HDrawablePool + HShape 2: All right, Mongolian national ornament. We scanned this page, incredible, bunch of really nice stuff on there. Well, you probably watched that time lapse where I drew one of them well actually, I drew six of them and here they are, so here and I've just named them as mongo1.svg, here's mongo2.svg, mongo3, mongo4, mongo5, and mongo6. You should take note that all of this artwork is 300 pixels by 300 pixels, all right? Now, this artwork is obviously a lot more detailed than the first svgs that we just used in the last video. Now, I'm going to go ahead and close these out of Illustrator, here they are on my desktop, I go ahead and save our step three, go into build, go into data and I'm going to remove these svg1 through six and I'm going to go ahead and dump in my mongo1 through six. Then I'm going to open up my build_pde and I can change this to mongo1 and I will make the adjustments here on the rest of them. So we've got mongo2, three, four, five, six. In the case of this, I'm going to take off the weighting. So, again, they all have a one in six chance of getting drawn. Now, anytime I use something that's super detailed, I'm a little bit nervous about line 11 which says, "Hey draw 100 things." I could crash processing, I could get an error that says it runs out of memory because that's a lot of stuff. So, let's try changing this to say 10 assets just to start. Now, the other thing that I want to change is down here on the size, remember the artwork is 300 pixels by 300 pixels inside of llustrator. So, maybe I want to say that the random size could be something like 50 by 50 to 300. So, I know at a maximum, it's its original size at 300 by 300 and at a minimum it would be 50 by 50, that may work, that might not work. Again, let's just test the sketch to see. I think all is good with universe, let's go ahead and run this sketch and see what happens. So, at this point I can start to play with size. So, in this case maybe 50 is too small, look at this little guy right over here you can barely even see it, so I can start to do things now like, well 150 would be half of its original size and maybe I want to go bare, maybe I want to go 400 or maybe 150 I think is too small, maybe 200, 400, so that way 300 is the middle of the road, we're going 100 pixels less and 100 pixels more. If I were to run the sketch again, I could see how things are mixing on screen. So, cool it ran with 10, I can probably up this, so let's come over here and say that the pool has 50 svg assets, go ahead and run it and we should see the screen mixing a lot more than before. So cool, at this point, I really feel like I'm done with HdrawablePool, we're starting to glue these ideas together using HdrawablePool to specify how many assets we draw with, dot add who we're drawing with, do they have any weight or precedent over some of the other assets? We've got each color pool in here, so stuff is getting randomly colored. It's now at this point that I want to move away from some of this just randomness on screen and start to structure it a little more. So, the next video, we're going to implement each grid layout into RHdrawablePool and start to organize some of the assets on screen and see what variations we can come up with. Next video, HGridLayout. See you there. 34. HGridLayout: So, this whole section brings us to this point, pulling in HGridLayout. So again, all these pieces of the puzzle are falling into place. So, I'm going to create a new folder on my desktop called HGridLayout and I'm going to go to the HDrawablePool, step 2 example. The step 2 example is using the 50 pixel by 50 pixel SVG assets that are triangle in nature. So, let me copy this step 2 to HGridLayout and let me rename this as step 1 and I'm going to open up build.pde and again, I've got my six SVG assets inside of the data folder. Now, here's the code. Here, I'm going to make some adjustments here. One is, I'm going to take out the 20 of SVG six. So, by eliminating that, each of the assets has a one in six chance of getting drawn. Now, I'm after the.add, I'm going to give myself a few hard returns and I'm simply going to say that DrawablePool has a layout attached to it and the kind of layout that it has attached to it is a new HGridLayout. Now, there's some stuff that we need to specify which is; where do you want this grid to start? So, I'm going to go ahead and say, startX is zero and I'm going to say that startY is zero. Now, the next argument is because it's a grid and because a grid is made up of cells and rows and columns, what is the spacing between each of those cells? So, I'm going to go ahead and say, spacing and I'm going to say, 50,50 because our artwork is 50 pixels by 50 pixels, so that should build a perfect grid where each cell is 50 pixels distance from another and same one moving down to the next row. Now, because it's a grid, there are rows, there are columns but you actually only need to tell it what the columns are and in this case, I'm going to say 11. Now, the only reason why you have to specify columns is because HDrawablePool has a number of assets that are being drawn. So,100 divided by 11 would tell you how many rows the grid is going to have. So, there's no need to specify rows, we only need to specify how many columns we want. All right? Now, there's some stuff that I need to change down below in D. For example, I don't want to specify a size because the artwork is 50 by 50, let's just attach it 50 by 50. So, I'm going to go ahead and delete that line. I'm building a grid here, I don't want to see rotation just yet and the last thing is, is this last line of.location. If you remove.location that was the line that randomized all the assets on screen, if you remove that then layout takes precedence in HDrawablePool. So now, anytime these get on created, this layout and all of the instructions for the structure of that grid will get pushed into the creation of D, which is our HShape. Now, let's see what happens. So, I'm going to go ahead and run this sketch and you should notice a few things. One is, is our grid ends right here. Now, the reason why the grid ends right there is because we only said that the HDrawablePool was 100. So, if I actually were to come here and say, well, what is 11 times 11? That would be 121. So, if I now run my sketch, you should notice that it's a perfect grid, 11 rows, and 11 columns. So, 11 times 11, the drawable pool should be 121 assets in order to do a perfect grid. Now, because on line 38 we said, that affects startX, startY. So, since the artwork is 50 pixels by 50 pixels, if the anchor at is the center, then that means the center point is at 25,25. So, hence if we startX, startY at 0,0 then that would mean that the artwork is 25,25 negative on the X and negative on the Y, so we have it hanging off this side here. So, actually what I'm going to do is, for the time being, I'm just going to comment out Now, if I comment out and run my sketch, now the grid should be start at 0,0. Now, because this is 50 by 50, we've got a little bit of extra space where I could put another row and another set of columns because my sketch here is 600 by 600, but instead, I'm going to change startX, startY to be 25,25. Now, by doing 25,25, just means that this is the starting position of the X-axis and the Y-axis. So, now I get this grid that's floating in space here. Now, because my artwork is 50 by 50, let's run some tests here. Let's pretend for a moment that startX was zero and startY was zero and you could say that the spacing was 55 by 55 and that would mean that there's a five-pixel buffer between each of the cells, so I can space them out. Or you could say that the spacing is 50 on the X and 60 on the Y. So, that would mean that they're perfectly fine in each row but then there's a 10-pixel spacing between each row. So, spacing and startX and startY is where I can start to change some of these arguments to change the structure of my grid. Let's say this for example, let's say I said 25 for the X and 25 for the Y. That would mean that each cell is overlapping 25 pixels on the previous. So, maybe that overlapping could be interesting, who knows. So, let's get it back to where I want it to be which is startX 25 and startY 25 and let's make the spacing 50 and the spacing 50 and let's go ahead and run our movie. Now, when we run our movie, again, we get this nice, beautiful grid happening. Now, from just this base structure, I can start to save out the steps in a bunch of different ways and just modify to see what happens. So, check this out. Let's go ahead and save and close this and I'm going to take the step 1 and save it as a step 2. If I open up the build.pde, I could say, "Hey, for a moment, I don't want to see SVG one through five." So, let me just comment those out and I'm only painting with SVG six. I go ahead and run my movie and again it should build my grid of 121 assets but I'm seeing perfectly SVG six all the way across. Okay, fine. But, what would happen if I randomly rotated? Each of these individual cells by 90 degrees. Let's see what happens. I'm going to do that saying.rotate, right? Then in the rotate, I'm going to say integers, so that's a whole number, and then I'm going to say random(4) times 90, right? So random(4) is going to give me zero, one, two, three, right? Zero times 90 is zero, 90, 180, 270. So, I get all four rotations of this artwork. Now, when they randomly rotate, let me go ahead and run this sketch and see what kind of results we get. Now, look what happened. All right. The reason why this happened is because line 38, we commented out.anchorAt(H.CENTER), which means that- I don't have a piece of paper. Okay, that means that we're rotating the paper from here we are, from zero, zero and then we're turning it 90 degrees and then turning it 90 degrees, right? So, in this case, maybe that.anchorAt(H.CENTER) is exactly what we're looking for but let's comment out the rotate and let's put the.anchorAt(H.CENTER) back. Now, when I run this sketch, because I've centered it, I've messed up my start X and start Y, because I've offset it again by 25 pixels on the X and 25 pixels on the Y by saying.anchorAt(H.CENTER). So in order to fix that, the start X should be 50 and the start Y should be 50. If I do that, it should put the grid nice and centered grid back in the middle of the screen with a little bit of buffer around the outside. Cool. Now, this rotate is going to look a lot more interesting because now it's pivoting around that middle point and now, when I actually run my sketch, you start to see some really nice patterns starting to emerge from this artwork, right? Very cool. So, again, I can just start to mutate this so many different ways. Okay, use this SVG with these numbers, use this SVG with these numbers and it just starts to mutate, mutate, mutate. So, let's do something else. I'm going to go ahead and close this and I'm going to save this, and I'm going to pull out a step three here. In step three, let's try to randomize the size, right? So, the artwork is always 50 by 50, so what if I were to randomize and do the size of the artwork in increments of 50. Now, that would look something like this, where you'd say.size, okay. Now, I want it to start at 50 pixels plus something, okay, and in this something is where I put integer, let's say random(2) times 50. Cool. So, random(2) is going to return to zero or to one. Zero times 50 is zero and, but you can't have a size of zero, because you wouldn't see anything on it. So that's why I do this 50 plus at the end. So, random zero times 50 is zero, plus 50 is 50. Cool. So, we know at the smallest level, it's going to be 50 by 50. Random one times 50 is 50. Fifty plus 50 is 100. So now this line 40. Work with me here, love me, embrace me. This line 40 right here is either going to pick a random 50 by 50 or random 100 by 100. Cool. Now, when I run my movie. Movie. Quit saying movie. When I run this sketch, now it's starts to mutate into something a lot more interesting because I'm actually randomizing the size of the asset from either 50 by 50 or 100 by 100, and when they overlap, all this, check this out, this ends up being 100 by 100 but because I mathematically created these lines using a grid inside of Illustrator even though I'm scaling up times two, the lines actually will match up, which is awesome. Now, if I was to say that I wanted it to be random(4), that would mean that I'm getting four sizes, 50 by 50, 100 by 100, 150 by 150, and 200 by 200. Again, if I came up here and uncomment it out so that I was using all six of the assets, that would just mean that this artwork is even going to get stranger. Okay? Like so. Right now, everything is pivoting around that center point, and so just remember that if I comment out that anchorAt, then that rotation is a much different sweep and if it's a much different sweep, then maybe that's going to work out for me better onscreen. So, these kind of ideas is something that I've been playing with quite a lot, and I actually want to show you a URL here where I've got my a Pinterest page. On my Pinterest page, I've been sort of adding my entire design archive, and there's a little project here called the Social Grid. The Social Grid is me taking this one idea, this code that you have right here, right? So, let me just find it, bingo! That's SVG six with the random rotation 90 degrees. So, I took this one engine and mutated all of the parameters to try to see how many different kind of grid arrangements I could come up with, right? So, some were very basic and then some I would randomize the rotation, the scale and I would start to get these really, really fascinating patterns. What's nice about the series is that, all of this stuff right now is just black and white, there's not any color at all added to these documents and just by adding color, we just add a whole other layer to the complexity of these patterns. So, I saw a few of you are textile designers, right? So, this should be bananas. It means that you can work in Illustrator, work out these kind of little textures and then use HGridLayout to build this structure but randomize within the structure. Again, in the case of this particular file, the only thing that I'm randomizing is its random rotation and its random size but I'm allowing layout to actually structure the artwork on screen in a very rigid system, a grid system. Again, if you've taken the opportunity to look at my website, hopefully, some of you have been seeing the stuff that I've been doing with Libs Elliot in Toronto, Canada where, again, she's taking this file that you have right now and randomly generating these grids and then using this grid information to actually make quilts and she's hand sewing these quilts where it's just, mind blown, which is incredible. All right. So each grid layout. Really great example right here, so hopefully you will download the zip file, you'll mutate some of these steps and find out what kind of patterns you can create by changing some of these numbers. In addition to that, you can start making your own visual assets inside of Illustrator and get an endless array of different things happening. For example, here's a perfect set of stuff which is located under stuff that I did for- oh, here was a book cover that I did, Aim High, Keep Moving. Again, that's using the same exact system where I'm using grid layout and just a whole new different set of geometry and mapping that to a grid which is super cool. Then there was another one that I did. Let me just try to find it. Let me go to my boards and I want to look for Orbit. There we go. What happens when you mix in some circular shapes? Okay. Again, this is using HGridLayout. So, I'm super excited to see what kind of assets that you draw inside of Illustrator and what happens when you start mapping them to come up with these sort of arrangements. Now, this section is completed. We are going to move onto section seven which is HShapeLayout and you're going to lose it because HShapeLayout is amazing. So, we'll see you in the next section. 35. Introduction: HShapeLayout: I'm going to show you a ton of examples using this next aesthetic. This one is H-shape layout and I love H-shape layer. Let's say, I draw a bunch of flowers, right? So, I draw a bunch of independent flowers and then what I can do is I could actually make another asset that's my hand. So, what shape layout does is it looks at the drawing and if it hits a transparent pixel, it tries again. So, let's say I draw six flowers and let's say that we write a program that says, I want to draw 10,000 flowers. What will happen is is that it will randomly start picking until it hits my hand. So, my entire hand will actually be made up of all of those little independent flowers that we made, and I can actually start to define these random shapes on my canvas and every time the program runs, it's going to say, "Oh, I've got these shapes. I've got these banks of assets". There's instructions about what types of banks of assets get attached to what kind of forms. Believe it or not, this entire print is actually generated from this one warrior. You can see he's got a little belt here and if you look at the pattern that's generated along this belt, that's actually right here. You can see that that belt shape happens right on this top thing here. Here, it's randomized again. You can see the belt. What you're left with is no longer the original source material. It's no longer this warrior. It's this amalgamation of abstraction that for me, this is where I'm finding beauty in taking something familiar and remixing in a way where it becomes something entirely different. 36. HShapeLayout: All right, Section Seven. So much awesome, I can barely contain myself. I love this next project. Here's what I'm going to do. We just covered each grid layout, Section Six. If I go to HGridLayout, and I go to step one, and I go to build, and I go to build_pde, and I run this movie, it builds a grid. So, let's work off of this file. So, I'm going to create a new folder called HShapeLayout, and inside of HShapeLayout, I'm going to copy this step one. So, HShapeLayout, I'm copying step one, and let's go ahead and open up this build_pde here. So, some good stuff. Now, what does HShapeLayout do? It's bananas. What I'm going to do is look at my movie, my movie is 600 by 600. So, I am going to rock over to Photoshop and I'm going to create a new document that's 600 by 600. There it is, and I'm going to take the Type Tool and I've picked Georgia Bold at 400 point, and I'm just going to write, "Hi." I'm going to select this and center it like so. Now, what I'm going to do is, you can see I've got two layers here inside of Photoshop, I'm going to hide the background layer. So, it's transparent, and I've got this type that's hanging out. What I'm going to do is Save for Web, and under Save for Web, I am going to come to PNG-24. Now, the nice thing about PNG-24 is it supports transparency, and so you can see that I get my little checkboard in the background because PNG can handle transparency. I am going to save this on my desktop as shapeMap.png. Cool? Cool. Done. Now, I'm going to minimize this because we're going to go back to this science. Now, I am inside of the folder called HShapeLayout. I am inside of step one. I am inside of build, and there is a folder called Data and that's where we put all of our external assets. So, I'm going to copy or I'm going to move shapeMap.png to the Data folder. Now, this is some evil business. I am going to edit this build_pde. The first thing is that I don't want to draw with all these shapes. In fact, I only want to draw with svg5, and svg5 happens to be a triangle. So, there's sgv5, a nice beautiful triangle. So, we're just going to draw with that triangle to start. I'm going to modify some stuff here inside. We're not going to do layout yet, just one second. We're going to enable the Style(false). I don't actually want to have a stroke. I don't want to have a stroke, I'm too young. I'm too young. noStroke, my next class, how to do nerd humor? Anchor at H.CENTER, I like that, and I'm going to put some other stuff but I'm going to wait. Now, what does ShapeLayout do? Well, what you can do is, you can say layout equals new HShapeLayout. Now, you have to pass an argument HShapeLayout wants to know, what am I using? What am I using as the shape? I'm being vague for reason here. Now, I want to define what the shape is and so, I say,.target(). I'm going to go ahead and put that close parenthesis on its own line and that's because I'm going to tab over here, and say that the shape target is a new HImage and inside of new HImage I'm going to say the name of our PNG, so shapeMap.png. Now, let's go ahead and change up here at the top, HDrawablePool to 100. I'm really excited about this. What's going to happen is HShapeLayout gets past the target, and the target is the shape that assets should stick to. So, if I were to save and run this sketch, what happens in the case of shape layout is, that's odd, what is it doing? Well, it's looking at your image, it's randomly picking a position, and if that pixel is transparent, it re-picks again. In fact, it keeps picking a space on the image until it actually hits non-transparent pixels. If it hits non transparent pixels, then the artwork actually sticks to it. So hopefully somewhere, minds are exploding. Because it means that inside of Photoshop now, I can actually use gesture, and form, and type, and I can draw shapes. I can draw whatever I want, and artwork will stick to non-transparent pixels. So, holy cow, let's make some edits here. Pool equals HDrawablePool(2000), I want to attach 2,000 pieces of artwork. Now, our artwork is 50 pixels by 50 pixels, so I want to bring it down a little bit. So, I want it smaller so that you can really see it stick to the type. So, I'm going to say.size and inside of the.size, let's go ahead and put integer and random. Let's say that on a minimum, it's 10 pixels by 10 pixels, and a maximum of 30 pixels by 30 pixels. Let's also add a random rotate. So, I'm going to go ahead and put in a rotate here, and I'm going to say (int)random(360). You ready? Here we go. Go ahead and run the sketch and now 2,000 of svg5 is sticking to any shape that you make inside of Photoshop. So hopefully now, you're starting to understand the possibilities of how I make a lot of my generative print. You know a lot of times, I'll say, "Well okay, I want this kind of form here and I randomly want to generate a bunch of stuff just in this area," and shape layout will stick my random assets to that area. So, check this out. Let's save this, let's close it, let's go ahead and save a step two. Inside of step two, I'm going to open up build.pde. I'm going to toggle back over to Photoshop here. I can go ahead and close this. Actually, in step two, build, data, I'm going to reopen shapeMap.png. So, if I have this open, just check this out, I can delete this. Let's try some stuff, let's put a square there, let's put a rectangle here, let's change to the ellipse tool and let's draw a circle. So, I'm just defining some shapes. Now, if I was to, again, save this as a PNG, and this time let's put it inside of ShapeLayout, step two, build, and data. So I'm overwriting shapeMap.png, replace, replace. Toggle over to subline text two, save and run the sketch. Sure enough, it sticks to those assets. Again, you could even come in here with a Paintbrush if you wanted, and you could do this kind of business. Save as PNG, overwrite, shapeMap.png, toggle back to subline text two, go ahead and build your sketch, and again, you'll now see that it's actually mapping to that shape. So, shapeMap is just brilliant because if you start to look at some of the stuff that I've been making, so let's go to my Pinterest page, and let's look at something. Let's look at this guy right here. We'll do this purple one here. So, if you look at this, look at these little white circles. Do you notice that none of the white circles are down here? Why is that? Well, that's because I defined a shapeMap right in this area, just like this, and said, "Oh, okay listen. I want only circles to attach to this area." So, when I run the movie, I would randomly get circles inside of those positions. So now, I can start to define shapes in my code, and say, "Okay, I want stuff mapped to these shapes." Again, I'm still empowering the greatness of random but it's controlled. It's a controlled scenario I'm defining what goes where and all of that. Really, I'm hoping you're really going to enjoy this class, because HShapeLayout is fun. So, at this point, you can take this code that I've zipped up and attached to this lesson and you can again use Photoshop to define any shape. The thing to remember is that HShapeLayout is looking for non-transparent pixels. So, if a pixel is transparent, it's going to keep re-picking until it finds a non-transparent pixel. If it hits a non-transparent pixel, then the artwork will actually stick to that shape. So, super exciting. Great. Let's move on to Section Eight and talk about how we're going to take the HGridLayout files, the HShapeLayout files, and how are we going to export them to some assets that we can work with. Are they pixel-based images? Are they vector-based images? So, we'll move on to that in the last section, and then we'll talk about some final thoughts. All right, see you in the next section. 37. Introduction: Output Files: So, you're now at the final stage of this process. So, at this point, what I want to do is get this content out of the screen and back into some format that I can work with. Let's take a look at this composition for example. Again, randomly generated, but outputted back to a vector-based system. I wanted this area to be very, very calm. So, all of these little tiny circles that got randomly generated in this section, I was able to delete. Now, look at the number eight, if you look directly down, there's a circle that's perfectly aligned in the center with the eight. Did that happen randomly? No, Josh put that there. That circle probably got generated over here and I very deliberately moved it directly beneath the eight. So, while 90 percent of this is randomly generated, 10 percent is me going in and actually cleaning stuff up, moving stuff around. My hope is, is that you're comfortable enough with illustrator, that you would want to get back into this vector-based environment, so that you could do this kind of obsessive compulsive editing. I mean OCD. We're dating. Were dating. 38. letsRender / bad: This is it. Section eight, output them files. So, wow, we've got this all in place. We have drawn our visual assets. We've learned about how to paint them to the screen. We've learned how to steal colors from photographs and pull that into our work. We have learned how to attach these external assets in a grid layout. We've learned how to attach these assets into a shape. Now, how do we get it out of processing? There's I think about four videos that I have left to do. Let's start with the first one. So, I am going to make a new folder called letsRender. All right. Inside of letsRender, I am going to go to HGridLayout, and I'm going to go to step 1, and I'm going to open up build.pde, and I'm just going to show you this file. This is the one that's using HGridLayout. Now, this code that we're going to write is going to work in everything. So, cool, I see this grid on screen, I want it, I want to take it. Now, what I'm going to do is I'm going to copy the step 1 out of HGridLayout and I'm going to copy it to letsRender. Now, let's go ahead and open up this build.pde, and why don't we do what the processing website tells us that we should do. What it says is is, well, okay, if line 47 is where we're drawing the stage, we're painting the stage, let's save out what's happening. So, if you were to go to the processing website, it would say saveFrame. In saveFrame, there's so many different image formats that you could pass here. For example, I could say render.jpg. Now, if I save and build this sketch, watch what happens to my folder. I see what happen on screen, and in my folder, it spit out render.jpg. Now, I can go ahead and close the sketch, I can open up the JPEG inside of Photoshop, and sure enough check that out, it rendered what I see on screen. Now, it's a JPEG and JPEG has got some compression to it. If you really start to zoom in here, JPEG is not our friend. So, it's too chewy Chewbacca for for Josh Davis. So, I don't like that. So, I'm going to close this out of Photoshop, and I'm going to head back and I'm going to change this. I could say render.png, I could save, I could build our sketch. You should notice that it spits out a render.png inside of your build folder. I can go ahead and close this sketch. I could open up this render.png inside of Photoshop and much better. It's not a compressed format, we don't get any kind of that weird JPEG artifact business, so all is good with the universe. I like PNG, PNG is nice. But there's some things that I'm not really liking, which is wouldn't it be great if it was transparent? Do we really have to render the background? Right now, this is flat. What if I wanted to render this and just render it as a transparent PNG? As you can see right out the gate, it actually doesn't do that. Now, just to show you if you really didn't want any compression at all and you want to just raw files, of course, you could say render.tif and that will spit out a TIFF file. You could also do TARGA, and of course if you render your sketch, you'll see that it also spits out a TARGA file on. So, this is fine, but it's lacking in some areas. So, what I would really like to do is expand on this somehow. So, what I'm going to do at this point is stop this video, let's go ahead and start a new one, but this time we'll try to make things a little bit better. Output two, next video. 39. letsRender / better: Okay. So, now, I want to do some more advanced outputting. So, let's take this step one and I'm just going to copy the step one to a step two. All right. Inside of step two, inside of build, I'm going to go ahead and just trash these existing images that got copied over and I'm going to open up build.pde. Now, I am going to make some changes. Right now, we've only been using setup, all right. What I want to do is I'll give myself some hard returns here to move up this stuff. I'm going to get rid of this saveFrame, and right now, we've just been in the setup. Well, as it turns out, I would like to introduce a void draw, okay? In the void draw, I want to copy this H.drawStage in it, okay. Now, if you remember from before, a draw is a loop. It runs over and over and over and over again. Well, we can cancel that by saying noLoop. NoLoop basically will run the draw function once and then shut it down, okay? So, noLoop is going to shut down that draw function after it runs one time. Now, I want to introduce a new function as well called void saveHiRes. What I want to do is right before I call noLoop is I want to call saveHiRes, all right? In calling this function, I'm going to pass it an integer, right? This will all make sense here in a moment. I'm going to pass it a one, okay? Down here in the function, I'm going to say, "Oh my gosh, there's a number coming in." All right, so let me just say int, and then we'll call this scaleFactor, okay? So, int scaleFactor. Now, what I'm going to do is I'm going to write a little bit of code that allows me to do some stuff above and beyond what step one does. I'm going to go ahead and say PGraphics, and we'll call this hires is equal to createGraphics, okay? Inside of createGraphics, I'm going to say width times scaleFactor and then I'm going to say height times scaleFactor and then I'm going to pass it a renderer. So, I'm going to say JAVA2D. Cool. So, I'm creating a PGraphics that's width times the scaleFactor and height times the scaleFactor, but I'm passing it a one. So, if you come up to the top here, our sketch is 600 by 600, so 600 times 1 is 600 for the width, and 600 times 1 for the height is 600, right? So, hopefully, you're going to be able to see here, you'll be able to pass in a number to render out the size of the image that you want based on some scaleFactor. So, if I said saveHiRes two, instead of it rendering a graphic that's 600 by 600, it would actually render our graphic 1200 by 1200. So, I can render out a higher res version than what you're actually seeing on screen. On screen, you'll still see the 600 by 600 but in our folder, we'll be outputting that image to 1200 1200 if saveHiRes was passed the number two, but we'll get there. Now, after I define this PGraphics, I'm just going to go ahead and say beginRecord and after beginRecord, you have to endRecord like so. Inside of the beginRecord, I'm going to pass it this PGraphics of hires, okay? Then I'm going to say that hires should scale whatever came in as the scaleFactor, okay? So, we're scaling up the artwork based on our scaleFactor here but again, right now, it's just one so it's going to be the same exact size as our stage, width, and height. Then I'm going to put a little if-else statement here. So, let me just do if and then let me define an else and tab these like so. Inside of the if, I'm going to say if hires equals-equals null, then it should do H.drawStage, okay? Now, if hires doesn't equal null, I'm going to say H.stage then I'm going to fire our little internal guy, paintAll, and inside of paintAll, I need to pass it some information. So, inside of paintAll, I need to pass it the PGraphics. It also wants to know whether it's using 3D or not. Right now, this is still in development because we want to see if we can render three-dimensional space to a two-dimensional graphic, but this is a work in progress. Then the third argument is the Alpha that's coming in, okay? Inside of paintAll, our PGraphics is actually called hires. We're not using 3D so it's a Boolean value, I'm just going to say false, and for Alpha, I'm just going to pass a value of one, okay? Now, we've got our endRecord and after we're done recording, I'm now going to render out the image. Again, JPG, not our friend. You might like to if you want a target but I want to get to PNG. So, I'm going to go say and inside of the save, I'm going to say please save it to render.png, okay? Now, I'm digging this, so let's see what happens here. I'm going to go ahead and save and I'm going to build the sketch. Hopefully, we don't have any errors. We don't. Boom. It runs and we can see that it renders out the render.png inside of our folder here. So, from what I can tell, let's go ahead and open up this png, it looks identical to the step one. Yes, it is, okay? It's absolutely identical. However, there's actually some hidden functionality here. Check this out. This actually did render an image 600 pixels by 600 pixels. So, if I delete this PNG and ask this function call to save hires with a scale factor of two, if you save and build your sketch, what's happening at this point is it displays it 600 by 600, okay? But if I were to close this and actually look at the PNG, you would notice that it's actually been outputted to 1200 by 1200. So, if I come here to the image size, I can see that the dimensions were rendered out at 1200, 1200. So, now I can render this image any size I want despite what we're seeing when we build the sketch. So, being able to render out to a much larger size is something that I think is extremely helpful. Now, there's one other little bit here and that's the issue of transparency, right? It's a PNG, so I'm going to come back here, I'm going to delete this PNG, and it ends up that up at the top here, I'm setting the background color to a dark grey, 20, 20, 20. Well, you got it. You can actually come to background and say H.CLEAR. H.CLEAR would be a transparent background. So, if I save and build this sketch, I should see it render on screen. Now, I'm obviously not viewing the background of 20, 20, 20 anymore but if I actually close this sketch and come to render PNG and open this inside of Photoshop, it has actually rendered this with transparency. So, now, I can pull a lot of different things into Photoshop and layer them on top of each other, I can set a different background color, I can start to modify this in a way that I think is a little bit more robust than step one. So, I'm really excited about this, all right? Now, in the next video, we're going to do a step three, right? In step three, let's get this output back to vector data. So, output three, see you there. 40. letsRender / BEST: Okay. We are in letsRender and we are going to rock out a step three. Step three for me it's it, it is the holy grail of renderers. If we're using vector-based assets, then I want to get back to a vector-based output. So, let's implement that. I'm going to take step two and I'm actually going to copy it to a step three. I'm going to open up the Build folder. I'm going to delete render.png and go ahead and open up build.pde. Now, I'm going to modify some of the code down at the bottom, but before we do that, there's a few things that I want to do up at the top. The first is, is that if you're going to be rendering back out to a vector-based format, you actually need to import a library in order to be able to do that. What we're going to do is, is up at the very top, we're simply going to type import processing.pdf.*;. So, this is importing processing's PDF Library so that, again, we can work in vector and get back out as vector. Now, the second thing that I want to change is line eight, where it says H.CLEAR. I'm not working with a transparent PNG anymore, this is vector-based, so I'm okay to see the background at this point. So, I'm actually going to put the background back to our dark gray of 202020. Scrolling down to the bottom, we're going to make some changes here. Obviously, I don't want to call this saveHiRes anymore, I want to call this saveVector. In the saveHiRes, we were passing in a scale factor. This is vector and because it's vector, it doesn't matter whether that vector file is the size of a postage stamp or is the size of the Taj Mahal. It's vector, you can scale it to any desirable size thou wisheth. So, we don't need to pass in a scale factor, we can just say fire this function called saveVector. So, let's go ahead and update the function down here to saveVector. Again, I can kill this argument for scale factor and now I'm going to modify our PGraphics and, it rather than using hires because, again, to me that seems kinda specific that you're rendering out a higher res version than maybe what you see on screen, let's go ahead and change this to PGraphics tmp. PGraphics temp equals null. Now, the next thing that I'm going to do is say that tmp is equal to beginRecord, and inside of the beginRecord I'm going to say, I want you to record but I actually want you to record to PDF. So, we're going to be outputting to a PDF document. Now, the second argument is the file name. So, we'll just say render.pdf. Now, I don't need these lines on 60 and 61, so I can go ahead and delete those because again, they related to the pixel-based output, so I can delete. This if and else statement just modifies a little bit because we changed the name to tmp, so I'm going to say if tmp equals null and down here on the else, H.stage().paintAll and again we're passing in this new guy of tmp. Now, we do need to have an end record but we do not need the"render.png") because the file format that we're saving at, again, is defined here on this line 59. Now, if all goes well, I should be able to save and build the sketch and when I build the sketch, I should see on screen 600 pixels by 600 pixels exactly as expected, but in my folder, I see a render.pdf. I'm going to go ahead and open this render.pdf inside of Illustrator. So, here we are inside of Illustrator, I can open up the Layers palette and, oh I see, it automatically creates a clipping mask. So, if I go ahead and open this up, you should notice that there's probably a clipping path up at the top, you could delete that clipping path if you wanted to, you could ungroup all of this and, oh my gosh, we are back to a vector format. You can come up here and click View, Outline, we could dance at this point because this is where it's at. If we're using vector-based assets, let's output back to vector-based assets because now, all of this is editable. If I didn't like that to be a blue, gosh dang it I wanted it to be an orange, I can modify it. Where it's much harder to modify if we're rendering the PNG. So, in the step two example, because we're rendering to a pixel based image, you better like what you see because it's much harder to edit that file once it's been rendered and you've opened it up in Photoshop, but if we're rendering to vector, I can go in here and make all sorts of changes. So, if I didn't like the stroke weight, I could select the stroke weight of one of the vectors here, I see that it's selected the black stroke and I could come to select same stroke color, and if I wanted to I could change the stroke weight to five if that's what I was looking for. So, I like this idea of working with vector-based assets doing some kind of random generation instead of processing, but then the ability to render it back out to a vector-b ased composition so that I can start to do some editing inside of Illustrator. Let's go ahead and close this video, I'm going to show you one last video in terms of doing some editing. See you in step four. 41. letsRender / final edits: Because this is it. I actually don't know that song. But this is it, this is it. I want to show you something else. I am going to open up HGridLayout. In HGridLayout specifically, I am going to open up step three. Look at this one, this is the one where we randomize the rotation, and we randomize the size, and it looks like this. Now, I didn't make a comment earlier because I really wanted to address it here. Because you're randomizing the size, do you notice that the stroke weight has changed throughout the document? Like here, where it did 50 by 50, the stroke weight looks like one, and here, where the stroke weights quite large, it's gotten much thicker because the stroke is actually scaling with the artwork as you're attaching it at a higher size. Now, do I care? Maybe not initially, but I definitely want to edit this in Illustrator. So, I'm going to show you some one last tricks here. Now, this is HGridLayout, and this is step three, but we already have a step three inside of letsRender. So, I am going to copy this to my desktop like so, and then, I can close this folder, and I'm actually going to change this to a step four, and then, I'm going to drag step four into the letsRender folder. Now, I want to open up step three, and I also want to open up step four, and the reason why I want to do that is so that I can just copy and paste my business like rate appear at the top that import processing PDF. Yes, please. I'm going to paste that, and then down at the bottom here, I've got this beautiful, say, vector function. So, I'm going to copy right up to that save vector function, and then, I'm going to come over here, and I'm going to paste where it says H.draw stage. So, cool. I can close now this step three. So, I'm in step four, and all I've done is added the rendering to a PDF. So, if I save and build my sketch, again, I should see something on screen, and I also see that it outputted a render.pdf. So, what I want to do is just show you a few things actually in Illustrator. So, I'm going to close my sketch, and I'm going to go ahead and close the build PDE, and I'm going to open up this render inside of Illustrator. Now, everything looks good. If you come to view outline, yes, sure enough, it's all vector, that's awesome. It does do that clipping mask, so I'm going to open up my layers, and sure enough, there's the clipping path right there, and I'm going to go ahead and say, delete clipping path. When I do that, this guy opens up, I'm going to select all and click ungroup. So now, I'm just looking at the vectors and all of their wonderful beauty. Now, what I'm going to do is press the A on the keyboard, which is the sub-selection arrow guy right here, and I'm going to select the stroke, and I'm going to say select same stroke color. Now, that's going to run through and it's going find all of my strokes because all of my strokes have the same exact color. Again, if I do command H to hide the selection and I come over to stroke here, you'll see that the weight is blank because there are so many different strokes that have happened because of the size changes. So, I could come here and say that I want the stroke to be one, then, that fixes the way this looks inside of Illustrator. Now, I want to show you one other little trick that I end up doing in my work, and don't tell anybody because this is our secret. I love this palette which is the appearance palette, and I bet most of you don't even know that this palette exists. I love the appearance palette because what you can do with the appearance palette is while the strokes are still selected, I can see here, cool, hey, you've got strokes selected. They're using one point with no fill. Well, you can actually select the stroke layer and actually duplicate it. So, I'll duplicate it right here, and so now, I have two strokes that are actually right on top of each other. Both of them, a stroke weight of one and on this bottom one. I'm going to set it to a stroke weight of three. So, all of a sudden, you notice that all the lines get thicker on screen. Well, the reason why I like the appearance palette is because I could take this appearance palette in conjunction with transparency and I can say, "Hey, I want the transparency of the strokes that are three to be 20 percent." You would notice that, if you actually opened up this little toggle here, it would show you that the stroke is actually happening at three points with an opacity of 20 percent, but the stroke at one point is not any transparency at all. Now, if you were to zoom in, you would notice that it's just gotten nice and fuzzy, and I do this in every single one of my prints because when this actually prints on paper in one of my wide format printers here, just having that 20 percent Alpha on either side of the stroke, just softens the artwork in just a beautiful way. Now, I want to show you one other trick before we wrap up this business. Again, also in Illustrator and that's the swatch palette. So, I'm going to come to swatches here, and I can say add used colors. So, if I click that, it should run through my document and actually add all of the colors that are chilling here inside of my document. Now, what I want to do is with the swatches, I actually want to select them and turn them into a group, new color group. So, down here at the bottom, I click the little folder and color group and I say, okay. So, that's taken those colors and it's grouped them into a nice little color group here. Now, the reason why I want to do that is because you can actually select all inside of your Illustrator file, and most people have no idea what this little button does right here. It says recolor artwork. So, you click this little button, recolor artwork and it actually pulls up this little palette here, and any swatches that you add into this swatch palette, they auto-magically get added into this color groups thing. So, I'm actually going to select that, and I could come here and just say, "Hey, don't scale the tense like make it exact." But the reason why I like this palette is because I like random color, and it ends up that there's this little button right here that says randomly change color order, and I can sit there and go, oh, yeah, oh, yes. I can press this button all day long. What it's doing is it's running through my artwork and just reshuffling the colors around. So, it's just an extra step of me being able to offer a lot of different variations to my clients by setting some initial colors, but maybe using this trick and outputting this composition a ton of different ways but with different color arrangements. Now, all of a sudden, somebody says,"Oh, yeah. But can we change one of the colors?" You can actually build an entirely new set of colors, and you can recolor this entire artwork using an entirely new group of color swatches. So, those are two little secrets that I love sharing with Illustrators, is this recoloring of colors and then that stroke, putting two on top of each other and having the bottom one, have a little bit of transparency to it, so that it softens the edges. Okay. Oh, my God. We have embarked on a journey of kicked butt. Some butts were kicked. I could feel it. I could feel that a lot of butts were kicked, and I'm so excited that you decided to spend your time with my crazy. I can't wait to see what you guys do and girls. I think there are a lot of techniques in here that, again, that the thing that I want to keep driving home is that the code doesn't care what colors you use, or what art assets you use. You can make an entirely new set of drawings with chainsaws and kittens, and you could map this composition right here with train saws and kittens. The code is completely artwork agnostic. We're specifying what assets should be used. So that means that at the end of this journey, the work that you create, and the work that you share with all of us that have taken this class is going to be completely unique to you, and the reason why it's going to be unique to you is because you're drawn to different colors than the rest of us are. You're driven to different forms than the rest of us are and even using these simple building blocks, there are an infinite number of possibilities that should hit our gallery, and I'm excited to see that happen. Great. I hope this is one of many classes. I would love to do another class on animation, and I would love to do a third class on hardware like the Leap Motion and the Connect. So, if you enjoyed this class, tell those Skillshare people that I'm the best teacher that you've ever had in your entire life and that we're dating. We're dating. Thanks. Hit me up on Twitter. Hit me up on Facebook. I Like email. I read email. Thanks again. Thanks for taking this class. See you later. 42. Some Parting Words...: We've come to this great ending of output. This is where I'm really excited to see what you guys do, because hopefully, you've seen at this point, your drawings are your drawings, your color choices are your color choices, and it's that output that is randomly happening within these layout classes. Just like the stuff that I show you is completely unique to me, and it's driven by taking this trip going to Istanbul, it's away from the computer, right? That's where this magic is. It's not in front of the computer, it's about taking a trip to Istanbul, and walking through the Grand Bazaar, and finding these drawings, and having this moment of, "I can take this drawing and I can make it my own. I can make it my own by redrawing it and abstracting it, in a way that this computer programming is going to use to generate that excitement on screen." Then, it's going to get populated with colors that I may have experienced on that trip. I make a turn, and I see mosaics with certain colors, and I take a picture of those colors, and I'm going to extract the colors out of that photograph. So, this entire output is completely driven by those initial choices that you make, which means all of these work that you're going to be vomiting to this class is specific to you. It's specific to the imagery that you're drawn to, whether it be floral or organics. I have my flower phase. Maybe, you are going to have your flower phase. I then drew way too many flowers and I moved into geometry. Had to go mathematical. So, these kind of aesthetics that you're drawn to are going to define your output. Your output, again, completely unique to you. So, I'm super excited because you should be dazzling all of us with your awesomeness. Can I get a hallelujah? 43. hexGrid / Randy Steward: Hey. So, I thought it would take the time to add a section nine called Project Inspirations, where I would take things that I see that you guys are posting onto the student gallery, and maybe show you some things that I would do. Yeah. So, here's a post that Randy did, and he's doing these hexagons, and just by looking at these hexagons, I thought I would show you how to combine a lot of different pools with a lot of different grid layouts. So, attached to this video, there's going to be a file, and let's look, I had broke it down into six steps. So, let's look at step one. Step one is obviously, I have a build PDE, I have height PDE, I have a data folder, and inside of the data folder I've got hexagon SVG. If we toggle over to illustrator, you can see that I just made a very simple hexagon here, and also this art is a width of 50 and a height of 50. Right. So, each of these little hexagons is 50 by 50. Okay. So, let me show you by opening up this build PDE here some tricks. So, the first thing is that, let me just make the font size a little bit bigger. Okay. Is I've compacted the HDrawablePool code. Okay, and you'll see why, because again we're going to add six different pools here. All right. So, up at the top I said dp1 for drawable pool one. I said I want to draw 88 items. On line 10, I've specified that I want to use a hexagon hexagon.svg. On line 11, I've created a grid layout, and I've said, Okay I want you to start on 27 on the x-axis,40 on the y-axis this spacing is 78, the Y spacing is 51 and columns is eight. Okay, and in this particular one, I say all right, let's kill the styling that comes over from illustrator, let's kill the stroke, and let's add a fill of dark gray, and put the anchor point at the center. All right. Now, so it's one pool using hexagon SVG, and if I run this, you'll notice that it builds a grid like so. Now, you'll notice that the numbers that I've come up with allow for me to write, to put a new grid inside of the spacing, that's what the spacing is, its 78 pixels because it's aligned in a way so that I can put in another hexagon here. But this hexagon, obviously is on a different start x, and in a different start y, because it's not aligned with this particular grid. All right. So, let's move on to hGrid two, and in hGrid two up at the top, I change each drawable pool, let's say I'm going to have a drawable pool one, and a drawable pool two. In drawable pool two, I say okay, I want 70 items, I'm still using hexagon SVG, but you'll notice I have a different start x I have a different start y, but the spacing is still 78 by 51, and the column is seven. In the case of this hexagon SVG, it's identical to the one up above except for a set the fill color to that dark orange. All right. So, now we have two drawable pools using the one hexagon SVG. So, if I build the file, I now have a second grid and using a second drawable pool with a different layout, but I'm able to put it in such a way so that it fills the spacing in between the first grid that we created. Okay. Now, let's just extend this a little bit further. So, in build three, I've said okay, well, I want to do an H pixel colorist. Okay. So, check this out. I say H drawable pool, I'm going to add a third one, but now I'm going to add a pixel colorist, right? I want to steal color from actually a gradient Jpeg. All right. So, there's our hexagon and inside of Photoshop, I created an image that 600 by 600, and I made a gradient that went from white to black. Okay. So, if we were to look at drawable pool three, again it's identical to drawable pool two except, for I changed a few things. I said I want the size to be 40 by 40 instead of its default 50 by 50, and then on line 36, I said, hey let's take this color pool gradient, and apply color to the fill only. So, now when I test this movie, I now have a third grid that's on top of the second grid, but using each pixel colorist to transition from white up at the top, towards black, towards the bottom. Right. So, now I've got three drawable pools, three grids, and again I can continue this kind of stacking. So, let's open up hexGrid four, and of course I'm now adding a fourth drawable pool. But this time, I add H color pool, and in H color pool, I've got the colors that basically we've been working on all of our sample builds. So, some grays and two blues, and two oranges, so on and so forth. Now, down here at the bottom, I copy the same exact thing of drawable pool three. So, I copy drawable pool three, rename it as drawable pool four, again it's 70 hexagon SVG, but I changed the size to be 20 instead of 40, and then I say, instead of CP one, apply color I say CP2 apply color. Now, this should put a fourth grid on top of the third grid which is on top of the second grid, and we get something like this. All right. So, now we can see that it's randomly picking colors on that fourth grid. Now, we've got this grid, the very first one that we recreated that's still gray. So, why don't we duplicate the same thing but maybe reverse it. All right. So, let's go ahead and open up H grid five, and an H grid five up at the top, I create a drawable pool five, and in drawable Pool five, I actually copy drawable pool one. Right? Because two, three, and four are stacked on top of each other. I want five to be stacked on top of one. Again, I changed the size to 40, and I do the CP2 which is the H color pool. So, if I were to run this file, it should put the drawable pool five on top of drawable pool one, which you can see here in this row is randomly picking colors out of the color pool. Right. So, we've reversed it than this stack. Now, let's add the last grid. If you go to H grid six, and you open up build PDE, of course up at the top, I've created a drawable pool six, drawable pool six is just a copy of drawable pool five, but I've changed the size to 25, and I've actually used the gradient pixel colorist apply color. All right. So, now, drawable pool six is on top of drawable pool five, and drawable pool five is on top of drawable pool one. So, we're basically just doing grid stacking. All right. So, now if we look, we can see that we've got some hexagons that are going from the white color all the way down to the dark color. All right. So, by using this structure, we can actually stack a lot of drawable pools all using the same hexagon SVG, but just using different layout with different parameters, and so we can get this layer stacking. Now, what I think it's going to look good in. Let me just go to the URL here. Skillshare. Now, what I think it's going to look good in Randy's file instead of using one SVG, if he was using all these different mutations of SVG, Right. Then this file would actually take on this new textural pattern, which I think would be the beginner. All right, I'm going to wrap this up. I'm going to continue to be totally inspired by the things that you guys are posting, and I've got some other ideas for some other project inspiration remix videos that I'll post under this section. All right, see you later. 44. hypnoWheel / Luke L: Okay. I thought I would record. Hi, how are you? How's the class doing? Good? I thought we would do another tutorial for section nine, which is project inspirations. This one, Luke L, really like some of the imagery that he's coming up with here. But I thought I would break this one down and show some possibilities with it. So, I've created a new folder on my desktop called hypnoWheel. I've just used Luke's project as kind of a starting point, but I'm actually going to recreate the vectors a little bit differently and we'll talk through it. Now, the nice thing is that you can click Luke's link right here, and you can actually see this particular file running. It's got some things that maybe I would do a little bit differently. So, I thought maybe we would do the same thing as before, break down some steps, show some possibilities, and go from there. Now, in Luke's file, let's just go ahead and close this. In Luke's file, his SVG assets are actually fills. I actually wouldn't use fills. I would use strokes. Let me explain why. So, if I toggle over to Illustrator, you can see here that I've recreated the assets, but rather than using fills, I'm actually using strokes. I just made four SVGs. The artwork is 100 by 100. I just took a circle and divided it up into a bunch of subsections. So, again, important to remember that the artwork is 100 by 100. Again, I've got four sample SVGs here. So, first, we're looking at Build one. This little project is going to have five different steps, and I'm going to showcase some different features. So, let's just talk about some of the stuff that Luke does in his file, and how I would address it in my file, and also add on some features. So, Luke, I'm also speaking to you specifically and other people who are just listening. First thing is that rather than, in your particular file, you copy white a bunch of times, don't forget that in color pool that you can add color weighting by specifying the color, then specifying how many instances of that color that you want. So, rather than copying and pasting white, white, white, white, white, white, white, white, you can actually define your color pool this way. Again, here you can see I've said, "Okay, I want a dark gray." A medium gray give me six of them, a lighter gray give me four of them, and a lighter gray give me two of them. So, again, I can focus on the color weighting this way. Now, I've added some other stuff to this file. Here are my four SVGs. Again, remember that they're strokes, not fills. Why is that? Well, the first thing that I want to talk about is using scale as opposed to size. Now, in some of the examples that we've done over the course of this course, it's been setting size. Setting size is when you're setting like, okay, I want the width to be 100, and I want the height to be 100, or I want the width to be this and the height to be that. What scale does is, scale is based on the artwork's original size coming over from Illustrator. So, I'm saying pulling this artwork from Illustrator. That artwork in Illustrator already has a set width and height. What I want to do is change scale. Scale is a percentage. So, 0.5 would be 50 percent smaller. A scale of two would be 200 percent bigger. So, again, check this file where I'm using scale as opposed to size. So, on line 38, I say, "Well, okay, I want to set a random scale." I say at the base, it should be one and then pick a random 16 number and jump in increments of 0.3. You'll see what this does in a moment. Inside of the drawable, enables style false. So, I set the anchor at the center. I attach it to the center of the screen. Then, instead of using dot size, I'm using dot scale and passing in that random scale that I set up on line 38. Now, I'm not using fills. So, I go ahead and say no fill. What I do is I'm playing with the stroke. Now, one of the questions that you asked is, how can I attach something but have everything to be the same weight? So, again, this is why I would want to use stroke rather than fill because you can see on line 47, I can say strokeWeight, start with a base of 10, but then multiplied one divided by ranScale. So, what happens is, as the artwork scales up, it scales the strokeWeight down. So, that way, it appears that the strokeWeight is actually the same weight no matter what the size, whether it's in the smallest in the center or the largest on the outside. Line 51, I set a randomColor and on lines 55 through 57, I set a randomSpeed for HRotate. Here, I'm saying that if random picks is zero, give it up a speed of one. Now, let's just go ahead and test this sketch so that you can see what's happening here. So, as you can see, it actually looks like the strokeWeight is the same, and that's because as I'm scaling the SVG up, I'm actually dynamically scaling the weight of the strokes down. So, they all appear to have the same strokeWeight. Don't forget on lines 48 and 49, you can specify what you want the strokeJoin and strokeCap to be. So, you can see here I'm getting rounded caps. Now, I've added some other really cool features in here. The last section of the class is actually how they output. So, I thought maybe you would want to output this particular file. So, you can see up at the top, I've put in the importprocessing.pdf. I also put two toggles here, one for pausing and one for recording. If you actually scroll down to the bottom, I copy and paste our same vector function, that again is in the last section of the class, and then I put in a void keypress to do a couple of things. Spacebar will pause and restart, the plus key will advance to the next iteration of the animation and pressing the R key would actually render to PDF. If I run this sketch one more time what you would see is that I can press the spacebar and it actually pauses the animation, I can press the spacebar again, it restarts the animation, I can press the spacebar to pause it and then I can press the plus key on my keyboard and actually advance the iteration of the animation by one. So I can really start to look at this animation and go "Okay, let me press this a few times until I get to something that I like", and then of course, if I press the R key it actually will render it. If I set this off to the side you'll see that it is rendered a PDF document that obviously I can open up inside of illustrator and all the vector information is there and everything looks good. That's file one. If we move on to file two, all I've done in file two is said that I want the join and cap to actually be square, so this starts to look a little bit more like your animation because I'm not rounding the caps, I'm squaring caps. Let's move on to build three. On build three, I've added a little bit more functionality here, which is, what if I randomized the base weight? So, you'll see on line 39 I pick a random base weight for the stroke and when I actually set the stroke weight on setting the base weight times and the dynamic scaling, so rather than it looking like it's all the same weight, if you actually run this file, I'm actually randomizing the base weight and I think it starts to look a little bit more interesting. It just so happens that what I'm seeing on screen right now, I'm not crazy about the color. So, I thought I would introduce the ability to randomize some of the color. If you come down to key press, you'll notice that I added a new key press for the letter C, C obviously being color. What's nice about ool is I can do this kind of talking right here which is for while you find drawables inside of pool. So, this for loop will now iterate over the pool and find all of the drawables that we've set inside of pool. So I said, "Cool", HDrawable temp inside of pool and then I create a new HShape d and set it to the object of temp and then refire the random colors stroke. So if I were to test the sketch, have this thing run, again, if I didn't like the colors I could actually press the C key and it would actually re-randomize the colors on screen for me. Now, again I can pause it. Just know that on line 101 there's redraw, and redraw is going to redraw everything and unfortunately it's also going to redraw the HRotate animation running. So, if you actually press the C key now, not only will it re-randomize, but it's also advancing the HRotate animation by one. So, just be cautious that C will randomize the color, but it also is going to rerun HRotate. Again, if I press R I could actually render that out, I can now go to build three, and you'll see that I can open this up in Illustrator, and I'm rendering out a pretty nice-looking piece artwork. Let's look at build four. I actually comment out the use of asset one, two and four. I'm just using SVG3. The reason why I'm just using SVG3 is because I'm going to introduce something new and I know this starts to get into animation and my Hope is that I will do a skillshare hype class on animation, but what I've done here is I've actually swapped out the animation of HRotate and introduced HOscillator. HOscillator is really nice because it's actually drawing with a wave function, and in this case, I'm using a sign wave. So, what I'm doing here is saying "I want an HOscillator and what I want to oscillate is actually rotation. So, I want to oscillate from -180 degrees to +180 degrees." I specify a size and I specify a frequency of the wave. If I were to test this sketch using HOscillator instead of HRotate, I can start to get some really interesting wave animations by using that as opposed to HRotate, and again, I can run this and pause it, and of course, I can render it out. Now build five, which is the last, the nice thing about hype is that you can actually stack behavior. So, in this case, I'm stacking two HOscillators, one that's doing rotation and another that's doing scale. So here you can see on lines 67 through 74, I introduce a new HOscillator where I'm changing the scale of the artwork from 0.25-1.5. If I were to test the sketch, you would start to see the system now looks like this. So these are just a lot of different things, a lot of different features that are in hype that, again, even if I'm doing static print, I may run a behavior like this and "Okay, let me change the colors until I get something that I like" and then when we press the plus key to advance to the next iteration of the animation, "Cool, I like that right there" and I end up rendering it out and maybe I use it in a poster and I use these shapes to detype along the shapes, the possibilities are endless. Keep posting new projects in the student gallery and I'll keep making these types of video. Hope you have fun. See you later. 45. Processing 3 + HYPE library / update: To record a quick little video of an update. When I first did these courses some four years ago, Processing 2 was the thing. In conjunction with using Processing 2, HYPE, and how I described HYPE in all of these classes, was also a.pde file. So, in these three classes, you had a HYPE.pde. HYPE.pde contained the entire HYPE library. That also meant that you could use things like processing JS at the time. But now, a lot's changed. It's four years later. Processing JS really isn't a thing much anymore, but P5 JS is the new, new. Of course, we have Processing 3. Well, since I was doing more on an application basis, and not really using the browser anymore, we actually updated HYPE to a proper processing library. So, what I've done is, I've gone through all of these classes that I had previously done four years ago using HYPE pde and Processing 2, and updated them so that they were using Processing 3 and HYPE, the proper processing library. So, I just wanted to show you really quick, if you go on to, you will see that there is HYPE Processing right here. This is the Master_Repo. However, I just want to show you that if you click branches and inside of branches there is lib_staging. Lib_staging is always the most current. It's where we're pushing the most stuff, the most changes, making adjustments. It's always the work in process before it actually gets pushed to Master. So, because we want the new, new, the secret new, new, let's go ahead and go to lib_staging and you're just going to click this green button that says "clone or download", and then you're going to say "download zip". Now, what this is doing is downloading the entire HYPE library including the source code and everything. But, we want to use it inside of processing. So, you'll notice that if you go to your documents file, Processing, there's a folder called Libraries, and in the case of this particular example, my folder is empty. So, I am going to unzip the zip that I just downloaded, and I should get this guy. What this has is it has reference and examples and resources. Really the only thing that you need to look at is the Distribution folder. The distribution means this is the current build that you can push inside of your documents Processing Libraries folder. So, go into Distribution, and you'll notice that there is HYPE.jar and Let's go ahead and unzip, and it will create this folder called HYPE, and you are just going to drag that folder to your Processing Libraries folder. So, inside of this HYPE, you should have example, library, reference, and source. If you look at examples like, "Oh my gosh there's a ton of examples here." Now, if we were to launch processing the IDE, you would notice that if you came, it's probably going to tell me to update. No. Yes. No. Let's go to sketch import library. Look you should see HYPE there. So, now HYPE is a proper processing library. So, the question is, does that mean can I use this in a browser? No, you can't use this in a browser. If you wanted to output your stuff to JavaScript, I don't suggest using this environment at all, go ahead and look at the P5 JS project that's happening which is processing for the browser in JavaScript. But, if you want to update all of these class files that I've done over the past couple of years, I moved to the system now. Where you're going to be using Processing 3 and then you're using HYPE, the processing library. So, cool. So, we got this inside of processing and just for the heck of it, if I was to move this aside and here is some of these Skillshare and Gumroad classes that I have been working on, and you'll notice if I go to Programming Graphics 1, I have now included in this zip all of the updates to this code to use Processing 3 and to use HYPE, the library. So, if you go to, let's just say Drawing Visual Assets, and you were to go and look inside the folder, you'll notice that HYPE.pde is now removed completely from all of the projects. If you click on buildpde, you will notice up at the top here that we've got a new structure, which is now that it is a proper processing library, you have to import HYPE as an external library. So, up at the top, you can see I've said import HYPE.asterisk, which means loaded in. If you want to use other things, so if you just are importing HYPE, you get the bare bones that's needed in order to use HYPE with Processing 3. If you want extra stuff like, "Hey, I'm using a color pool or I'm using a grid lay out," then you have to also manually import the class that handles whatever it is you're trying to use. The best thing to do is to go into examples and say, "Hey I want to use an oscillators." So, if you look at oscillator, you'll notice oh, I've got to import oscillator. That means that this keeps the HYPE library very thin. Whereas before with HYPE.pde you were importing everything, even if you weren't using it all. So, this is lean, this is mean, it's much more efficient as a proper processing library. You import the classes that you want to talk to. So again, look at the examples folder, it will show you how to structure things. In addition to that, if you look at this zip file, you will see that all the files are there just like they were before, but they all have been updated to support this new structure. I'm going to do that for all the classes, and I'm obviously going to use this structure for all new classes going forward. Hope that helps. Chat soon.