def __init__(self, width, height): self.config = config self.width = width self.height = height self.la = LinearAlgebra() self.id = 0
def __init__(self, width, height): self.width = width self.height = height self.la = LinearAlgebra() self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfileSimpleSmooth with name [%s]" % self.name)
def __init__(self, config): self.config = config self.width = self.config["width"] self.height = self.config["height"] self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfile with name [%s]" % self.name)
def __init__(self, width, height): self.width = width self.height = height self.diagonal = (self.width**2 + self.height**2)**0.5 self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfileCreepyCircles with name [%s]" % self.name)
def __init__(self, width, height): self.config = config self.width = width self.height = height self.la = LinearAlgebra() self.id = 0 away = 100 self.point_a = LAPoint([-away, -away]) # top left self.point_b = LAPoint([self.width + away, 0 + away]) # top right self.point_c = LAPoint([-away, self.height + away]) # bottom left self.point_d = LAPoint([self.width + away, self.height + away]) # bottom right
class PyGradienterProfile(): def __init__(self, config): self.config = config self.width = self.config["width"] self.height = self.config["height"] self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfile with name [%s]" % self.name) def generate_nodes(self): # Create N random nodes on the image for _ in range(4): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.randint(0, self.config["width"]), random.randint(0, self.config["height"]), ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint( 0, 255 ), random.randint( 0, 255 ), random.randint( 0, 255 ), 255 ], 1 ) yield next_node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y # point = LAPoint( [ x, y ] ) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b # return [r, g, b, a] def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [0, 0, 0, 255] minimum_distance = min(distances) if minimum_distance < 50: this_pixel[0] = 255 if minimum_distance < 100: this_pixel[1] = 255 if minimum_distance < 200: this_pixel[2] = 255 return this_pixel
class PyGradienterProfileParticles(): def __init__(self, width, height): self.config = config self.width = width self.height = height self.la = LinearAlgebra() self.id = 0 def generate_nodes(self): random.seed(self.id) self.random_exponent = random.uniform(0.2, 2.4) # White note at the center next_node = LAPointNode( # Position [ width // 2, height // 2, ], [ # Pixel color based on the minimum and maximum pixel colors for each channel 255, 255, 255, 255 ], 1) yield next_node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y # point = LAPoint([x, y]) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b # return [r, g, b, a] def proportion(self, a, b, c): # a - b # c - x # x = b*c/a return b * c / a def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [255, 255, 255, 0] transparent = self.proportion(self.width / 2, 1, sum(distances)) transparent = transparent**self.random_exponent transparent *= 255 if transparent > 255: transparent = 255 this_pixel[3] = 255 - transparent return this_pixel
class PyGradienterProfileFabric(): def __init__(self, config): self.config = config self.width = self.config["width"] self.height = self.config["height"] self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfileFabric with name [%s]" % self.name) def generate_nodes(self): random.seed(self.id) min_stretch = 10 max_stretch = 20 self.noise_red = Noise() self.noise_red.new_simplex(random.randint(min_stretch, max_stretch), random.randint(min_stretch, max_stretch), self.id + 1) self.noise_green = Noise() self.noise_green.new_simplex(random.randint(min_stretch, max_stretch), random.randint(min_stretch, max_stretch), self.id + 2) self.noise_blue = Noise() self.noise_blue.new_simplex(random.randint(min_stretch, max_stretch), random.randint(min_stretch, max_stretch), self.id + 3) # Create N random nodes on the image for _ in range(2): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.randint(0, self.config["width"]), random.randint(0, self.config["height"]), ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255 ], 1) yield next_node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y x = x * math.sin(x / 2)**4 y = y * math.cos(y / 2)**4 y += math.sin(x) * 20 # point = LAPoint([x, y]) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b # Apply some shading to black r *= math.sin((x + (self.noise_red.get_simplex2d(x, y) * 10)) / self.width) * 0.5 + math.cos(y / self.height) * 0.5 g *= math.sin((x + (self.noise_green.get_simplex2d(x, y) * 10)) / self.width) * 0.5 + math.cos(y / self.height) * 0.5 b *= math.sin((x + (self.noise_blue.get_simplex2d(x, y) * 10)) / self.width) * 0.5 + math.cos(y / self.height) * 0.5 r += self.noise_red.get_simplex2d(x, y) * 2 g += self.noise_green.get_simplex2d(x, y) * 2 b += self.noise_blue.get_simplex2d(x, y) * 2 return [r, g, b, a] def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [0, 0, 0, 0] for node_index, distance in enumerate(distances): for c in range(4): this_pixel[c] += distance * nodes[node_index].color[c] * nodes[ node_index].intensity sum_distances = sum(distances) this_pixel = [x / sum_distances for x in this_pixel] return this_pixel
class PyGradienterProfileMushyColorful(): def __init__(self, width, height): self.config = config self.width = width self.height = height self.la = LinearAlgebra() self.id = 0 away = 100 self.point_a = LAPoint([-away, -away]) # top left self.point_b = LAPoint([self.width + away, 0 + away]) # top right self.point_c = LAPoint([-away, self.height + away]) # bottom left self.point_d = LAPoint([self.width + away, self.height + away]) # bottom right def generate_nodes(self): close = 0.8 # Create N random nodes on the image for _ in range(2): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.choice( random.choice([ range(int(-self.width), int(-close**self.width)), range(int( (2 - close) * self.width), int(2 * self.width)) ])), random.choice( random.choice([ range(int(-self.height), int( -close * self.height)), range(int((2 - close) * self.height), int(2 * self.height)) ])) ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint(100, 255), random.randint(100, 255), random.randint(100, 255), 255 ], 1) yield next_node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y # point = LAPoint([x, y]) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b r *= math.tanh(math.pi - abs( self.la.angle_between_three_points(self.point_a, LAPoint([x, y]), self.point_b))) g *= math.tanh(math.pi - abs( self.la.angle_between_three_points(self.point_b, LAPoint([x, y]), self.point_c))) b *= math.tanh(math.pi - abs( self.la.angle_between_three_points(self.point_c, LAPoint([x, y]), self.point_d))) # return [r, g, b, a] def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [0, 0, 0, 0] for node_index, distance in enumerate(distances): for c in range(4): this_pixel[c] += distance * nodes[node_index].color[c] * nodes[ node_index].intensity sum_distances = sum(distances) this_pixel = [x / sum_distances for x in this_pixel] return this_pixel
class PyGradienterProfileSimple(): def __init__(self, width, height): self.config = config self.width = width self.height = height self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfileSimple with name [%s]" % self.name) def generate_nodes(self): random.seed(uuid.uuid4()) # Create N random nodes on the image for _ in range(2): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.randint(0, width), random.randint(0, height), ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255 ], 1) yield next_node def calculate_distance_between_nodes(self, point, node): point = LAPoint([point[0], point[1]]) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] return [r, g, b, a] def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [0, 0, 0, 0] for node_index, distance in enumerate(distances): for c in range(4): this_pixel[c] += distance * nodes[node_index].color[c] * nodes[ node_index].intensity sum_distances = sum(distances) this_pixel = [x / sum_distances for x in this_pixel] return this_pixel
class PyGradienterProfileTemplate(): def __init__(self, config): self.config = config # Get some basic info self.width = self.config["width"] self.height = self.config["height"] # Build a LinearAlgebra object self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfile with name [%s]" % self.name) def generate_nodes(self): # Create N random nodes on the image for _ in range(2): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.randint(0, self.config["width"]), random.randint(0, self.config["height"]), ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255 ], 1) yield next_node # Calculate this point's distance to that node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y # point = LAPoint([x, y]) return self.la.distance(point, node) # On the final pixel, apply this transformation def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b # return [r, g, b, a] # Here you bias the colors based on the distance to a node and its colors # This default one multiplies the distance to a node and its colors # then divides this "biased" list by the sum of the distances for a # averaged distance - color final pixel def get_pixel_by_distances_and_nodes(self, distances, nodes): # Start with a black pixel this_pixel = [0, 0, 0, 0] # For each (ordered) distance for node_index, distance in enumerate(distances): # For each color for c in range(4): # This color is the distance multiplied by that color node's color this_pixel[c] += distance * nodes[node_index].color[c] * nodes[ node_index].intensity # Divide by sum(distances) to calculate the final bias this_pixel = [x / sum(distances) for x in this_pixel] return this_pixel
class PyGradienterProfileCreepyCircles(): def __init__(self, width, height): self.width = width self.height = height self.diagonal = (self.width**2 + self.height**2)**0.5 self.la = LinearAlgebra() self.id = 0 self.name = os.path.basename(__file__).replace(".py", "") print("Starting PyGradienterProfileCreepyCircles with name [%s]" % self.name) def generate_nodes(self): random.seed(uuid.uuid4()) if random.randint(1, 2) == 1: self.subtract_one_from_darkness_bias = True else: self.subtract_one_from_darkness_bias = False # Create N random nodes on the image for _ in range(random.randint(1, 4)): # Create a random Node object with our input next_node = LAPointNode( # Position [ random.randint(0, self.width), random.randint(0, self.height), ], [ # Pixel color based on the minimum and maximum pixel colors for each channel random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 255 ], 1) yield next_node def calculate_distance_between_nodes(self, point, node): x = point[0] y = point[1] # Make changes on X and Y # point = LAPoint([x, y]) return self.la.distance(point, node) def pixel_color_transformations(self, rgb, x, y, distances): r = rgb[0] g = rgb[1] b = rgb[2] a = rgb[3] # Make changes on r, g, b mind = min(distances) if mind == 0: mind = 1 r = (255 * ((math.sin((mind / 20))) / 2 + 0.5)) g = (255 * ((math.sin((mind / 20) + 2 * math.pi / 3)) / 2 + 0.5)) b = (255 * ((math.sin((mind / 20) + 4 * math.pi / 3)) / 2 + 0.5)) darkness_bias = (mind / (self.diagonal * 0.7)) if self.subtract_one_from_darkness_bias: darkness_bias = 1 - darkness_bias if darkness_bias < 0: darkness_bias = 0 r *= darkness_bias g *= darkness_bias b *= darkness_bias # return [r, g, b, a] def get_pixel_by_distances_and_nodes(self, distances, nodes): this_pixel = [0, 0, 0, 0] for node_index, distance in enumerate(distances): for c in range(4): this_pixel[c] += distance * nodes[node_index].color[c] * nodes[ node_index].intensity sum_distances = sum(distances) this_pixel = [x / sum_distances for x in this_pixel] return this_pixel