Do your little circles have to be re-generated each time the script is called? Ie. If the circles are always the same size(s) and chosen from a limited set of colours, and it's only which colour/size get displayed in which position each time, then you are probably better off generating 1 small gif/png of each possible color/size combination and placing these somewhere accessable to your cgi script as a one time thing.

Then, your cgi script need only calculate which of the pre-existing images needs to be displayed in each position and generate the html with the appropriate IMG tag in each position. Saves (re-) generating the images each time. You could do this with image tags inside a table--quick and simple but not hip. Or you could use css to position the images.

Perhaps the smartest way would be to use css to define classes for each color/size combination using the background-image property, and then generate a table with the appropriate class applied to each cell.

Theoretically you could have a standard table with a different class tag applied to each cell (eg. <td class="cell0-0"></td><td class="cell1-0"></td>...) and then you generate the style sheet to map the class definition (eg.  cell0-0 { background-image: url( 'images/bluecircle.png'); } etc. as required by your calculations.

If however, there is no reasonable finite set of colour/size combinations, then your probably better of generating one large image, writing it to disc with a unique name and then generating the html to reference the image you generated. Doing it this way you will need to have some mechanism for cleaning up the (possibly large in size and number) of the images you generate.

A clearer description of your application and your code so far will usually get you better responses.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

In reply to Re: cgi graphics by BrowserUk
in thread cgi graphics by Evanovich

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.