cheechm Posted February 2, 2013 Share Posted February 2, 2013 I've got some code that basically draws a wavefrom line by line (going horizontally). I was hoping to be able to get a vertical gradient, however I'm not too sure where to start. imageline( $img, // x1 (int) ($data_point / DETAIL), // y1: height of the image minus $v as a percentage of the height for the wave amplitude $height * $wav - $v, // x2 (int) ($data_point / DETAIL), // y2: same as y1, but from the bottom of the image $height * $wav - ($height - $v), imagecolorallocate($img, $r, $g, $B) ); The full code is available here: Github Another question I have: Is it possible to fill every part of the PNG image which isn't transparent with a solid colour? Thanks Link to comment https://forums.phpfreaks.com/topic/273936-working-with-images/ Share on other sites More sharing options...
Barand Posted February 2, 2013 Share Posted February 2, 2013 Do you have a question? Link to comment https://forums.phpfreaks.com/topic/273936-working-with-images/#findComment-1409640 Share on other sites More sharing options...
cheechm Posted February 2, 2013 Author Share Posted February 2, 2013 Do you have a question? Another question I have: Is it possible to fill every part of the PNG image which isn't transparent with a solid colour? Admittedly my first question wasn't as clear. How might I go around drawing a single pixel line with a vertical gradient? Link to comment https://forums.phpfreaks.com/topic/273936-working-with-images/#findComment-1409643 Share on other sites More sharing options...
Barand Posted February 2, 2013 Share Posted February 2, 2013 vertical gradient $height = 200; $xpos = 23; $ypos = 50; $c1 = array(0xFF, 0x00, 0x00); $c2 = array(0x00, 0x00, 0xFF); $interval = 20; $im = imagecreatetruecolor(50,300); $bg = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $border = imagecolorallocate($im, 0x00, 0x00, 0x00); imagefill($im,0,0,$bg); imagerectangle($im, 0,0,imagesx($im)-1,imagesy($im)-1,$border); imagesetthickness($im, 4); $y1 = $ypos; for ($y2 = $ypos+$interval; $y2 <= $ypos+$height; $y2+=$interval) { $c=array(); for ($i=0; $i<3; $i++) { $c[$i] = $c1[$i] + ($c2[$i]-$c1[$i])*($y2-$ypos)/$height; } $col = imagecolorallocate($im, $c[0], $c[1], $c[2]); imageline($im, $xpos, $y1, $xpos, $y2, $col); $y1 = $y2; } header("content-type: image/png"); imagepng($im); imagedestroy($im); Link to comment https://forums.phpfreaks.com/topic/273936-working-with-images/#findComment-1409723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.