/    Sign up×
Community /Pin to ProfileBookmark

imagefilledrecatangle in a loop

Ok its very easy to create a single rectangle, heres what I have now.

[code=php]<?
$im = @imagecreate(80, 80);
$background_color = imagecolorallocate($im, 177, 179, 188);
$cellSize=10;
$x_from=0;
$y_from=0;
$main_color = imagecolorallocate($im, 233, 14, 91);
$dark_color = imagecolorallocate($im, 200, 11, 73);
$light_color = imagecolorallocate($im, 255, 18, 110);
imagefilledrectangle ($im, $x_from, $y_from, $x_from + $cellSize – 1, $y_from + $cellSize – 1, $light_color );
imagefilledrectangle ($im, $x_from + 1, $y_from + 1, $x_from + $cellSize – 1, $y_from + $cellSize – 1, $dark_color );
imagefilledrectangle ($im, $x_from + $cellSize – 1, $y_from, $x_from + $cellSize – 1, $y_from, $dark_color );
imagefilledrectangle ($im, $x_from + 1, $y_from + 1, $x_from + $cellSize – 2, $y_from + $cellSize – 2, $main_color );
header(“Accept-Ranges: bytes”,true, 200);
ob_start(); // Turn on buffering
imagegif($im); // Output the image to the buffer
$imageSize=ob_get_length(); // Get size of image file
$imageData=ob_get_clean(); // Get image file contents
header(“Content-Length: $imageSize”);
header(“Content-Type: image/gif”);
header(“Last-Modified: Wed, 26 Jan 2005 18:36:31 GMT”);
echo $imageData; // Output the image data
imagedestroy($im);
?>

[/code]

What I want to do is draw a diagram like this into a textarea

——*****——-
——**
**——-
——**
*
**——-

and then it will somehow grab the coordinates and draw imagefilledrectangles where the stars are.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@solomonApr 07.2005 — textareas don't give 'coordinate' information. You might be able to achieve a similar result by exploding the POST information from the textarea with [code=php]$var = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
[/code]
. Then, knowing the dimensions of your text area (height and width in lines and characters), you can determine whereabouts in the exploded array a particular character comes. You can then interpret each character using your script above.
×

Success!

Help @Conor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...