Location: PHPKode > projects > PHP Cad and Drawing Program > phpcad/functions/aa--readme.txt
The purpose of the document is to describe how to make an .inc.  The idea is
to make the objects as pluggable as one file, where all you have to do is put a
whatever .inc in this function directory and it will automatically show up in
the menu and work for movies, povray, and your screen.

In each .inc, you will notice a bunch of AAAAAAAA, BBBBBBB, CCCCCCC, DDDDDDD,
and EEEEEEEE.  These dividers are each 15 or more characters long, if you use
less, the php code will not be able to separate the sections and you will get
errors.  The best way to make a new function is to use a close existing function
and edit it.

*** Above AAAA ***

Above AAAA I believe you can use for anything text.  A good spot to place your
name and stuff.  You probably, don't even have to comment it out.  Since php
only scans the sections between the letters and reads it in.

*** Between AAAA and BBBB ***

This is the GD function used to draw a point on the screen.  The upper comments
are very important, between the "AAAAA" and the word "function" only use //
comments.  These lines will show up as help in the GUI.  Much easier and cleaner
than using docbook.

Next comes the GD function.  Use standard GD code to put the object
on the screen. By convention the define point ($x,$y) must be at the end of the
attributes to allow deleting in the editor and to prevent it from being deleted
by the editor. It is also best not to use non-scalable GD functions like "LINE",
but use "RECT" instead.  You should attempt to make all objects scalable.  Also,
by convention, all objects that use more than one point, should use
coordinates relative to $x,$y.  This will be necessary if I ever make a
"movearea" routine in the menu.  The standard format for a function is,
functionfoo(usually $image or $time first, whatever, blaha, blahb, blahc,
$scale,$x, $y). At minimum you need to include "function whatever(blaha, blahb,
blahc) {}", if the object was developed for 3-D povray and not to be visiable in 
//  Draws a simple pixel, click point and submit.
//  Color option may be added later.
//  The pixel is only 1 unit high in povray though
function pixelone($image, $scale, $x, $y)
    $edge = ImageColorAllocate($image,110,190,190);
    $padobe = ImageColorAllocate($image,100,180,180);
    $x = $x * $scale;
    $y = $y * $scale;

*** Between BBBBB and CCCCC ***

Between BBBBB and CCCCC is the scriptmaker function.  This function takes data
from the 2nd form and is used to write one line into a text object image file
(.tob). The first thing you need to do is VERIFY the data.  This is very
important if you were use this program online. I am working on verify all data
of all objects, since I was originally not expecting to use the program online
but am now. 'fwrite ($a, $xp)' writes the line to the file.  $PObj contains
the function name, $PDir contains data from the first select box, $PLen contains
data from the second select box, and $PTxt, contains data from the textarea.

if ($PObj == "pixelone") {
    $a=fopen("./files/$pfilez", "a");
    for($i = 0;$i < $PLen; ++$i) {
        if ($PDir == "R") {
            $xp = "<?php " . $PObj . "($" . "image,";
            $xp .= "$" . "scale," . $xx . "," . $yy . "); ?>\n";
        } else {
            $xp = "<?php " . $PObj . "($" . "image,";
            $xp .= "$" . "scale," . $xx . "," . $yy . "); ?>\n";
        fwrite($a, $xp);

*** Between CCCCC and DDDDD ***

Between CCCCC and DDDDD is the povray function.  It writes lines
of povray text to a file.  At minimum, even if
you don't use a povray with this object, you need to include one line,
"function whatever(bhaha, blahb, blahc) {}" so if you decide to display
the picture in povray, you won't get an error.  The global variables
are used so you can change the default texture or even floor height.
See falkenstein.tob as an example.  These variables could be placed
in the function, but to save time, of not having to enter textures
for each object it was done this way.  You can change default textures
at the bottom of pov.php.

function pixelone($image,$scale,$x,$y)
    global $floor;
    global $twall;
    global $tfoundation;
    global $zz;
    $a = "box{<";
    $a .= $x . "," . ($floor) . ",";
    $a .= $y  . "><";
    $a .= $x+1;
    $a .= "," . (1+$floor) . ",";
    $a .= $y+1;
    $a .= "> $twall}\n";

*** Between DDDDD and EEEEE ***

This is where you setup the menu form. These items are to to generate javascript
menus dynamically.  $inthemenu variable is set to "yes"if you wrote a 
scriptmaker function (See above).  You might also want to turn itoff on the web 
for whatever reason, thus it is an option.$dirlist shows up in the first select 
box, $lenlist shows upin the second box, and $txtitem will show up in the 
textbox to give the user the format of this box for example "122323&23&12121&Eat" 
at Joes.  By conventionuse & to separate data and describe the contents for this 
box in the data.
$inthemenu = "yes";
$dirlist = array("R","D");
$lenlist = array("1","2","3","4","5","6","7","8","10","12","16","20","25","30");

Return current item: PHP Cad and Drawing Program