/    Sign up×
Community /Pin to ProfileBookmark

Passing values to image

Hi,

I have this:

[code=php]<?php
Header(“Content-type: image/png”);
$height=8000;
$width=8000;
$ofst=0;
$im=ImageCreate($width*2+10, $height);
$imr=ImageCreate($width, $height);
$fac=rand(110,130)/100;
$points=array(0=>0,0);
while($width>5){
$points[count($points)]=$points[count($points)-2]+round($width/$fac);
$width=round($width/$fac);
$points[count($points)]=$points[count($points)-2];
$points[count($points)]=$points[count($points)-2];
$points[count($points)]=round($width/$fac)+$points[count($points)-2];
$width=round($width/$fac);

$points[count($points)]=$points[count($points)-2]-round($width/$fac);
$width=round($width/$fac);
$points[count($points)]=$points[count($points)-2];
$points[count($points)]=$points[count($points)-2];
$points[count($points)]=$points[count($points)-2]-round($width/$fac);
$width=round($width/$fac);
}
$pointsb=array_reduce($points, “rsum”);
if($_GET[“use”]==”yes”){
for($i=1;$i<10;$i++){
eval(“$r”.$i.”=$_GET[“r1″];”);
eval(“if($r”.$i.”==””){$r”.$i.”=rand(0,255)}”);
}
}
else{
for($i=1;$i<10;$i++){
eval(“$r”.$i.”=rand(0,255)”);
}
}

$spia=ImageColorAllocate($im,$r1,$r2,$r3);
$spib=ImageColorAllocate($im,$r4,$r5,$r6);
$spic=ImageColorAllocate($im,$r7,$r8,$r9);

$pointsl=$points;
$z=0;
while($z<count($pointsl)){
$pointsl[$z]=$pointsl[$z]-500/(pow($fac,$z/4));
$z=$z+2;
}
drawpolys();

/*$iml=$im;
$im=$imr;*/
$pointsl=$points;
$z=0;
while($z<count($pointsl)){
$pointsl[$z]=$pointsl[$z]+500/(pow($fac,$z/4));
$z=$z+2;
}
$ofst=8100;
imagefilledpolygon($im,array(8000,0,8100,0,8100,8000,8000,8000),4,ImageColorAllocate($im,255,255,255));
drawpolys();
ImagePNG($im);
function rsum($v, $w)
{
$v = $v.”,”.$w;
return $v;
}
function drawpolys(){$y=0;
global $pointsl,$spi,$spia,$spib,$spic,$im,$ofst;
for($x=0;$x+10<count($pointsl);$x+=2){
$cr=array($pointsl[$x]+$ofst,$pointsl[$x+1],$pointsl[$x+2]+$ofst,$pointsl[$x+3],$pointsl[$x+10]+$ofst,$pointsl[$x+11],$pointsl[$x+8]+$ofst,$pointsl[$x+9]);
if($y%3==0){$spi=$spia;}
if($y%3==1){$spi=$spib;}
if($y%3==2){$spi=$spic;}
imagefilledpolygon($im,$cr,4,$spi);
$y++;
}
imagefilledpolygon($im,array($pointsl[6]+$ofst,$pointsl[7],$pointsl[8]+$ofst,$pointsl[9],0+$ofst,0,0+$ofst,8000),4,$spic);
imagefilledpolygon($im,array($pointsl[4]+$ofst,$pointsl[5],$pointsl[6]+$ofst,$pointsl[7],0+$ofst,8000,8000+$ofst,8000,8000+$ofst,8000+$pointsl[5]-$pointsl[4]),5,$spib);
imagefilledpolygon($im,array($pointsl[2]+$ofst,$pointsl[3],$pointsl[4]+$ofst,$pointsl[5],8000+$ofst,8000+$pointsl[5]-$pointsl[4],8000+$ofst,0),4,$spia);
}
?>[/code]

and:

[CODE]<html>

<head>
<title>Form</title>
</head>

<body>
<form method=”get” action=”spiral.php”>
<input type=”text” name=”use” />
<input type=”text” name=”r1″ />
<input type=”text” name=”r2″ />
<input type=”text” name=”r3″ />
<input type=”text” name=”r4″ />
<input type=”text” name=”r5″ />
<input type=”text” name=”r6″ />
<input type=”text” name=”r7″ />
<input type=”text” name=”r8″ />
<input type=”text” name=”r9″ />
<input type=”submit” />
</form>
</body>

</html>[/CODE]

If use=”yes” then the values r1 to r9 should equal what they’re specified in the form, or if they’re blank, a random number between 0 and 255. If use=no then r1-9 are all random.

Thanks,

Neil

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @neil9999 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...