diff options
| author | group1 <f16_group1@pbridge.adm.cs.cmu.edu> | 2016-09-27 17:50:28 -0400 |
|---|---|---|
| committer | group1 <f16_group1@pbridge.adm.cs.cmu.edu> | 2016-09-27 17:50:28 -0400 |
| commit | 78fde3bb014ecd8e2368f2cc088839aecd0ca1ed (patch) | |
| tree | ef06fa2a4ad1495623ef6deba4d217e87715a862 /fish_render.py | |
| parent | dfa817559273c1b97e131f41a6051235d5ca4608 (diff) | |
| download | bridge-78fde3bb014ecd8e2368f2cc088839aecd0ca1ed.tar.zst | |
Fish render
Diffstat (limited to 'fish_render.py')
| -rw-r--r-- | fish_render.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fish_render.py b/fish_render.py new file mode 100644 index 0000000..be94a23 --- /dev/null +++ b/fish_render.py @@ -0,0 +1,29 @@ + +class Fish(object): + def __init__(self, x, y, width, height, color): + self.x = x + self.y = y + self.width = width + self.height = height + self.color = color + + +class BridgeRender(object): + WIDTH_SEGMENTS = 200 + HEIGHT_SEGMENTS = 2 + SAMPLES_PER_SEGMENT = 4 # Actual samples is this squared + + def __init__(self, fish): + self.fish = fish + + def compute_coverage(self, x, y): + min_x = max(x, self.fish.x - self.fish.width) + max_x = min(x+1, self.fish.x + self.fish.width) + min_y = max(y, self.fish.y - self.fish.height) + max_y = min(y+1, self.fish.y + self.fish.height) + + return (max_x - min_x) * (max_y - min_y) + + def compute_color(self, x, y, base_color): + cov = compute_coverage(x, y) + return (cov * self.fish.color) + ((1 - cov) * base_color) |
