|
http://chance.ch/viewtopic.php?m=68&tp=56969&l=742 New Whales Plant http://christophsprenger.com/viewtopic.php?m=32&tp=42040&l=203 Cure Skin Rashes http://cvp-fr.ch/viewtopic.php?m=67&tp=45235&l=297 Basket Demoulas Market Nh http://chance.ch/viewtopic.php?m=25&tp=64994&l=165 Oktober Light http://chance.ch/viewtopic.php?m=7&tp=63763&l=290 Ocfcu Maine http://chasa-capol.ch/viewtopic.php?m=42&tp=56965&l=148 Madeeha Khalid http://cvp-fr.ch/viewtopic.php?m=27&tp=39828&l=331 Australian Education Union Tasmanian Branch http://capunz.ch/viewtopic.php?m=79&tp=88327&l=262 Why Are Canadians Called Canucks http://chasa-capol.ch/viewtopic.php?m=52&tp=55561&l=437 Lynchburg Virginia Commonwealth Attorney's Office http://careerprocess.info/viewtopic.php?m=3&tp=83723&l=579 Rudd Fishing http://chasa-capol.ch/viewtopic.php?m=21&tp=55014&l=632 Luis Sabino http://capunz.ch/viewtopic.php?m=5&tp=85617&l=139 What Is The Meaning Of Worksheet http://chance.ch/viewtopic.php?m=40&tp=55827&l=529 Networking With Playstation 2 http://clown.ch/viewtopic.php?m=57&tp=24491&l=643 9-11 Outline http://capunz.ch/viewtopic.php?m=58&tp=89121&l=596 Wild Boar Pig Targets http://chasa-capol.ch/viewtopic.php?m=55&tp=50204&l=453 Lippold Park http://careerprocess.info/viewtopic.php?m=3&tp=81841&l=354 Rolm 61000 Phone Manual http://cvp-fr.ch/viewtopic.php?m=5&tp=43298&l=244 Ballerz Empire http://careerprocess.info/viewtopic.php?m=55&tp=77455&l=304 Restructuring Advisors http://cvp-arbon.ch/viewtopic.php?m=51&tp=33956&l=288 Anti-freeze 55 Gallon Miami |
Labs /
Lab5Monday, February 20 Lab concepts:
Lab corresponds to: 5a-googleRequest.html Run in web browser <html> <head> <title>What do you want to search for</title> </head> <body> <form action="4e-googleSoap.php" method="get"> What do you want to search for.<br> <input type="text" name="searchTerm"> <input type="submit" value="Submit the search"> </form> </body> </html> 5b-image.php Run in web browser <?php // ----- PHP SHOULD TELL THE BROWSER IT'S GETTING A PNG IMAGE, NOT HTML AS IS THE DEFAULT header("Content-type: image/png"); // ----- GET REQUEST PARAMETERS if (isset($_REQUEST["text"])) $text = $_REQUEST["text"]; else $text = "Networks & Transactions"; // ----- CONSTANTS $canvasWidth = 300; $canvasHeight = 300; // ----- CREATE A NEW CANVAS $canvas = imagecreatetruecolor($canvasWidth, $canvasHeight); // ----- DEFINE A FEW COLORS $white = imagecolorallocate($canvas, 255, 255, 255); $blue = imagecolorallocate($canvas, 0, 255, 255); $red = imagecolorallocate($canvas, 255, 0, 0); $gray = imagecolorallocate($canvas, 127, 127, 127); // ----- FILL THE BACKGROUND // Define white as a transparent color imagecolortransparent($canvas, $white); // Fill the background with white starting from 0, 0 imagefill($canvas, 0, 0, $white); // ----- SPRINKLE 5000 BLUE PIXELS // Do 5000 times... for ($count = 1; $count <= 5000; $count++) { // Pick a random x and y coordinate $x = rand(0, $canvasWidth - 1); $y = rand(0, $canvasHeight - 1); // Draw the pixel imagesetpixel($canvas, $x, $y, $blue); } // ----- DRAW A RED CIRCLE IN THE TOP-LEFT QUARTER OF THE IMAGE $x = rand(0, $canvasWidth / 2); $y = rand(0, $canvasHeight / 2); $radius = rand(0, $canvasWidth / 2); imagefilledellipse($canvas, $x, $y, $radius, $radius, $red); // ----- DISPLAY ANTI-ALIASED TEXT USING A TRUETYPE FONT $x = rand(15, $canvasWidth / 2); $y = rand(50, $canvasHeight); imagettftext($canvas, 28, 0, $x, $y, $gray, "5d-whitney.ttf", $text); // ----- SUPERIMPOSE ANOTHER IMAGE THAT HAS A TRANSPARENT BACKGROUND // Load the icon $iconCanvas = imagecreatefrompng("5c-icon.png"); // Figure out its width and height $iconWidth = imagesx($iconCanvas); $iconHeight = imagesy($iconCanvas); // Decide where to put it on the main canvas $x = rand(0, $canvasWidth - $iconWidth); $y = rand(0, $canvasHeight - $iconHeight); // Copy the icon onto the main canvas... // ...with 100% opacity, but respecting the transparency of the icon imagecopymerge($canvas, $iconCanvas, $x, $y, 0, 0, $iconWidth, $iconHeight, 100); // Note: Unfortunately, this works best with images that have exactly one transparent // (knocked out) color, not varying levels of transparency or anti-aliased edges. // Still working on that... // ----- OUTPUT THE IMAGE TO THE BROWSER AS A PNG imagepng($canvas); ?> Asset: 5c-icon.png (control-click the image below to download) Asset: 5d-whitney.ttf (control-click the link below to download) 5e-imageTest.html Run in web browser <html> <head> <title>Image test</title> </head> <body> <img src="5b-image.php?text=Networks" align="absmiddle" width="150" height="150"> <font size="5">&</font> <img src="5b-image.php?text=Transactions" align="absmiddle" width="150" height="150"> </body> </html> |