PageRenderTime 68ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/slow/ext_imagick/pixel_color.php

http://github.com/facebook/hiphop-php
PHP | 60 lines | 52 code | 6 blank | 2 comment | 0 complexity | 69fab169cbed6b47f1af4d934559c2fd MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. // hphp doesn't support this at this moment
  3. // ini_set('precision', 3);
  4. function dump($exp) {
  5. $ret = print_r($exp, true);
  6. $count = -1;
  7. $ret = preg_replace_callback(
  8. '/\d+\.\d+/',
  9. function ($matches) {
  10. return sprintf('%.3f', $matches[0]);
  11. },
  12. $ret,
  13. -1,
  14. inout $count,
  15. );
  16. echo "$ret\n";
  17. }
  18. <<__EntryPoint>> function main(): void {
  19. $pixel = new ImagickPixel;
  20. $pixel->setColor('yellow');
  21. dump($pixel->getHSL());
  22. dump($pixel->getColor(true));
  23. $pixel = new ImagickPixel($pixel->getColorAsString());
  24. dump($pixel->getHSL());
  25. dump($pixel->getColor(false));
  26. $pixel = new ImagickPixel;
  27. $pixel->setHSL(0.3, 0.4, 0.5);
  28. dump($pixel->getHSL());
  29. dump($pixel->getColor(false));
  30. $pixel = new ImagickPixel($pixel->getColorAsString());
  31. dump($pixel->getHSL());
  32. dump($pixel->getColor(true));
  33. $pixel = new ImagickPixel('#F02B88');
  34. $colors = varray[
  35. Imagick::COLOR_BLACK,
  36. Imagick::COLOR_BLUE,
  37. Imagick::COLOR_CYAN,
  38. Imagick::COLOR_GREEN,
  39. Imagick::COLOR_RED,
  40. Imagick::COLOR_YELLOW,
  41. Imagick::COLOR_MAGENTA,
  42. Imagick::COLOR_ALPHA,
  43. Imagick::COLOR_FUZZ,
  44. ];
  45. foreach ($colors as $color) {
  46. dump($pixel->getColorValue($color));
  47. }
  48. foreach ($colors as $color) {
  49. $pixel->setColorValue($color, $pixel->getColorValue($color));
  50. }
  51. dump($pixel->getHSL());
  52. dump($pixel->getColor());
  53. echo "==DONE==\n";
  54. }