diff options
author | Thomas Jourdan <b.vehikel@googlemail.com> | 2010-01-09 21:24:55 (GMT) |
---|---|---|
committer | Thomas Jourdan <b.vehikel@googlemail.com> | 2010-01-09 21:24:55 (GMT) |
commit | 8d8009ea73b77fc37c165462b21a342fb3614416 (patch) | |
tree | d11735b60966666f7f180874f4ca6a167fc585e1 /ep_layer_markovchain.py | |
parent | 9840852aca167c25c979fa08a23bc0fc623b680e (diff) |
Themes and categories for stamps.
Diffstat (limited to 'ep_layer_markovchain.py')
-rw-r--r-- | ep_layer_markovchain.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/ep_layer_markovchain.py b/ep_layer_markovchain.py index b1a8aed..c434256 100644 --- a/ep_layer_markovchain.py +++ b/ep_layer_markovchain.py @@ -74,7 +74,7 @@ class MarkovChainLayer(model_layer.Layer): stamp_factory = ka_factory.get_factory('stamp') stamp_key = stamp_factory.keys()[0] - self.stamp = stamp_factory.create(stamp_key, self.path) + self.stamp = stamp_factory.create(stamp_key, self.path, self.states) def dot(self): result = "" @@ -154,7 +154,6 @@ class MarkovChainLayer(model_layer.Layer): and self.states == other.states \ and self.sampler == other.sampler \ and self.stamp == other.stamp -# and self.number_of_tiles == other.number_of_tiles \ if equal: for cix, cell_color in enumerate(self.cell_colors): equal = equal and cell_color == other.cell_colors[cix] @@ -186,7 +185,7 @@ class MarkovChainLayer(model_layer.Layer): stamp_factory = ka_factory.get_factory('stamp') stamptype_constraint = cpool.get(self, STAMPTYPE_CONSTRAINT) self.stamp = stamp_factory.create_random(stamptype_constraint, - self.path) + self.path, self.states) self.stamp.randomize() def mutate(self): @@ -232,12 +231,10 @@ class MarkovChainLayer(model_layer.Layer): new_one = MarkovChainLayer(self.get_trunk()) cross_sequence = self.crossingover_base(new_one, other, \ 2 + len(self.cell_colors)) -# new_one.number_of_tiles = self.number_of_tiles \ -# if cross_sequence[0] else other.number_of_tiles new_one.sampler = model_random.crossingover_elem(self.sampler, - other.sampler) + other.sampler) new_one.stamp = model_random.crossingover_elem(self.stamp, - other.stamp) + other.stamp) if cross_sequence[1]: probability = self.probability @@ -266,16 +263,14 @@ class MarkovChainLayer(model_layer.Layer): """ self.begin_render(ctx, width, height) dw, dh = self.sampler.get_sample_extent() - self.stamp.set_extent(dw, dh) + self.stamp.set_stamp_extent(dw, dh) cell_rand = random.Random(self.random_seed) cell_state = 0 for point in self.sampler.get_sample_points(): rgba = self.cell_colors[cell_state].rgba ctx.set_source_rgba(rgba[0], rgba[1], rgba[2], rgba[3]) - self.stamp.render(ctx, (point[0]-0.5, point[1]-0.5), - state=cell_state) + self.stamp.render(ctx, (point[0]-0.5, point[1]-0.5), cell_state) cell_state = self._next_state(cell_state, cell_rand) -# cell_state = (cell_state+1) % len(self.cell_colors) def _next_state(self, cell_state, cell_rand): next_cell_state = self.states-1 @@ -311,7 +306,6 @@ class MarkovChainLayer(model_layer.Layer): new_one = MarkovChainLayer(self.get_trunk()) self.copy_base(new_one) new_one.states = self.states -# new_one.number_of_tiles = self.number_of_tiles new_one.cell_colors = [None] * self.states for cix in range(len(self.cell_colors)): new_one.cell_colors[cix] = self.cell_colors[cix].copy() |