From f2627f5096ed7763db83f37f595a9a51b041dc84 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Tue, 21 May 2024 18:26:17 -0700 Subject: [PATCH] Rename hash_to_matrix to matricize Signed-off-by: Alek Ratzloff --- colorhash/__main__.py | 2 +- colorhash/matricizer.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/colorhash/__main__.py b/colorhash/__main__.py index 99cc44e..763ff0e 100644 --- a/colorhash/__main__.py +++ b/colorhash/__main__.py @@ -64,6 +64,6 @@ colorizer = PaletteColorizer(palette) # pprint.pprint([[hex(c) for c in row] for row in colors]) # Print SVG -matrix = NibbleMatricizer(w, h).hash_to_matrix(hashdata) +matrix = NibbleMatricizer(w, h).matricize(hashdata) colors = PaletteColorizer(palette).colorize(matrix) print(gensvg(colors, 32)) diff --git a/colorhash/matricizer.py b/colorhash/matricizer.py index 1a0334e..6713046 100644 --- a/colorhash/matricizer.py +++ b/colorhash/matricizer.py @@ -11,14 +11,14 @@ class Matricizer(metaclass=abc.ABCMeta): self.h = h @abc.abstractmethod - def hash_to_matrix(self, data: bytes) -> Matrix: + def matricize(self, data: bytes) -> Matrix: """ Convert a hash to a matrix of given width and height. """ class NibbleMatricizer(Matricizer): - def hash_to_matrix(self, data: bytes) -> Matrix: + def matricize(self, data: bytes) -> Matrix: """ Convert a set of bytes to a list of rows of nibbles. """ @@ -43,3 +43,7 @@ class NibbleMatricizer(Matricizer): row = [] return cols + + +class PerlinMatricizer(Matricizer): + pass