Mam dosc specyficzne zadanie, musze przeksztalcic zegar :

  1. <?php
  2. if (! $size > 0)
  3. {
  4. $size = 300;
  5. }
  6.  
  7. $radius = floor($size / 2);
  8.  
  9. header("content-Type: image/gif");
  10. header("refresh: 1");
  11.  
  12. $img = ImageCreate($size, $size);
  13. $color_alpha = ImageColorAllocate($img, 254, 254, 254);
  14. $color_white = ImageColorAllocate($img, 255, 255, 255);
  15. $color_black = ImageColorAllocate($img, 0, 0, 0);
  16. $color_gray = ImageColorAllocate($img, 192, 192, 192);
  17. $color_red = ImageColorAllocate($img, 255, 0, 0);
  18. $color_blue = ImageColorAllocate($img, 0, 0, 255);
  19. ImageColorTransparent($img, $color_alpha);
  20. ImageArc($img,$radius, $radius, $size, $size, 0, 360, $color_black);
  21. ImageFill($img, $radius, $radius, $color_white);
  22. $min = 0;
  23. while($min++ < 60) {
  24. if ($min % 15 == 0)
  25. $len = $radius / 5;
  26. elseif ($min % 5 == 0)
  27. $len = $radius / 10;
  28. else
  29. $len = $radius / 25;
  30. $ang = (2 * M_PI * $min) / 60;
  31. $x1 = sin($ang) * ($radius - $len) + $radius;
  32. $y1 = cos($ang) * ($radius - $len) + $radius;
  33. $x2 = (1 + sin($ang)) * $radius;
  34. $y2 = (1 + cos($ang)) * $radius;
  35. ImageLine($img, $x1, $y1, $x2, $y2, $color_black);
  36. }
  37. list($hour, $min, $sec) = preg_split ("/-/", Date("h-i-s", Time()));
  38. $hour = $hour % 12;
  39. $xs = intval(cos($sec * M_PI/30 - M_PI/2) * 0.75 * $radius + $radius);
  40. $ys = intval(sin($sec * M_PI/30 - M_PI/2) * 0.75 * $radius + $radius);
  41. $xm = intval(cos($min * M_PI/30 - M_PI/2) * 0.65 * $radius + $radius);
  42. $ym = intval(sin($min * M_PI/30 - M_PI/2) * 0.65 * $radius + $radius);
  43. $xh = intval(cos($hour*5 * M_PI/30 - M_PI/2) * 0.5 * $radius + $radius);
  44. $yh = intval(sin($hour*5 * M_PI/30 - M_PI/2) * 0.5 * $radius + $radius);
  45. ImageLine($img, $radius, $radius, $xs, $ys, $color_gray);
  46. ImageLine($img, $radius, $radius-1, $xm, $ym, $color_blue);
  47. ImageLine($img, $radius-1, $radius, $xm, $ym, $color_blue);
  48. ImageLine($img, $radius, $radius-1, $xh, $yh, $color_blue);
  49. ImageLine($img, $radius-1, $radius, $xh, $yh, $color_blue);
  50. ImageArc($img, $radius, $radius, $radius / 8, $radius / 8, 0, 360, $color_red);
  51. ImageFillToBorder($img, $radius, $radius, $color_red, $color_red);
  52.  
  53.  
  54. ImagePNG($img);
  55. ImageDestroy($img);
  56. ?>
  57.  


ma po przeksztalceniu wygladac tak: musi to byc tylko gorna polowka tarczy, ma byc widoczna 1 wskazowka, na tarczy maja byc napisane nastepujace wartosci: po lewej stronie 0 u gory 50 i po prawej 100, caly ten "licznik" ma byc podkreslony kreska (zeby to bylo zamkniete polkole) i ma wskazowka (ta ktora zostala) wywietlac zadana mu wartosc czyli np 50 i wowoczas strzalka bedzie skierowana w gore.
Udalo mi sie obciac tarcze i usunac 2 wskazowki i niestety na tym moja wiedza sie konczy sad.gif
moj kod wyglada nastepujaco:
  1. <?php
  2. if (! $size > 0)
  3. {
  4. $size = 300;
  5. }
  6.  
  7. $radius = floor($size / 2);
  8.  
  9. header("content-Type: image/gif");
  10.  
  11. $img = ImageCreate($size, $size);
  12. $color_alpha = ImageColorAllocate($img, 254, 254, 254);
  13. $color_white = ImageColorAllocate($img, 255, 255, 255);
  14. $color_black = ImageColorAllocate($img, 0, 0, 0);
  15. $color_gray = ImageColorAllocate($img, 192, 192, 192);
  16. $color_red = ImageColorAllocate($img, 255, 0, 0);
  17. $color_blue = ImageColorAllocate($img, 0, 0, 255);
  18. ImageColorTransparent($img, $color_alpha);
  19. ImageArc($img,$radius, $radius, $size, $size, 180, 360, $color_black);
  20. ImageFill($img, $radius, $radius, $color_white);
  21. $min = 14;
  22. while($min++ < 45 ) {
  23. if ($min % 45 == 10)
  24. $len = $radius / 5;
  25. elseif ($min % 5 == 10)
  26. $len = $radius / 10;
  27. else
  28. $len = $radius / 30;
  29.  
  30. $ang = (2 * M_PI * $min) / 60;
  31. $x1 = sin($ang) * ($radius - $len) + $radius;
  32. $y1 = cos($ang) * ($radius - $len) + $radius;
  33. $x2 = (1 + sin($ang)) * $radius;
  34. $y2 = (1 + cos($ang)) * $radius;
  35. ImageLine($img, $x1, $y1, $x2, $y2, $color_black);
  36. }
  37.  
  38. $xm = intval(($min * M_PI/1 - M_PI/1));
  39.  
  40.  
  41. ImageLine($img, $radius, $radius, $xm+100, $ym, $color_blue);
  42.  
  43.  
  44. ImageArc($img, $radius, $radius, $radius / 8, $radius / 8, 0, 360, $color_red);
  45. ImageFillToBorder($img, $radius, $radius, $color_red, $color_red);
  46.  
  47.  
  48. ImagePNG($img);
  49. ImageDestroy($img);
  50. ?>
  51.  


Bardzo prosil bym o ewentualna pomoc w tym projekcie smile.gif
Pozdrawiam