コード例 #1
0
ファイル: draw.py プロジェクト: gyver/p2pool
def get_pos(share, t, d):
        x = 5 + get_uniform(d.get_width() - 10, share.hash, "pos")
        y = d.get_height() - (t - share.time_seen)*10
        return v(x, y)
コード例 #2
0
ファイル: draw.py プロジェクト: gyver/p2pool
def get_uniform(bound, *data):
    x = int(hashlib.sha256(repr(data)).hexdigest(), 16)
    return x % bound

def get_pos(share, t, d):
        x = 5 + get_uniform(d.get_width() - 10, share.hash, "pos")
        y = d.get_height() - (t - share.time_seen)*10
        return v(x, y)

def get_color(data):
    return [get_uniform(256, data, x) for x in "rgb"]

def perp_and_normalize_to((dx, dy), d):
    m = math.sqrt(dx**2 + dy**2)
    return v(-dy/m*d, dx/m*d)

def go(share, tracker, t, d):
    #c = color.green if share.peer is None else color.red
    c = get_color(share.new_script)
    pos = get_pos(share, t, d)
    pygame.draw.circle(d, c, pos.rounded, 5)
    if share.previous_hash in tracker.shares:
        previous_share = tracker.shares[share.previous_hash]
        previous_pos = get_pos(previous_share, t, d)
        vec_to_previous = previous_pos - pos
        pygame.draw.polygon(d, c, [
            (pos + perp_and_normalize_to(vec_to_previous, 5)).rounded,
            (pos + perp_and_normalize_to(vec_to_previous, -5)).rounded,
            previous_pos.rounded,
        ])
コード例 #3
0
ファイル: draw.py プロジェクト: finway-china/p2pool
    x = int(hashlib.sha256(repr(data)).hexdigest(), 16)
    return x % bound

def get_pos(share, t, d):
    x = 5 + get_uniform(d.get_width() - 10, share.hash, "pos")
    y = d.get_height() - (t - share.time_seen)*10
    if y < -10000: y = -10000
    if y > 10000: y = 10000
    return v(x, y)

def get_color(data):
    return [get_uniform(256, data, x) for x in "rgb"]

def perp_and_normalize_to((dx, dy), d):
    m = math.sqrt(dx**2 + dy**2)
    return v(-dy/m*d, dx/m*d)

def go(share, tracker, t, d):
    #c = color.green if share.peer is None else color.red
    c = get_color(share.new_script)
    pos = get_pos(share, t, d)
    pygame.draw.circle(d, c, pos.rounded, 5)
    if share.previous_hash in tracker.shares:
        previous_share = tracker.shares[share.previous_hash]
        previous_pos = get_pos(previous_share, t, d)
        vec_to_previous = previous_pos - pos
        if vec_to_previous.mag() > 1:
            pygame.draw.polygon(d, c, [
                (pos + perp_and_normalize_to(vec_to_previous, 5)).rounded,
                (pos + perp_and_normalize_to(vec_to_previous, -5)).rounded,
                previous_pos.rounded,
コード例 #4
0
ファイル: draw.py プロジェクト: finway-china/p2pool
def get_pos(share, t, d):
    x = 5 + get_uniform(d.get_width() - 10, share.hash, "pos")
    y = d.get_height() - (t - share.time_seen)*10
    if y < -10000: y = -10000
    if y > 10000: y = 10000
    return v(x, y)
コード例 #5
0
ファイル: draw.py プロジェクト: dooglus/p2pool
def get_pos(share, t, d):
    x = 5 + get_uniform(400 - 10, share.hash, "pos")
    y = d.get_height() - (t - share.time_seen)*10
    if y < -10000: y = -10000
    if y > 10000: y = 10000
    return v(x, y)