Exemple #1
0
import os
import numpy as np
import algoraphics as ag
import algoraphics.extras as ex

os.chdir(os.path.dirname(os.path.abspath(__file__)))

w, h = 400, 400
c = ag.Canvas(w, h)

#################
# Splatter text #
#################

color = ag.Color(hue=ag.Uniform(0, 0.15), sat=0.8, li=0.5)

points = ex.text_points("ABCDEFG", 50, pt_spacing=0.5, char_spacing=0.15)
ag.jitter_points(points, 2)
points = [ag.Translation(p, (20, 300)) for p in points]
x1 = [ag.Circle(c=p, r=ag.Exponential(2.2, stdev=1)) for p in points]
ag.set_styles(x1, "fill", color)
c.new(ag.shuffled(x1))

points = ex.text_points("HIJKLM", 50, pt_spacing=0.5, char_spacing=0.15)
ag.jitter_points(points, 2)
points = [ag.Translation(p, (20, 200)) for p in points]
x2 = [ag.Circle(c=p, r=ag.Exponential(2.2, stdev=1)) for p in points]
ag.set_styles(x2, "fill", color)
c.add(ag.shuffled(x2))

points = ex.text_points("0123456789", 50, pt_spacing=0.5, char_spacing=0.15)
Exemple #2
0
import os
import algoraphics as ag
import algoraphics.extras as ex

os.chdir(os.path.dirname(os.path.abspath(__file__)))

c = ag.Canvas(400, 400)

#########
# Waves #
#########

# n_waves = 100
# x = []
# for d in (1 + np.arange(n_waves)) / n_waves:
#     wav = ag.wave(start=(200, 200), direction=d * 360, width=d * 20,
#                   period=1 + d * 30, length=1 + d * 180)
#     ag.set_style(wav, 'stroke', (d, 1, 0.5))
#     ag.set_style(wav, 'stroke-width', d * 2)
#     x.append(wav)

# ag.write_SVG(x, w, h, 'svg/shapes1.svg')
# ag.to_PNG('svg/shapes1.svg', 'png/shapes1.png')

######################################
# Wobble (make edges a little messy) #
######################################

x = []
x.append(ag.Circle(c=(100, 100), r=80))
x.append(ag.Line(p1=(200, 30), p2=(250, 170)))
Exemple #3
0
import algoraphics as ag
import algoraphics.extras as ex

os.chdir(os.path.dirname(os.path.abspath(__file__)))

#####################################
# Objects colored by sampling image #
#####################################

image = ex.open_image("test_images.jpg")
ex.resize_image(image, 800, None)
w, h = image.size
x = ex.tile_canvas(w, h, shape="polygon", tile_size=100)
ex.fill_shapes_from_image(x, image)

c = ag.Canvas(image.width, image.height)
c.add(x)
c.png("png/images1.png")

#####################################
# Image segments colored from image #
#####################################

image = ex.open_image("test_images.jpg")
ex.resize_image(image, 800, None)
w, h = image.size
x = ex.image_regions(image, smoothness=3)
for outline in x:
    color = ex.region_color(outline, image)
    ag.set_style(outline, "fill", color)