SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: two rectangles

  1. #1
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    two rectangles

    I have to generate with php two PNG rectangles:
    I generate one rectangle of this way:
    rectangle.php
    PHP Code:
    <?php

    header 
    ("Content-type: image/png" );
    $porcentaje=$HTTP_GET_VARS['porcentaje'];


    $tope=300;//tope del fondo

     
    $im2 = @ImageCreate ($tope20)//rectangulo de longitud 390 para el 100%
      //si quiero un 50..seria 60, a cambiar tb en l string
        
    or die ("Cannot create a new GD image.");


    $background_color ImageColorAllocate ($im2200130180);
    $text_color ImageColorAllocate ($im2255255255);

    $alcentro=$tope-30;

    ImageString ($im22$alcentro3"hola"."%"$text_color );

    ImagePng ($im2);//line 9
    //linea 10
    ?>
    This is the file which calls the image:
    tablepicture.php
    PHP Code:
    <?php
    echo "<table>";
    $destino='dimensiones.txt';
    $largo=100;
    echo 
    "<tr>";
    echo 
    "<td>";
    echo 
    "<br>hay alguien?<br>";
    echo 
    "<img src=\"picture.php?largo=$largo\">";//line 7
    //line 8
    echo "</td>";//line9
    echo "</tr>";
    echo 
    "</table>";
    ?>
    THE PROBLEM IS:
    I want to draw to overlapped rectangles.
    If I call picture.php again in line 8 of tablepicture.php, I draw a rectangle which starts when the first rectangle finishes, so I do not get two OVERLAPPED rectangles.
    If I launch in line 10 of rectangle.php other ImagePng($rectangle 2)(of course, with its $background_color ), the script only shows me the first one.
    THE QUESTION IS:
    HOW CAN I DRAW TWO OVERLAPPED RECTANGLES?
    Regards from Spain.

  2. #2
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use CSS for positioning and embed the rectangles in a div:

    PHP Code:
    <?php 

    echo "<table>"

    $destino='dimensiones.txt'
    $largo=100

       echo 
    "<tr>"
          echo 
    "<td>"
          echo 
    "<br>hay alguien?<br>";
          echo 
    "<div>";
             echo 
    "<div id='firstRectangle'><img src=\"picture.php?largo=$largo\"></div>"
             echo 
    "<div id='secondRectancle'><img ... /></div>"
          echo 
    "</div>";
          echo 
    "</td>";
       echo 
    "</tr>"

    echo 
    "</table>"
    ?>
    If you set the positioning of the rectangles relative to the parent object (the embedding <div>), it should work !

  3. #3
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks ...I have found another solution.

    I will try yours,too.
    Regards from Spain.

  4. #4
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by marylin77
    Thanks ...I have found another solution.
    Which one, if you don't mind my asking? Would be nice of you sharing the solution with us .

    Quote Originally Posted by marylin77
    I will try yours,too.
    Let us know, which one you prefer!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •