コード例 #1
0
function test_url_char_to_xy_main()
{
    header('Content-type: text/plain');
    for ($scale = 8; $scale > 1; $scale /= 2) {
        for ($quantize = 8; $quantize > 1; $quantize /= 2) {
            if ($quantize <= $scale) {
                print "Passing quantize: {$quantize}, scale: {$scale}\n";
                $ci = 0;
                for ($y = 0; $y < 8; ++$y) {
                    for ($x = 0; $x < 8; ++$x) {
                        $c = substr(URL_CHARS, $ci, 1);
                        list($px, $py) = url_char_to_xy($c, $quantize, $scale);
                        print "({$px},{$py}) ";
                        ++$ci;
                    }
                    print "\n";
                }
                print "\n\n";
            }
        }
    }
}
コード例 #2
0
ファイル: binary.php プロジェクト: JasonWoof/square
function easy_shadow($url)
{
    $url_len = strlen($url);
    $parent = tile_get_128(substr($url, 0, -1));
    $shadow = '';
    $pos = strpos(URL_CHARS, substr($url, -1));
    $qx = floor($pos % 8 / 2) * T32_RB;
    $qy = floor($pos / 16) * T128_RB * 32;
    for ($y = 0; $y < 32; ++$y) {
        $shadow .= substr($parent, $qx + $qy + $y * T128_RB, T32_RB);
    }
    if ($url_len == 1) {
        return $shadow;
    }
    if ($url_len > 1) {
        $shadow_4_tile = tile_get_128(substr($url, 0, -2));
        list($x, $y) = url_char_to_xy(substr($url, -2, 1), 8, 128);
        list($xq, $yq) = url_char_to_xy(substr($url, -1, 1), 4, 16);
        $shadow_4 = t128_subsection($shadow_4_tile, $x + $xq, $y + $yq, 4);
        if ($url_len > 2) {
            $initial_toggle = get_initial_toggle($url, 2);
            if ($initial_toggle) {
                $shadow_4[0] = chr(ord($shadow_4[0]) ^ 0xff);
                $shadow_4[1] = chr(ord($shadow_4[1]) ^ 0xff);
                $shadow_4[2] = chr(ord($shadow_4[2]) ^ 0xff);
                $shadow_4[3] = chr(ord($shadow_4[3]) ^ 0xff);
            }
        }
        blit_xor_8x($shadow, $shadow_4, 4);
    }
    return $shadow;
}