<< Chapter < Page Chapter >> Page >

Recall also that if you plan to export your sketch in JavaScript mode or to export your sketch as a stand-alone application, you must use literal values asthe parameters to the size method.

You should set the height of the display window to be at least 70 pixels greater than the height of the image to allow roomto display the width, height, and pixel information below the image as shown in Image 4 . Otherwise, the black text will be printed on the image and may not be visible, depending on the color of theimage.

If you don't know the size of your image, simply make a guess. You will either get an output that displays the size of the image, as in Image 2 and Image 3 , or you will get an output that shows the image as in Image 1 and Image 4 . In either case, the width and height of the image will be displayed and you can use this information to update the call tothe size method and recompile the sketch.

Set the font

The only other thing that is new in Listing 2 is the call to the createFont method.

This statement is required to prepare the sketch to draw the text characters on the display window as shown in Image 1 . I will leave it as an exercise for the student to study the documentation for the createFont method in whatever depth is necessary to understand it.

The draw method

The draw method is shown in its entirety in Listing 3 . As you can see, all the duties of the draw method were delegated to the run method belonging to an object of the class named Pr0120aRunner .

Listing 3. the draw method.

void draw(){ obj.run();}//end draw
Listing 3. The draw method.

You might be wondering why I didn't simply write that code in the draw method. The reason is that I frequently provide my students with input and output images (such as Image 1 and Image 4 ) along with the driver code in Listing 10 . It is then the students responsibility to design and write the code in Listing 11 .

In other words, I provide a driver class along with the input and output images. It is the student's responsibility todesign and write a class that will run in conjunction with the driver class to transform the input image into the output image.

The class named Pr0120aRunner

Beginning of the class

The class named Pr0120aRunner begins in Listing 4 .

Listing 4 also shows the beginning of the method named run that is called by the draw method in Listing 3 .

Listing 4. beginning of the class named pr0120arunner.

class Pr0120aRunner{void run(){ background(255);//whitetextFont(font,16);//Set the font size, and colorfill(0);//black textloadPixels();//required img.loadPixels();//requiredfloat reD,greeN,bluE;//store color values hereint ctr = 0;//output pixel array counter
Listing 4. Beginning of the class named Pr0120aRunner.

The run method begins by setting the background of the display window to white, and then takes care of some more housekeeping details regarding fonts.

Daniel Shiffman tells us about the requirement to use the loadPixels method and the updatePixels method in his tutorial titled Images and Pixels . I will leave it as an exercise for the student to study and understand that material.

Finally, Listing 4 declares some local variables that will be used later.

Check for size problems

The code in Listing 5 checks to confirm that the image will fit in the display window. If not, one of the messages shown in Image 2 and Image 3 is displayed in place of the image.

Questions & Answers

where we get a research paper on Nano chemistry....?
Maira Reply
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Google
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, The processing programming environment. OpenStax CNX. Feb 26, 2013 Download for free at http://cnx.org/content/col11492/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'The processing programming environment' conversation and receive update notifications?

Ask