
January 21st, 2003, 10:59 PM
|
|
|
|
Join Date: Apr 2007
Posts: 367
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
RE: Wrapping in code...
I understand your point,
Quote:
It might make reading the textual portions of posts less convenient
due to horizontal scrolling, but the code would be much more neat,
thus easier to read. |
but (since you've widened this post already) the following short bit
of code
Code:
function resizeImage($imptr,$w,$border=1){
$old_w=ImageSX($imptr);
$old_h=ImageSY($imptr);
$new_w=$w;
$new_h = ($old_h*$new_w)/$old_w;
$dst_img=ImageCreate($new_w,$new_h);
ImageCopyResized ($dst_img,$imptr,0,0,0,0,$new_w,$new_h,$old_w,$old _h);
if ($border){
$black = ImageColorAllocate ($dst_img, 0, 0, 0);
imagerectangle ( $dst_img, 0, 0, $new_w-1, $new_h-1, $black);
}
return $dst_img;
}
is much easier to read, especially if you're
trying to get your head around an idea,
than the following:
Code:
function resizeImage($imptr,$w,$border=1){
$old_w=ImageSX($imptr);
$old_h=ImageSY($imptr);
$new_w=$w;
$new_h = ($old_h*$new_w)/$old_w;
$dst_img=ImageCreate($new_w,$new_h);
ImageCopyResized
($dst_img,$imptr,0,0,0,0,$new_w,$new_h,$old_w,$old _h);
if ($border){
$black = ImageColorAllocate
($dst_img, 0, 0, 0);
imagerectangle ( $dst_img, 0, 0, $new_w-
1, $new_h-1, $black);
}
return $dst_img;
}
which is how it appears for me at 1280*1024(not fullscreen).
I'm only suggesting this to make things clearer for people
trying to learn. (If you wanted to get really crazy, you could
you could insert an html linebreak every 15th or 20th word in
text outside of the 'code' tags.) Probably not though.
Just a suggestion...
|