Cerebus Posted March 3, 2010 Share Posted March 3, 2010 Hi all, I've been working on getting this right for some time now, but I can't get it to work I'm trying to get some rectangles filled with a hatching pattern and it just doesn't go the way I want. The code I have now is the following: function applyhatch1 ($im, $sxp, $exp, $syp, $eyp) { // this is the \\\ hatch $spacing = 25; // line every 25px $min_x = ($exp-$sxp)/$spacing; $min_y = ($eyp-$syp)/$min_x; // first loop up for ($q=0; $q<=$min_x; $q++) { imageline($im, ($sxp+($q*$spacing)), $syp, $exp, ($eyp-($q*$min_y)), IMG_COLOR_STYLED); } // first loopdown for ($q=0; $q<=$min_x; $q++) { imageline($im, ($sxp), $syp+($q*$min_y), $exp-($q*$spacing), ($eyp), IMG_COLOR_STYLED); } return; } function applyhatch2 ($im, $sxp, $exp, $syp, $eyp) { // this is the /// hatch $spacing = 45; $min_x = ($exp-$sxp)/$spacing; $min_y = ($eyp-$syp)/$min_x; // first loop up for ($q=0; $q<=$min_x; $q++) { imageline($im, ($exp-($q*$spacing)), $syp, $sxp, ($eyp-($q*$min_y)), IMG_COLOR_STYLED); } // first loopdown for ($q=0; $q<=$min_x; $q++) { imageline($im, ($exp), $syp+($q*$min_y), $sxp+($q*$spacing), ($eyp), IMG_COLOR_STYLED); } return; } If I use applyhatch1 it does give me the hatch I want, but the hatching is not consistent (in spacing) on images of different size. Somewhere I'm going wrong, but not being able to find out where and why. Any help on this is appreciated. (attached a picture so you can see (hopefully) what I'm on about ) [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/194042-hatching-gd-images-going-crazy-here/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.