![]() The next thing that we did was we said we wanted to compute inPixel's red + inPixel's blue + inPixel's green, divide that by 3 and call the result average. ![]() That's going to mean we're declaring another variable, so it's going to be inPixel = inImage.getPixel. Now, when we do this, we need to give it a name so we can use it again. So, what we're going to want to do is, inImage.getpixel at the same location as pixel. In our algorithm, the next thing we did was we looked at the corresponding pixel in inImage. And you can see that BlueJ put this all in pink so we can easily see that these all are going to happen for each pixel. And we're going to put curly braces around all of the steps of our algorithm that we want to do for each pixel. That's going to be a for loop, which you've seen before, pixel : outImage.pixels. The next thing we did in our algorithm was, we wanted to do something for each pixel in outImage. This is going to be the width of inImage and the height of inImage. And when I create this ImageResource, I need to pass in information, in this case, telling it how big I want my image to be. And since I want to make a new thing I'm going to say new, the type of thing I want to make is an ImageResource. So if I want to make a new image, I'm going to declare an image resource. The next thing we did was we made a blank image of the same size as inImage. In this case, that's going to be a parameter that we pass to our function, so that this function can operate on any image we want. The first thing we did in our algorithm was we started with the image we wanted inImage. And before this video started, I went ahead and wrote in the steps that we came up with as comments in our code, to guide us as we write. We've started here with a class for the grayscale converter and we've already imported edu.duke.*. I suggest using the $HOME/.local/bin directory, if it exists, because that's generally in your path.Now that we've developed our algorithm to convert to grayscale, we're ready to write code. Once it launches, point it to the directory you want to use for installing. If you're using the generic installer, launch it with Java from a terminal: $ java -jar. It also offers a "generic" installer, delivered as a JAR file (the usual Java format). BlueJ also requires JavaFX (as a separate download), so follow the instructions on the BlueJ site. After you've installed Java and JavaFX, launch the BlueJ installer.īlueJ has downloadable installers for Ubuntu Linux, Windows, and macOS. However, to use BlueJ, you must have the same version of Java used by BlueJ, so check the version you have against what BlueJ requires. You need Java to program in the language anyway, so you may already have Java installed. ![]() Installing BlueJīlueJ is written in Java, so to run it, you must install Java. ![]() It's meant to help you learn the language, not to type faster or more efficiently. It's very much a learning tool, and it's purposefully less helpful than a full IDE like Eclipse or NetBeans. You don't have to rely on indentation to see that a Java method falls within a specific class because you can see the blocks of code.īlueJ isn't an all-purpose IDE. By using colored backgrounds, BlueJ helps you visualize the structure of the code you're writing. It can be nearly impossible to tell a variable apart from a keyword that's a part of the language, and even with the assistance of indentation and braces and semicolons, it all starts to blur together.īlueJ is designed to clear away this confusion. It doesn't help that when you're learning to program, most of the code you type looks and feels basically the same: it's all vaguely meaningful, yet oddly similar, with words that seem to make as much sense whether you read them backward or forward. If you're new to programming-or just new to Java, it can be difficult to understand advanced concepts like variable scoping and loops and conditionals. It uses a subdued color scheme to keep different code elements separate from one another, so it's easy to tell a class from a method or a comment. When you create a new class, BlueJ generates a clean but robust template with hints toward what you need to do.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |