예제 #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)