def test_unset_empty(self): c = Canvas() c.set(1, 1) c.unset(1, 1) self.assertEqual(len(c.chars), 0)
def test_unset_nonempty(self): c = Canvas() c.set(0, 0) c.set(0, 1) c.unset(0, 1) self.assertEqual(c.chars[0][0], 1)
def test_unset_nonempty(self): c = Canvas() c.set(0, 0) c.set(0, 1) c.unset(0, 1) self.assertEqual(c.chars[0][0], 1)
def test_unset_empty(self): c = Canvas() c.set(1, 1) c.unset(1, 1) self.assertEqual(len(c.chars), 0)
def test_unset_nonempty(self): c = Canvas() c.set(1, 1) c.set(2, 1) c.unset(1, 1) self.assertEqual(c.pixels, {1:{2: 2}})
def test_unset_empty(self): c = Canvas() c.set(1, 1) c.unset(1, 1) self.assertEqual(c.pixels, dict())
except: print("could not read pixel") #totals that rgb per ppd x ppd area tr = tr + r tg = tg + g tb = tb + b #averages tr = tr / ( ppd * ppd ) tg = tg / ( ppd * ppd ) tb = tb / ( ppd * ppd ) sum = (tr + tg + tb) / 3 #python doesn't have bools, it's like see where 0 is false and anything else is true if (dither or trippy) : #because you can't divide by zero if (sum == 0) : canvo.unset(x,y) else: #the RGB scale is exponential , so the ratio of light from 255 to 80 would be 255^2/80^2 # however since the image is 3 dimensional, then the dither turns on in 1/mod * 1/mod # so mod should be 255/80 instead mod = int(255 / sum) # the ratio here is (2x-1)/x^2 where x is 255/sum if (trippy) : if (((x % mod) == 0) or ((y % mod) == 0)) : canvo.set(x,y) else: canvo.unset(x,y) #ratio is 1/x^2 elif (dither) : if (((x % mod) == 0) and ((y % mod) == 0)) : canvo.set(x,y)