File size: 778 Bytes
52a9452 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from concern.config import Configurable
class DataProcess(Configurable):
r'''Processes of data dict.
'''
def __call__(self, data):
return self.process(data)
def process(self, data):
raise NotImplementedError
def render_constant(self, canvas, xmin, xmax, ymin, ymax, value=1, shrink=0):
def shrink_rect(xmin, xmax, ratio):
center = (xmin + xmax) / 2
width = center - xmin
return int(center - width * ratio + 0.5), int(center + width * ratio + 0.5)
if shrink > 0:
xmin, xmax = shrink_rect(xmin, xmax, shrink)
ymin, ymax = shrink_rect(ymin, ymax, shrink)
canvas[int(ymin+0.5):int(ymax+0.5)+1, int(xmin+0.5):int(xmax+0.5)+1] = value
return canvas
|