Hejsa.
Jeg har denne kode:
- <?php
- $val = array(
- 1 => 5,
- 2 => 4,
- 3 => 3,
- 4 => 2
- );
- $total = $val[1] + $val[2] + $val[3] + $val[4];
- $totalval = array(
- 1 => ($val[1] / $total * 360),
- 2 => ($val[2] / $total * 360),
- 3 => ($val[3] / $total * 360),
- 4 => ($val[4] / $total * 360)
- );
- sort($totalval);
- $myImage = ImageCreate(360,360);
-
- $white = ImageColorAllocate ($myImage, 255, 255, 255);
- $red = ImageColorAllocate ($myImage, 255, 0, 0);
- $green = ImageColorAllocate ($myImage, 0, 255, 0);
- $yellow = ImageColorAllocate ($myImage, 255, 0, 255);
- $blue = ImageColorAllocate ($myImage, 0, 0, 255);
- $lt_red = ImageColorAllocate($myImage, 255, 150, 150);
- $lt_green = ImageColorAllocate($myImage, 150, 255, 150);
- $lt_blue = ImageColorAllocate($myImage, 150, 150, 255);
-
- ImageFilledArc($myImage, 100, 100, 200, 150, $totalval[3], $totalval[0], $red, IMG_ARC_PIE);
- ImageFilledArc($myImage, 100, 100, 200, 150, $totalval[0], $totalval[1], $green, IMG_ARC_PIE);
- ImageFilledArc($myImage, 100, 100, 200, 150, $totalval[1], $totalval[2], $blue, IMG_ARC_PIE);
- ImageFilledArc($myImage, 100, 100, 200, 150, $totalval[2], $totalval[3], $yellow, IMG_ARC_PIE);
- header ("Content-type: image/png");
- ImagePNG($myImage);
- ImageDestroy($myImage);
- ?>
I dette tilfælde tegner den tærten korrekt, men hvis jeg skifter værdierne i array val til to af samme tal, så tegner den kun én farve og det er den sidste(altså farven $yellow(som alligevel ikke er gul
))
Nogen der har nogle ideer?