Media software design
This presentation is the property of its rightful owner.
Sponsored Links
1 / 17

Media Software Design PowerPoint PPT Presentation


  • 53 Views
  • Uploaded on
  • Presentation posted in: General

Media Software Design. DIG 3134 Fall 2012 Lecture 15: Graphics J. Michael Moshell University of Central Florida. Original image* by Moshell et al. PHP Graphics. The Coordinate System (for our example). x 800 y 600. Excerpt from DA Text. PHP Graphics.

Download Presentation

Media Software Design

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Media software design

Media Software Design

DIG 3134

Fall 2012

Lecture 15: Graphics

J. Michael Moshell

University of Central Florida

Original image* by Moshell et al .


Media software design

PHP Graphics

The Coordinate System (for our example)

x 800

y

600

Excerpt from DA Text


Media software design

PHP Graphics

Motivation: the RSL Pickup Graph


Media software design

PHP Graphics

The Coordinate System (for our example)

x 0800

y 0 600

600 0 yup = 600-y (so y=600 – yup)

Excerpt from DA Text


Media software design

PHP Graphics: The GD Library

http://php.net/manual/en/ref.image.php

Basic example:

$Imagewidth=800;$Imageheight=600;

$image=imagecreate($Imagewidth, $Imageheight);

$colorWhite=imagecolorallocate($image, 255, 255, 255);

$colorGreen=imagecolorallocate($image, 0, 200, 0);

// x1 y1 x2 y2

imageline($image, 300, 200, 300,550, $coloGreen);

imagepng($image,'graphout.png');

imagedestroy($image);

print '<img src="graphout.png?lastmod=1">';

Excerpt from DA Text


Media software design

PHP Graphics: The GD Library

http://php.net/manual/en/ref.image.php

Basic example:

$Imagewidth=800;$Imageheight=600;

$image=imagecreate($Imagewidth, $Imageheight);

$colorWhite=imagecolorallocate($image, 255, 255, 255);

$colorGreen=imagecolorallocate($image, 0, 200, 0);

// x1 y1 x2 y2

imageline($image, 300, 200, 300,550, $coloGreen);

imagepng($image,'graphout.png');

imagedestroy($image);

print '<img src="graphout.png?lastmod=1">';

Do this to force

the browser not to cache

the png file.

If it is cached, you

won't see changes ... frustrating.

Excerpt from DA Text


Media software design

PHP Graphics: The GD Library

http://php.net/manual/en/ref.image.php

Basic example:

$Imagewidth=800;$Imageheight=600;

$image=imagecreate($Imagewidth, $Imageheight);

$colorWhite=imagecolorallocate($image, 255, 255, 255);

$colorGreen=imagecolorallocate($image, 0, 200, 0);

// x1 y1 x2 y2

imageline($image, 300, 200, 300,550, $coloGreen);

imagepng($image,'graphout.png');

imagedestroy($image);

print '<img src="graphout.png?lastmod=1">';

Do this to force

the browser not to cache

the png file.

If it is cached, you

won't see changes ... frustrating.

NOTE: This sometimes

sorta works

Excerpt from DA Text


Media software design

Project 4: Cowpies

Examine the cowpie1

prototype.

Behavior

Code

Examine the Requirements for Project 4

markbeam.com


Media software design

Project 4: Cowpies

Requirements BEGIN with a database task:

** remember previous moves and replay them.

So we will BEGIN (next week) with a tutorial database example

called "address book" to build up your database skills, and

also give you some code to steal / merge with cowpie1.php.

Let's look at one more graphical issue.

Can we write our .png DIRECTLY to browser?


Media software design

PHP Graphics: The GD Library

http://php.net/manual/en/ref.image.php

Basic example:

$Imagewidth=800;$Imageheight=600;

$image=imagecreate($Imagewidth, $Imageheight);

$colorWhite=imagecolorallocate($image, 255, 255, 255);

$colorGreen=imagecolorallocate($image, 0, 200, 0);

// x1 y1 x2 y2

imageline($image, 300, 200, 300,550, $coloGreen);

imagepng($image,'graphout.png');

imagedestroy($image);

print '<img src="graphout.png?lastmod=1">';

Can we write the

image DIRECTLY to

the browser, instead of

into a file? Docs say

we can, so we try it.

Excerpt from DA Text


Media software design

PHP Graphics: The GD Library

http://php.net/manual/en/ref.image.php

Basic example:

$Imagewidth=800;$Imageheight=600;

$image=imagecreate($Imagewidth, $Imageheight);

$colorWhite=imagecolorallocate($image, 255, 255, 255);

$colorGreen=imagecolorallocate($image, 0, 200, 0);

// x1 y1 x2 y2

imageline($image, 300, 200, 300,550, $coloGreen);

imagepng($image);

imagedestroy($image);

print '<img src="graphout.png?lastmod=1">';

Can we write the

image DIRECTLY to

the browser, instead of

into a file? Docs say

we can, so we try it.

Excerpt from DA Text


Media software design

GD direct to screen: ??

What's this?

Any ideas?


Media software design

GD direct to screen: ??

What's this?

Any ideas?

View Source


Media software design

GD direct to screen: ??

Once you've announced to the browser that HTML is

coming, it expects HTML.

So what if we tried a different header?


Media software design

So what if we tried a different header?

PHP has a header function. We modify cowpie1.php:

function htmlheader()

{

print "<html><body><form method='post'>";

}

//main program

$angle=$_POST['angle'];$velocity=$_POST['velocity'];

if (!$angle)

htmlheader();//need HTML first time for form

else

header('Content-type: image/png');


Media software design

Result: yes, it "works" ... but now it's not an HTML form

any more, so there are no inputs (controls). It's not

interactive.

So ... we're better off embedding png in html.


Media software design

FOR THURSDAY:

The usual shoot-out model:

GET your Group's BEST GAME ready to play!

If you need help with Project 3, come SEE ME.


  • Login