Next Graded Assignment :
Finished Class Web-site - due 27 May 2016 at 18:00 Two Mini-Site web-pages - due 31 May 2016 at 18:00 |
Find something fun to do - suggestions:
Exercise your brain with www.gamesforthebrain.com
Competitive Typing http://play.typeracer.com/
Try an amazing drawing tool (e.g. Flame Painter):don't just sit around watching videos.
This is an interested web-site with a programming language that makes 3D
effects:
https://www.shadertoy.com/view/MsGSRd
You can try to change some numbers, then press the "go" arrow at the
bottom
to see your changes in the display window.
Then try to find some other interesting programs (in Browse) and try changing them.
Click on this Amazon Link about Embedded Games.
Notice that the original AmazonWS link won't work,
because it is a SECURE httpS link.
You need to remove the 'S' to make it work properly.
You COULD try embedding this code into a web-page
and see what happens:
<div align="center"><embed src="http://www.classicgamesarcade.com/games/tron.swf" width="641px" height="554px" autostart="true" loop="false" controller="true"></embed><br /><a href="http://www.classicgamesarcade.com/game/21670/tron-game.html">Tron Game</a></div> |
Here is a Bungee page with EMBEDDED videos:
https://s3.amazonaws.com/files.haikulearning.com/data/frankfurt_international_school/minisite_78536426/b536617be5bf/Bungee/index.html
"Embedded" means that we see the video in the page, rather than a link,
and the video runs inside the page when we click on [Play].
Embedding YouTube videos is quite easy.
- find a YouTube video that you like
- below the video, click on [Share] and then [Embed]
- copy the HTML code
- in BlueGriffon, click on the [Insert] menu and choose [HTML
Markup]
- insert your copied code into the small box and click [OK]
Now BlueGriffon is NOT a browser, so it cannot actually display the video
page.
Instead, it will display an error message. But when you save your
page
and open it in a browser, the video will appear and will work properly.
In the example page, the text is lined up nicely to the left of the
video.
That is because the text and videos are all in a TABLE.
You don't see the Table because the Table/Properties/Border is set to 0
(zero).
Now make your own page:
- choose a topic that appears in Wikipedia
- create a web-page in BlueGriffon
- type a HEADING on your page with the name of your topic
- insert a table below the Heading, maybe 3 rows and 2 column
- copy paragraphs from Wikipedia and insert them into the table left
column
- find corresponding videos (preferably short, under 5 minutes)
- embed the Video code into the cells in the right column\
- save the page as "index.html"
- compress the folder and upload it into a Mini-Site in Haiku
Work QUICKLY. Finish 2 pages like this by Tuesday 31 May.
Then turn in the .amazonws URL addresses in Haiku.
Wikipedia is very useful, but not particularly attractive.
Here is an improved version of a Wikipedia page:
https://s3.amazonaws.com/files.haikulearning.com/data/frankfurt_international_school/minisite_78421840/b97bc183f470/Bungee/index.html
You are allowed to do this because ALL of Wikipedia content
is licensed under the Creative Commons License.
Not all web content is so flexible, but Wikipedia is.
You might be interested in some more reading:
- On Walden
Pond ("The tragedy of the commons") by David Thoreau
- Is
Copying Legal?
Use Blue Griffon to make a similar improved Wikipedia page:
- choose a topic
- find the Wikipedia article
- copy a small portion of text out of Wikipedia, into your page
- add a link to a video OR a nice image
- add another small bit of text plus a corresponding video
- put the copyright information at the bottom of the page, as well
as your name
- add any other visual improvements that you can think of, e.g.
colors
- save the page and name it "index.html"
- compress the folder and upload it to a Mini-site in Haiku
Try to figure out how to do this QUICKLY.
The teacher will show how to upload content into a Mini-Site in Haiku.
== Practice Today ==This is a first try. We will make a more complicated page tomorrow.
This is our last class-period to work on the web-site.
Here are useful things that you could work on TODAY:
(1) make a nice LOGO for ALL the pages (for the entire web-site)
(2) make sure YOUR NAME appears on EVERY PAGE that you created
(3) clean up all the links that either don't work or that have
meaningless text
(4) clean up text that is too small
(5) clean up pages where the content is too wide for a normal
browser
(6) refactor any pages that are still a mixture of HTML and
JavaScript
to make Pure Javascript pages that are easier
to change
(7) add some nice colors to your pages to make them prettier
(8) anything else to make the pages:
clearer, easier to understand, easier to use,
more attractive
(9) HELP OTHER STUDENTS and/or ask them to help you
You can continue working at home if you wish next week,
but the web-site must be FINISHED and FUNCTIONING
with YOUR NAME ON ALL YOUR PAGES, due on 27 May 18:00.
(1) TEST - 30 minute limit
(2) Once you have finished your test,
please try to make a LOGO for out web-site.
Try this web-site: http://www.logogarden.com/
There are lots of other web-sites that claim
to make logos for free. But be careful -
they might try to trick you into spending money.
==Today's Practice ==
(1) Search the web for "bad web-sites" that violate the tips above.
You can try searching Google for "bad
web-sites".
(2) Search for VIOLATIONS of the Web-site tips in our class web-site.
(3) Review the notes below to prepare for tomorrow's test.
== Tomorrow's Test ==
It will be a WRITTEN test - no computers, no notes.
It will take about 30 minutes to complete.
Here is code for a "PURE JS" web-page.
That means it virtually no HTML code.
HTML objects, like Buttons, are created by document.write(..) commands.
By using VARIABLES to determine the text that appears on the page,
it is very simple to change the text to do a different problem.
You can try this out today.
1 - copy the code below into a new web-page in Komodo
2 - check that the page works correctly
3 - use this as a TEMPLATE to quickly create 2 new problem web-pages (save them)
4 - Using one of your existing problem-pages from our big web-site,
change that page to be a JavaScript driven
template,
replacing all HTML code lines with
document.write(..) commands
at the beginning of the Javascript section, and
replacing
changeable text with variables.
5 - Use your own template (from #4) to create 2 more problem pages
<!DOCTYPE html> <html> <body> <script> question = "Where is FIS?" ans1 = "Oberursel" ans2 = "Germany" ans3 = "Frankfurt" ans4 = "Korea" document.write("<h2>" + question + "</h2>") document.write("<h3 id=message>Two answers are correct</h3>") document.write("<button id=r1>" + ans1 + "</button>") document.write("<button id=r2>" + ans2 + "</button>") document.write("<button id=w1>" + ans3 + "</button>") document.write("<button id=w2>" + ans4 + "</button>") r1.onclick = function() { r1.style.visibility = "hidden" checkDone() } r2.onclick = function() { r2.style.visibility = "hidden" checkDone() } w1.onclick = function() { r1.style.visibility = "visible" r2.style.visibility = "visible" } w2.onclick = function() { r1.style.visibility = "visible" r2.style.visibility = "visible" } checkDone = function() { if ( r1.style.visibility == "hidden" && r2.style.visibility == "hidden" ) { message.innerHTML = "SUCCESS!" r2.style.visibility = "hidden" r1.style.visibility = "hidden" w1.style.visibility = "hidden" w2.style.visibility = "hidden" } } move = function(b) { x = Math.random()*300 + 100 y = Math.random()*300 + 100 b.style.position = "absolute" b.style.left = x + "px" b.style.top = y + "px" } move(r1) move(r2) move(w1) move(w2) </script> </body> </html> |
How can we AUTOMATE the construction of our web-site?
- templates
- CMS
- ???
Today's Notes :
Cognitive Fluency - more white space - CONSISTENT color, layout (organization) - layout is things like for example: one question per page some put 5 questions Maybe this should be consistent ====================================== When is the project due? - it WAS due on Monday 9 May - did we FAIL? - not sufficiently organized (search function) - not enough questions ====================================== Real Software Projects - should be a BETA test .. 50% development (writing) + 50% Testing .. 90% TESTING, 10% writing ====================================== In reality Individual Question Web-pages - 3 May - 25% projects delivered + successful - 50% delivered but unsuccessful (either fix it or give up) - wrong hardware - wrong design - defective - features are MISSING - not EXANDABLE = SCALABLE - feedback system - SUPPORT - no OFFLINE access - 25% never delivered ===================================== If you are in the 50% category (near the top), - REFACTOR it = rewrite the pages without changing them to make the CODE more understandable this makes MAINTENANCE and SCALBILITY easier - FIXING BUGS = unreported error Error = reasonably unexpected malfunction - ADD AUTOMATION |
Now we have a web-site with lots of working question pages.
http://fisgraphicsproject.pancakeapps.com/
Unfortunately the various page work in a variety of different ways.
So the users have an unpredictable USER EXPERIENCE (UX).
Here is a good article about why SIMPLE is BETTER:
http://conversionxl.com/why-simple-websites-are-scientifically-better/
It is up to each individual author to organize his problem pages
so that they work SIMPLY - that means no extra clicks are required.
We made some suggestions for improvements at:
SIMPLE is good. Most users agree that simple is also PRETTY.
People like pretty things. More important, "pretty" is similar to
UNDERSTANDABLE.
So we want to make our web-site easy to understand.
The index pages that we have so fare are quite simple, and hence
understandable,
except that in many cases the links have mysterious labels, like "prob1".
We need to AGREE on a STANDARD format and strategy for these pages.
We will discuss this and agree on some STANDARDIZATION
that will make the entire web-site simpler, understandable and hence
EASIER TO USE - that means improving the USER EXPERIENCE (UX).
Class Notes: Mistakes - it's ok, just fix it - or maybe give up - but at least try --> ERRORS in computer systems - CasE sENsiTIVE (no = cause) - REASONABLY unexpected malfunction BUG - unknown or unreported error WARNING (not an error message) - comes BEFORE the error happens |
We need to finish our integration test.
If you have not finished a working page
and uploaded it to Dropbox, you need to do it today.
If you are not succeeding you MUST ask for help
and get something finished.
Once you have finished your first web-page,
and uploaded it, you should continue with the next task,
which is to make more questions about your subject.
OR - make a nicer Index page for your subject.
But you do need to have several pages next week.
Next Deadline : Tues 3 May - working index page
with at least 5 questions
We need to collect all the single web pages together
and copy them onto the Web Server. Then we need
an INDEX page that links to all the single pages,
and then we perform an INTEGRATION TEST
to confirm that all these pieces work together.
Everyone must finish ONE web-page the presents a problem
for your topic. This can be simple or complex, as you wish.
You will be making lots more pages next week. But we NEED
a collection of pages so that we can do the initial ASSEMBLY
of the system on Monday, and then upload this to our
Web Server. Whoever is working on the Web Server(s)
can just do that and get it working by Monday, but everyone else
must bring a working Web Page on Monday.
In case you "don't know what to do", try one of these:
- make something similar to one of the pages in a
sample Math Practice Page.
- make multiple-choice question with 4 pictures
where the user must click the correct picture
- present a paragraph of text, the user needs to read the text,
and then answer a question about the content
Our goal over next few weeks is to make educational practice pages,
that are both challenging and interesting - hopefully animated and
interactive.
These will be a large collection of small, individual web-pages.
For this to work sensibly, we must be able to store ALL the pages
in one place, and make them available to lots of students to use.
Hence, the eventual goal is to store them on a Web Server.
We must discuss HOW TO STORE these pages.
Do your quiz - time limit is 30 min (you probably need less time).
== After Finishing the Quiz ==
Here
is a sample Math Practice Page.
We are going to make web-pages like the sample above.
These will be aimed at REVIEW WORK for high school students.
ALL the pages, made be individual students, will be stored
together on a Web Server. We must organize the files and
file-names so that the pages can all work together, without
confusion or conflicts.
You
might be tempted to use Google Drive (docs) to store these pages.
Unfortunately, Google Drive is not actually a Web Server,
so you cannot store web-pages there if they contain JavaScript -
well, you can store them, but they won't function.
DropBox
DOES work as a Web Server. It is also relatively
simple to upload files and to share them.
Weebly.com
(where the class web-site is located) is a Web Server
and you can make a free account there. However, uploading
and sharing files there is not so simple.
Another
possibility is to ask the IT Support Staff (tech deck)
whether they have a Web Server that you can use.
If
anyone has a better idea, we can discuss it (on Tuesday).
Your
goal is to do the following before class on Tuesday:
- make a DropBox account (or an account on some other Web
Server)
- modify the Sample Math Page (above) so that it
contains one problem
that you created - whether that is a graphical question
or a text
question doesn't matter
- upload your FILES into your Web Server account
and check that the Math Practice Page works correctly
as a Web Page
- be prepared to REPORT about your experience on Tuesday,
explaining to the class what worked correctly or what
did not work
If you wish to use DropBox for this work, you will need to store your
files
in a PUBLIC folder. This used to be quite easy, but is now tricky.
You may need to read the HELP
files on DropBox.
We will discuss these
notes about file-names and character codes.
Why double slash // in http://www.google.com ?
- http://www.theinquirer.net/inquirer/news/1558680/berners-lee-regrets-double-slash
- http://stackoverflow.com/questions/4659345/is-there-any-downside-for-using-a-leading-double-slash-to-inherit-the-protocol-i
Here
is a sample Math Practice Page with
several different problems displayed in an iFrame.
Here is an example Menu with educational links.
About half of the menu pages turned in to Haiku did not work.
This is mostly related to LINKS and FILE LOCATIONS.
We will spend a week learning more about file locations
and how to make links work correctly.
We will have a QUIZ on Friday 15 Apr,
where you can demonstrate that you can
locate and link to files correctly.
Next week we will do some more work on Math Game pages,
using the ideas learned this week.
You can download this .zip archive containing several .html files.
You can try the game directly here.
You should do the following:
- copy the index.html file into YOUR folder containing several
problem.html files
- make a button for each of your games
- add javascript functions to make your buttons load your games
- add several games and several buttons, as time permits
Download this game : https://dl.dropboxusercontent.com/u/275979/graphics/javascript/Dynamic/simpleGame2.zip
You can play it here directly if you wish.
This is a MATH "game". You need to answer the math question
by moving the player around to collect digits
in the correct order - the right answer is 42, not 24.
== Practice ==
(1) Rename the program to problem1.html.
(2) Change the problem to something different,
where the correct answer is 24. Then change
the program so that if rewards the correct answer
of 24.
Save this as problem2.html. Save in the
SAME FOLDER with problem1.html.
(3) Make another problem with answer 60, like "How many minutes in an
hour?"
The images for 6 and 0 are already in the images
folder.
Save this as problem3.html .
(4) Find a picture containing all digits 0,1,2,3,4,5,6,7,8,9
Use html://ipiccy.com
or some similar tool to chop this up
and save an image for each digit (in the images
folder).
(5) Make another problem using odd digits.
Save this as problem4.html .
(6) Make a new problem: "How many sides does a pentagon have?"
The correct answer is 5. Put 5 and
three other digits on the screen
in random positions. Now the player
wins if they touch 5,
but touching anything else causes a
RESET().
Save this as problem5.html .
(7) Add one more problem that includes a PICTURE that illustrates
the problem. Save this as
problem6.html.
Tomorrow we will make BIGGER problems, with longer answers.
Some suggestions for improving the game:
- make the "board" bigger - that needs a bigger BACKGROUND picture and a
bigger CANVAS (CTX)
- add more "sprites"
- make some sprites that are obstacles (like walls)
- they are bigger
- they never move
- the player resets to the center if
he/ahw touches them
- make some sprites that jump around randomly, but in a
smaller area
that means the random numbers are chosen
differently
- make an invisible sprite (?)
if the player touches it, he/she gets lots
of points
Investigate various
downloadable (free) Javascript library systems
that create pop-up menues. Choose one that you like, and that
looks relatively easy to use, and implement the same links
that you did on yesterday's page - e.g. 3 sports links, 3 news links,
and 3 music links - in a new web-page. You will need to read the
instructions to understand how to use the library. If you can't
manage to get it working, get help from the teacher.
You can try the following sites:
- Dynamic
Drive
- Javascript
Kit
- HongKiat
- Wikipedia
List of Javascript Library Sites
- Book as PDF (use the
Download version)
apic.onmouseover = function() { apic.src = "button2.jpg" } apic.onmouseout = function() { apic.src = "button1.jpg" } apic.onclick = function() { location = "http://www.youtube.com" } |
Rube
Goldberg Machine Project
Your
assignment is to make a page similar to this one:
https://dl.dropboxusercontent.com/u/275979/graphics/javascript/RubeHack/RubeHack.html
Below
are a list of Rube Goldberg Machine ideas that turned
into projects that won a yearly contest. You may select
one of these ideas, or make up your own, as you wish.
Your
assignment is to make a WEB-PAGE with a Rube Goldberg Machine.
There should be a [Start] button that starts a sequence of actions.
Each action will involve some object moving and touching another object -
then that will start the second object moving.
The
best way to approach this is to start with one of the ideas below.
Make a web-page where that one single action happens.
THEN add the action that comes BEFORE that action, and triggers it to
start.
Then add another action before that, etc.
Keep
It Reasonably Simple - BUT INTERESTING!
You
are not expected to create something as complex as the little
boy in the video. You should have 5-9 actions total.
If some of the actions are complex, like involving an animation
as well as movement, then you can make fewer than 9.
Totally realistic actions are quite difficult. For example, a hammer
hitting
a nail should actually have the hammer rotating. But you can keep it
simple
by having the hammer just move down and up.
How Much is Enough
Let's
say that the finished page should contain 5-9 actions.
And don't make them last too long - about 10 seconds maximum
for each action.
Here are the suggested topics - but feel free to do something else:
2013 Hammer A Nail 2012 Inflate A Balloon and Pop It! 2011 Watering A Plant 2010 Dispense an Appropriate Amount of Hand Sanitizer into a Hand 2009 Replace an Incandescent Light Bulb with a More Energy Efficient Light Emitting Design 2008 Assemble a Hamburger 2007 Squeeze the Juice from an Orange 2006 Shred 5 Sheets of Paper 2005 Change Batteries and Turn on a 2-battery Flashlight 2004 Select, Mark and Cast an Election Ballot 2003 Select, Crush and Recycle and Empty Soft Drink Can 2002 Select, Raise and Wave a U.S. Flag 2001 Select, Clean and Peel an Apple 2000 Fill and Seal a Time Capsule with 20th Century Inventions 1999 Set a Golf Tee and Tee Up a Golf Ball 1998 Shut Off An Alarm Clock 1997 Insert and Then Play a CD Disc 1996 Put Coins in a Bank 1995 Turn on a Radio 1994 Make Cup of Coffee 1993 Screw a Light Bulb into a Socket 1992 Unlock a Combination Padlock 1991 Toast a Slice of Bread 1990 Put the Lid on a Ball Jar 1989 Sharpen a Pencil 1988 Adhere a Stamp to a Letter 1987 Put Toothpaste on a Toothbrush |
One Programming Trick
Notice
that you will have a long sequence of setTimeout commands.
This is quite difficult if you try to do it in one long sequence of
commands.
The teacher will show you a better, more "scalable" approach on Thursday.
For today, just start making the final action.
== Due Date : Thu 11 Feb at 18:00 ==
Turn
in your finished Rube Goldberg Page on Thursday 11 Feb.
QUIZ You may use your computer and any web-sites or notes or old practice projects that are useful. Download flyer.zip and follow the instructions. Once it is working, show it to the teacher to receive a grade. |
We will have a QUIZ tomorrow.
During class you will need to fix/improve a web-page containing Javascript. |
Read these notes for more information.
**
Note that the sample programs will only work
** if you have the web-page,
the images (ex.gif , oh.gif)
** and the PJ.js library
ALL STORED TOGETHER IN ONE FOLDER.
Download
ALL these files in this .zip archive.
Practice : Do #8,9,10 in the NOTES above
Read these notes for more information.
**
Note that the sample programs will only work
** if you have the web-page,
the images (ex.gif , oh.gif)
** and the PJ.js library
ALL STORED TOGETHER IN ONE FOLDER.
Download
ALL these files in this .zip archive.
Practice : Do #1,2,3,4,5,6,7 in the NOTES above
We
are going to make an interactive multiple-choice quiz.
Read
these instructions and
look at the
sample quiz.
You
need to download
this ZIP archive
that contains the Sample Quiz files and all the images.
Tomorrow we will start looking at a variety of LIBRARIES,
especially with GRAPHICS functions.
Using these will be easier with a standard
editor (not EzJS).
So, before class tomorrow, you should download
and install KOMODO from http://komodoide.com/download/
(choose Komodo Edit, not IDE)
(or borrow a USB stick from the teacher - that's a bit faster)
Today
Continue working on the robot program that you started yesterday.
Using make("div...") com- mands,
make some other figures, like:
- a dog/horse/animal
- a car (with square wheels)
- a tree with a rectangle for the trunk and several rectangles for
branches/leaves
- etc
Add more make("select.....") commands
to make more lists
that control colors of various pieces of your picture.
Practice so that you get better
and faster at writing JavaScript.
You will have a quiz next Wednesday, where you will need to
write a JavaScript program during the half hour quiz during class.
Copy the program below, paste into EzJS
Simplified Online Editor,
and follow the instructions in the PRACTICE section.
You might find this list of color names useful:
http://www.w3schools.com/tags/ref_colornames.asp
/////////////////////////////////////////////////////////////////////////// // This program makes a robot head. // It contains a SELECT list with color. // Choosing an item in the list changes // the color of the eyes. // // Notice that the program uses an extra BOUND function // for setting LEFT,TOP,WIDTH,HEIGHT. This makes it // easier to create new DIVs, because there is less // typing required - the BOUNDS function automatically // adds "px" to each number and assigns it to the // correct PROPERTY. This use of a FUNCTION is typical // of PROCEDURAL languages. It is not a typical // Object-Oriented-Programming technique, and // hence requires slightly different syntax: // using bounds(leftEye,110,70,30,30) // instead of leftEye.bounds(110,70,30,30) // // Also notice the SYNTAX of the make("select..) command. // The words for the list are entered like this: // Eyes|red|green|blue|orange // This is not standard Javascript or HTML, // but a convenience supplied by the IBIO.js library used in EzJS. ////////////////////////////////////////////////////////////////////////// make("select;left:100px;top:0px;id=eyes;Eyes|red|green|blue|orange"); eyes.onchange = function() { var c = eyes.value leftEye.style.background = c rightEye.style.background = c } make("div;id=head;left:100px;top:50px;width:100px;height:100px;background:pink") bounds = function(obj,l,t,w,h) { obj.style.position = "absolute" obj.style.left = l + "px" obj.style.top = t + "px" obj.style.width = w + "px" obj.style.height = h + "px" } make("div;id=leftEye;background:lime") bounds(leftEye,110,70,30,30) make("div;id=rightEye;background:lime") bounds(rightEye,160,70,30,30) make("div;id=mouth;background:purple") bounds(mouth,130,120,40,20) /************************************************************* * === PRACTICE === * * 1 - Add another SELECT list, with colors, that changes * the color of the MOUTH when clicked. * * 2 - Add more DIV objects to make the following: * - a body * - 2 arms * - 2 legs * Then add a COLOR list for each item, e.g.: * body color, arms color, legs color * * 3 - Make a BUTTON that can make one eye "wink", * by making it smaller (use bounds). * * 4 - Add a HIDE function - it looks like this: * * hide = function(obj) * { * obj.style.visibility = "hidden" * } * * Make a button that can hide the legs, by executing: * * hide(leftLeg); * hide(rightLeg); * * 5 - Make a corresponding SHOW function, using: * * obj.style.visbility = "visible" * * and add a BUTTON that makes the legs visible again. * ************************************************************/ |
which link to pictures, web-sites and videos:
make("button;id=clown;innerHTML=Happy
Clown") make("button;id=frogs;innerHTML=Ugly Frogs") make("button;id=crash;innerHTML=Chair Crash;left:40px;top:60px") make("button;id=big;innerHTML=Big Video;left:200px;top:10px;width:200px;height:100px;") clown.onclick = function() { open("http://www.shoutwiki.com/w/images/en.barneybunch/5/55/Ronald.jpg") } frogs.onclick = function() { open("http://www.free-extras.com/tags/1/ugly+frog.htm") } crash.onclick = function() { open("https://www.youtube.com/watch?v=BQJtV_YLuNE") } big.onclick = function() { open("https://www.youtube.com/embed/BIWeEFV59d4?start=25") } |
There
is not too much mysterious about these commands,
but the teacher will present a brief explanation.
== Practice ==
Now add the following code that clicks-through 3 pictures:
== More practice ==
3.
Check that your code works properly and clicks through
3 evil clown pictures when you click on the
image.
4.
Add another picture to the "stack". You will need to make
several changes in the code to make 4 pictures
work.
//==== AnimalDivs
============================================================ make("img;id=animals;left:100px;top:60px;width:500px;height:500px;") animals.src = "https://dl.dropboxusercontent.com/u/275979/graphics/EzJS/Animals.jpg" make("div;id=box;left:0px;top:0px;width:100px;height:100px;border:solid 2px orange") make("button;id=lion;left:100px;top:20px;innerHTML=Lion") make("button;id=giraffe;left:140px;top:20px;innerHTML=Giraffe") make("div;id=elephantDiv;left:100px;top:380px;width:190px;height:170px") make("div;id=butterflyDiv;left:520px;top:60px;width:80px;height:60px") lion.onclick = function() { box.style.left = "400px" box.style.top = "60px" } giraffe.onclick = function() { box.style.left = "400px" box.style.top = "270px" box.style.width = "180px" } elephantDiv.onclick = function() { this.innerHTML = "<H1>ELEPHANT</H1>" this.style.backgroundColor = "rgba(255, 0, 0, 0.2)" } butterflyDiv.onclick = function() { this.innerHTML = "Butterfly" this.style.backgroundColor = "rgba(0, 255, 0, 0.2)" } |
The Animals page uses BUTTONS and DIVS to identify specific animals. (1)
Add another BUTTON for another animal - (2) Add another colored-div that appears on top of another animal. (3)
Change the buttons so that the orange box always (4)
Add an IF command like the following: (5) Make the Butterfly DIV turn on and off when you click. (6)
Now add more buttons and boxes. |
We will be using Javascript to create Web-Pages. We will start by using a simplified JS editor, |
Here is a simple program with buttons and images
that link to other web-pages:
//-------------------------------- // PRACTICE Exercises // (1) Change each of the BUTTONS to show different web-pages. // (2) Change each of the IMAGES to show different web-pages // including one YouTube video for the [Friday] image. // (3) Add one new BUTTON below the [Radio] Button. // This requires LEFT and TOP settings to place it correctly. // (4) Add one new IMAGE to the right of [Friday]. // Be sure to use LEFT, TOP, WIDTH and HEIGHT values. // (5) Add more buttons and more images, as time permits. // (6) Move the <iframe> to the middle of the screen // (7) Add buttons and images around the outside of the <iframe> //-------------------------------- make("iframe;id=showPage;left:10px;top:100px;width:640px;height:480px") showPage.src = "https://www.bing.com" make("button;id=radio;innerHTML=Radio") make("button;id=spiegel;innerHTML=der Spiegel") make("button;id=bing;innerHTML=Bing Search") radio.onclick = function() { showPage.src = "https://www.internet-radio.com/" } spiegel.onclick = function() { showPage.src = "https://www.spiegel.de" } bing.onclick = function() { showPage.src = "https://www.bing.com" } //------------------------------------------------------------- make("img;id=world;left:250px;top:10px;width:64px;height:64px") world.src="http://icons.iconarchive.com/icons/BogdanGC/layered-system/128/globe-icon.png" make("img;id=friday;left:350px;top:10px;width:64px;height:64px") friday.src="http://allsteelefitness.com/wp-content/uploads/2014/03/friday18.jpg" world.onclick = function() { showPage.src = "https://cdn.shopify.com/s/files/1/0188/1978/products/world_map_940x627px_dark_bl_large.jpg?v=1377278248" } friday.onclick = function() { showPage.src = "https://www.youtube.com/embed/kfVsfOSbJY0" } |
Copy the code into EzJS. Then make the changes indicated in the PRACTICE shown at the top of the program. |
You
might wish to save copies of your picture(s) in graphics files.
You can save a copy of your picture to a graphics file
on the disk (in the sketch folder) like this:
int picnum = 0; void keyPressed() { if(key == 's') { picnum = picnum + 1; save("gradfill"+picnum+".jpg"); } } |
PImage img,img2; void setup() { size(600, 450); img = loadImage("http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/mountain-goat_635_600x450.jpg"); img2 = createImage(img.width, img.height, RGB); } void draw() { for (int y = 0; y < img.height; y++) { for (int x = 0; x < img.width; x++) { int p = y*img.width + x; // pixel position color c = img.pixels[p]; float r = red(c); float g = green(c); float b = blue(c); b = b * (y/200.0) ; r = r * ((400-y)/100.0); if(mouseY < 2*g) // use mouse position to change colors { g = g - mouseY/2; } img2.pixels[p] = color(r,g,b); } } img2.updatePixels(); image(img2, 0 , 0); } void mouseClicked() { save("gradfill.jpg"); // saves entire picture into a file on disk } |
make the changes described at the bottom.
PImage img,img2; void setup() { size(600, 450); img = loadImage("http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/mountain-goat_635_600x450.jpg"); img2 = createImage(img.width, img.height, RGB); noLoop(); } void draw() { for (int y = 0; y < img.height; y++) { for (int x = 0; x < img.width; x++) { int p = y*img.width + x; // pixel position color c = img.pixels[p]; float r = red(c); float g = green(c); float b = blue(c); //====== Here are the effects ====== if(x < 200) { r = 255; } else if(x >= 200 && x < 400) { r = r/2; // this removes half of the red b = b/2; // and half of the blue // the result looks green } else { b = b*3; } //====== end of EFFECTS section ======= img2.pixels[p] = color(r,g,b); } } img2.updatePixels(); image(img2, 0 , 0); save("stripes.jpg"); } /********************************************** (1) Try applying different effects to the 3 sections. (2) Change the IF.. commands to make 6 stripes instead of just 3 stripes. (3) Change the IF.. commands so the stripes are horizontal instead of vertical. That means you check the Y value instead of checking the X value. You need to use different numbers for Y, because the picture is not as large up and down as it is across. (4) Try writing "x+y" instead of "y". This will make diagonal stripes. (5) Try writing "2*x-y" instead of "y" (or whatever you have.) (6) Try various COEFFICIENTS, like 2.5*x - 1.2*y **********************************************/ |
Make the changes and improvements described by the teacher.
== PRACTICE ==
(1)
Try changing the calculations in the CHANGE method
to produce some other interesting effects.
(2)
Add a couple more words at the bottom of the screen,
and make the picture change when you roll-over
these new words - use different, interesting
effects.
Here is a simple example program:
PImage img; void setup() { size(1200, 500); img = loadImage("http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/mountain-goat_635_600x450.jpg"); // Load the original image noLoop(); } void draw() { image(img, 0, 0); // Displays the image from point (0,0) img.loadPixels(); PImage newImg = createImage(img.width, img.height, RGB); for (int y = 0; y < img.height; y++) { for (int x = 0; x < img.width; x++) { color p = img.pixels[y*img.width+x]; float r = red(p); float g = green(p); float b = blue(p); b = b*4 ; newImg.pixels[y*img.width + x] = color(r,g,b); } } newImg.updatePixels(); // puts pixels array back into the image image(newImg, width/2, 0); // Draw the new image } |
Pic-Click-Project (due 25 Sep at 18:00)
Read these notes and do what is suggested at the end.
The following program displays names for various objects in a big picture:
PImage pic; // this must include one variable for each picture
void setup() { size(900, 600);
pic = loadImage("http://www.albinoblacksheep.com/flash/960/waldo.jpg");
textFont(createFont("Georgia",32)); }
void draw() { background(250,180,250);
image(pic,0,0);
if(mouseX > 400 && mouseX < 440 && mouseY > 250 && mouseY < 300) { fill(0,0,0); text("Waldow",100,580); } if(mouseX > 500 && mouseX < 570 && mouseY > 0 && mouseY < 60) { fill(0,128,0); text("Big Bear",100,580); } } |
Copy this program into Processing.
Then add more names of other items in the picture.
Add as many names as you can in one class period.
Processing can load and display images (pictures), like these 3 images:
Here is the program that draws the picture above:
PImage img1 , img2, img3; // this must include one variable for each picture
void setup() { size(600, 400); img1 = loadImage("http://sunnysideprimaryacademy.org/wp-content/uploads/2013/05/clown.png"); img2 = loadImage("http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2012/6/4/1338797575737/Staffordshire-bull-terrie-008.jpg"); img3 = loadImage("http://images1.wikia.nocookie.net/__cb20090329034449/simpsons/images/e/e5/Krusty_The_Clown.png"); }
void draw() { background(250,180,250); // background color = pink
image(img1, 0, 0,300,300); // draws the image on the screen image(img2, 320,200,300,200); // image(variable,x,y,width,height) image(img3, 250,140,150,200); } |
You might notice that image #3 is on top of images #1 and #2.
Since image #3 has a transparent background, we see through
the background to see the other images.
Notice that each image requires a variable that is listed in the first line of the program.
Then each image must be loaded in the setup method.
Finally the images are displayed by the "image" command in the the draw method.
The image command is very similar to a rectangle command, but it starts
with an image variable.
Do the following practice tasks:
Start with the following program. Then do what is described on the quiz.
void setup() { size(600,600); robot(250,250); robot(150,250); robot(350,250); }
void robot(int x, int y) { fill( 0,0,255 ); rect( 0+x , 0+y , 100,100); fill( 255,0,0 ); rect( 20+x, 70+y, 60 , 10); fill( 255,255,255); rect( 20+x, 20+y, 20, 20); rect( 60+x, 20+y, 20, 20); } |
One more day working with parameters.
** Remember - QUIZ on Monday 14 Sep
** Read description in Haiku.
Continue with these notes.
Read these notes and do the practice exercises.
The teacher will demonstrate how to write methods
in a Processing program.
We will be drawing CIRCLES and ARCS.
Read these notes.
Finish the Olympic Rings today and
start working on the RUNNER.
Make the Olympic rings.
Then add as many sports icons as you can.
Continue with these notes
The teacher will explain how to draw triangles and lines.
If you have not installed Processing from http://processing.org
then borrow a USB stick from the teacher and install it today.
Today's Assignment
- read these notes and do the sample programs up to and including
#1 - German flag
#2 - Austrian flag
#3 - Belgian flag
The programs in these notes will run in Processing
from http://processing.org after downloading and installing the program.
Alternatively, you can run the code directly in the following web-page
without installing anything : http://sketchpad.cc .
- HOMEWORK - install Processing on your computer before our next class
https://processing.org/download/?processing
- read the notes below as time permits (over the next few days)
~~~~~~~~~~~~
Welcome to Graphics ProgrammingDaily Work - Computers Required - Bring Your Computer Every Day
Each student needs a computer for class every day
|
|
Course Description
In Graphics Programming we will be writing programs
to create graphical displays. We will use several different programming
languages, including Java and JavaScript. .. more ..