class Equation: def __init__(self, xf, yf, cf=(255,255,255), wf=1): self.xf = xf self.yf = yf self.cf = cf self.wf = wf def _xf(self, t): if callable(self.xf): return self.xf(t) else: return t def _yf(self, t): if callable(self.yf): return self.yf(t) else: return t def _cf(self, t, r): if callable(self.cf): return self.cf(t, r) else: return self.cf def _wf(self, t, r): if callable(self.wf): return self.wf(t, r) else: return self.wf def plot(self, r=(0, 12, 0.1), scale=(1,1)): t = r[0] prev_x = self._xf(t) prev_y = self._yf(t) while t <= r[1]: x = self._xf(t) y = self._yf(t) c = self._cf(t, r) w = self._wf(t, r) yield ( int(prev_x * scale[0]), int(prev_y * scale[1]), int(x * scale[0]), int(y * scale[1]), c, w, ) prev_x, prev_y = x, y t += r[2]