Digital Media Comp
Monday, 17 September 2012
copy This
<html>
<head>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById("canvas");
cx = canvas.getContext("2d");
cx.fillStyle = "rgb(200,0,0)";
cx.fillRect (12, 12, 46, 46);
cx.strokeStyle = "rgb(0,200,0)"; cx.lineWidth = 5;
cx.strokeRect(10, 10, 50, 50);
}
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>
Monday, 13 August 2012
Setting up processing
Introduction to Processing
- Using Windows Explorer, navigate to
folder of \processing-1.5.1and check out the folder in explorer. - If you cannot get the public directory, then you can download (http:/processing.org )the ZIP file and unpack this onto your desktop.
- You will find the following:
lib- Contains the Jar files that make up processing.modes- Shows that processing can be based on pure java or android-flavourmodes/java/applet/- Contains applet stubs that are used when you create a processing appletmodes/java/application/- Contains MAC-style stubs for applicationsmodes/java/examples/- Example code that you can access from a menu (see belos)modes/java/libraries/- Extension libraries. You will notice these are all third-partymodes/java/reference/- Helpmodes/java/theme/- Processing.exe's Skin. Change theme.txt to change the GUI colors.
Finally 'processing.exe'. This program is known as a 'class=loader' program and is the equivalent of 'appletviewer'. Other class-loaders include eclipse and netbeans (of course they do a lot more besides, but this is one thing they do. Appletviewer provides aFrameobject, which is the equivalent of what a browser provides for applets. Processing provides a more complex object (Processing). Appletviewer does very little beyond the basic, and things like class-paths are set outside of it. Processing does all of this internally, and has reasonable defaults so that it more or less runs out-of-the-box. A lot of care has gone into this aspect, making it more straightorward to use by newbies. - * By the way, the file
processing-1.5.1-windows-expert.zipis all of it. You can copy and expand this onto your memory stick and just move it with you. You can also download it or Mac/Linux versions from processing.org's Download page.- * By the way, the file
- Now run the program 'processing.exe' - either from the network where you are now, from your memory stick (it would be faster from there - it is 75MB in size.
- Finally, browse to Getting Started and start playing. In the File menu, you will find 'examples'. Click it, and you are away. Try some of the programs. Look at the code. Try to figure out how it works.....
Some questions
Look up the documentation to find out some of the answers to these questions.- Go to the examples, and load Topics/Image Processing/Brightness.
- The
loadPixels()method is called twice. Why? How are the calls different? loadPixels()is called only withinsetup(). Why?- The code inside
draw()describes a Point operation on the image pixels. How can you tell? - What is the purpose of the variable
loc? - The image looks monochrome. Which color is being used? Change the code to use all colors
- The
- Now save this file as an Applet on your webpage. Check the permissions, and see if you can run the code as an Applet on your browser.
Subscribe to:
Comments (Atom)