/    Sign up×
Community /Pin to ProfileBookmark

imagefilledrectagle – pattered background ?

imagefilledrectagle – pattered background ?

Hi All

Is it possible to have a pattern as the background of image created with imagefilledrectangle.

This creates a solid tray block but I want a block with a simple pattered fill.

[code]
<?php

header(‘Content-Type: image/png’);

$im = imagecreatetruecolor(1020, 215);

$gray = imagecolorallocate($im, 220, 220, 220);
imagefilledrectangle($im, 0, 0, 1020, 214, $gray);

imagepng($im);

imagedestroy($im);

?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyNov 26.2011 — PHP doesn't have a function that does this automatically, but you should be able to use imagecopymerge() to repeatedly copy a pattern image onto a base image.
Copy linkTweet thisAlerts:
@ttmtauthorNov 28.2011 — It's not a pattern function but I got it working with.

<i>
</i>&lt;?php

<i> </i>header('Content-Type: image/png');

<i> </i>$im = imagecreatetruecolor(1020, 215);

<i> </i>$w = imagecolorallocate($im, 255, 255, 255);
<i> </i>$c = imagecolorallocate($im, 235, 235, 235);
<i> </i>$black = imagecolorallocate($im, 10, 10, 10);
<i> </i>$style = array($w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$w,$c,$c,$c,$c,$c,$c,$c);
<i> </i>ImageSetStyle($im, $style);

<i> </i>imagefilledrectangle($im, 0, 0, 1020, 214, IMG_COLOR_STYLED);

imagefttext($im, $textSize, 0, 15, 165, $black, $font, $text);

<i> </i>imagepng($im);

<i> </i>imagedestroy($im);

?&gt;
×

Success!

Help @ttmt 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.19,
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,
)...