|
aohavkbs, http://www.tomshw.it/forum/members/buy-glucophage.html glucophage conveniente, tndgogaw, http://www.tomshw.it/forum/members/comprar-zyprexa.html zyprexa conveniente, vtyyhpgn, http://www.tomshw.it/forum/members/comprar-desyrel.html desyrel conveniente, fxjgwxxe, http://www.tomshw.it/forum/members/comprar-cytotec.html cytotec prezzo ridotto, sazxpbxj, |
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> |