Okay so you've made a few programs.
You might be wondering, how on earth am I supposed
to remember all these commands? Is it oval or circle or ellipse?
Is it width and height? Or is it height and width? Do I have to memorize all of this? Thankfully, no. That's what the computer is for! The thing is, we always have a computer
with us when we're programming. And a computer is really good at
remembering things, better than we are. So what if we just have a computer
remember all the details for us and we can just use it like a dictionary for programming? Then we can focus on making cool
programs, not memorizing plenty of boring details. That's what we call documentation. A document that explains how to program
in particular language and environment with examples and catches, so if we can't
remember the exact details, no worries, we can just look them up. You might think it's boring to read documentation, and you're right, it is kind of boring, it's a lot more fun to write code. But unless you want to memorize absolutely everything, you need to learn how to use documentation or be able to code your ideas. Even great programmers don't try to
memorize everything. In fact, great programmers are usually some of the best at reading documentation. For example, I'm drawing this smiley face and I've already drawn the face and the eyes using ellipse, a function I know pretty well. But I have more work to do.
First, I want to draw the face with thick outlines,
like a sticker. I remember it has something to do with stroke, but I don't remember exactly the name. So, instead of sitting here and trying to invent it, which could take hours, or infinity, I'll just go to the documentation tab and look around,
and try and find what I'm looking for. And I'll look into this coloring category,
because that seems likely and look at all the functions here, and then finally at the very end I find StrokeWeigth, to change the thickness of lines and outlines. So, here we see the function name and the parameters, just one in this case, what I usually do is start off by just copying that code and pasting it into my code but I immediately get an error
"thickness is not defined" That's 'cos thickness is a placeholder parameter,
it's not a real value. I am meant to replace that
with what I actually want it to be. Right, so that could be with a number
or a variable that refers to a number. So, in this case, I'll just put a number in.
Yeah, okay, perfect, 10's nice but you know, you could fiddle with that and see; that's a little extreme, that's too small. Right, so, go back, 12, cool. Now there's something really obvious missing in my smiley face, the smile. So, I basically just want something like this.
And I can look at that smile and think, well, does it look like something I'd draw using ellipse or line or rect? It's got this curve to it. But it doesn't have an inside. So, I think, well, I should check the docs and see if there's some other way to draw a curve like this. So, to the docs machine we go!
Scrolling down, scrolling down and looking around. So, I'll check at the shapes category. Aha!
The very first entry in shapes is arc, which is used for drawing an arc, which sounds kinda perfect, 'cause that's what the smile is. So, this one has a lot more parameters in it,
I'll start off by pasting this in here, and remember these are placeholder parameters,
so we need to replace them with what we think they should be. Alright, so X and Y. So maybe X and Y is where I want it to begin, so we'll say, let's see, so our middle is 200, so maybe it will start at 150 and then Y is maybe 250. And then width sounds like the width of the arc, so it's probably a bit less
than the width of the actual face. So, maybe it's 200 and then the height, maybe that's the height from the top of the arc
to the bottom, so maybe that's 50. Start and stop.
I don't actually really know what those are. Okay, so, now I'm stuck,
because I'm looking at this function and trying to use it, but I don't really
understand these parameters. Well, luckily, what you can do,
is just go back down to the docs and actually click on the function
that you're interested in and it will bring up a programme
that shows you how to use it and actually explains the parameters
in lot more detail. So, if I look at this, it says, X is the X coordinate of the centre of the ellipse derived from the arc. Okay, so it basically seems, to draw an arc, you kinda have to pretend you're drawing an ellipse, but only a part of it
and calculate everything based on that. So, the X and Y is actually the centre of that pretend ellipse we're making, the width and the height are the width and height of that pretend ellipse and start and stop -those are the ones I didn't know-
start and stop is the angle, ahh, the start angle to start the arc at in degrees, and stop is where to stop it at, right? And we can actually look at the examples they've done here, so, drawing an arc without fill 1 to 270- that's probably this guy over here, right, cause 1 degree to 270 degrees,
that's what that would look like. Let's try and change, there we go, that makes sense, cause then 1 to 180,
that's kind of what we want, right? Cause we want our half-arc, okay. So, now I think I understand arc
well enough to use it. And let's go back to my smiley. Alright, so we're going from 0 to 180,
and we've almost got it. My X and Y is off, cause I didn't realize
the X is actually the middle of the ellipse. And it's a little bit wide,
so let's go and make that smaller. I now have a real smiley face. Thanks to using the docs,
I was able to do what I wanted much faster, and that's the goal with programming. Turn our ideas into reality faster.
Remember, use the power of the docs!