toHex.php 2.8 KB

12345678910111213141516171819202122
  1. <?php
  2. // 30 dpi
  3. $arr = array(20,41,18,42,16,41,15,41,14,41,12,40,11,40,10,39,9,38,8,37,7,36,6,34,5,33,4,32,3,29,2,26,1,23,1,19,0,16,1,13,1,10,1,9,2,8,2,6,3,5,4,4,4,3,5,3,6,2,7,1,8,1,9,0,10,0,11,0,12,0,14,0,16,0,19,1,21,1,24,2,26,4,29,5,31,6,34,8,36,10,39,11,40,13,41,14,42,15,43,17,44,19,44,20,45,22,45,24,45,25,45,27,45,28,45,29,44,30,43,31,43,32,42,32,41,32,40,32,39,32,38,31,37,30,37,28,36,27,36,25,36,22,36,20,36,16,36,12,36,7,36,2,37,5,38,7,39,9,39,10,40,10,40,11,41,12,42,12,43,12,44,12,45,12,46,11,46,10,47,9,48,5,48,4,49,3,49,2,50,1,51,1,52,2,53,2,54,3,55,4,55,5,55,6,55,7,56,8,56,9,55,11,55,12,55,13,54,14,56,13,57,12,59,12,60,12,62,12,64,13,66,13,65,11,65,9,65,8,65,6,65,5,65,4,66,4,66,3,67,3,68,3,69,3,70,3,71,4,72,4,73,5,74,6,75,7,76,8,77,9,77,10,78,12,79,13,79,15,79,12,78,10,78,9,78,8,78,7,78,6,79,5,80,4,81,4,82,4,83,5,85,6,87,7,88,8,89,11,91,13,92,16,94,13,95,10,95,8,96,6,96,5,96,4,96,3,95,3,94,3,93,3,92,3,90,4,87,6,89,5,91,4,94,4,96,4,99,4,101,4,104,4,107,5,110,6,113,7,117,8,120,9,127,12,134,15,141,18,148,22,155,26,162,30,175,38,186,44);
  4. // 82 (90 dpi values exceed 255)
  5. $arr = array(58,125,53,126,48,125,44,125,40,123,36,122,32,120,28,117,25,114,22,111,19,108,16,104,14,100,11,96,7,87,4,78,2,69,1,59,0,49,1,40,2,32,3,28,4,24,6,20,8,17,10,14,12,11,14,9,17,7,19,5,22,4,25,2,28,2,31,1,34,1,41,0,48,1,55,3,63,5,70,8,78,12,85,16,93,20,100,25,108,30,115,35,119,39,122,43,125,47,128,52,131,57,132,62,134,67,135,72,135,77,135,82,134,86,133,89,131,92,128,95,127,96,125,96,123,97,121,97,119,97,117,96,115,96,114,94,112,93,111,90,110,86,108,82,107,76,107,68,106,60,106,49,106,37,106,23,107,6,110,16,113,23,115,27,116,30,118,32,120,34,122,36,124,37,126,38,128,38,130,38,132,37,134,36,136,35,137,33,138,32,140,27,142,17,144,13,145,9,146,7,147,6,149,5,150,5,153,5,156,6,159,8,161,10,163,13,164,16,165,19,165,23,166,26,166,29,165,33,165,35,164,38,163,40,161,42,160,43,167,39,171,38,175,37,180,37,185,37,190,39,196,41,195,33,194,28,193,24,193,20,194,16,195,13,196,12,197,11,199,10,201,9,204,9,206,10,209,11,212,12,215,13,218,16,221,18,224,21,226,24,229,28,231,31,233,36,235,40,236,45,235,38,233,31,233,28,233,24,233,21,234,19,235,17,236,15,238,14,241,14,244,14,248,15,253,18,259,21,261,23,263,25,267,33,271,41,275,48,280,39,283,31,285,25,287,20,288,16,288,13,287,11,286,9,284,9,281,9,278,9,275,10,268,13,261,18,267,14,273,12,279,9,286,8,293,7,300,7,307,7,314,8,322,9,329,10,337,13,345,15,353,18,361,22,369,26,378,30,394,39,411,49,428,61,445,73,462,86,478,100,494,114,510,128);
  6. $out = array();
  7. $len = count($arr);
  8. $last = array($arr[0], $arr[1]);
  9. for($i = $len/2; $i--;) {
  10. $c = array($arr[$len - 2 * ($i + 1)], $arr[$len + 1 - 2 * ($i + 1)]);
  11. $x = $last[0] - $c[0];
  12. $y = $last[1] - $c[1];
  13. $out[] = array($x,$y);
  14. $last[0] = $c[0];
  15. $last[1] = $c[1];
  16. }
  17. // print recentered output
  18. foreach($out as $v) {
  19. echo sprintf("b'\\x%02X' b'\\x%02X' ", $v[0] + 127, $v[1] + 127);
  20. }