Ejemplo n.º 1
0
def doodle3_fun():
    d = [
        ag.rectangle(start=(0.2, 1.2), w=2.6, h=0.6),
        ag.rectangle(start=(1.2, 0.2), w=0.6, h=1.6),
    ]
    ag.set_style(d, "fill", "blue")
    return d
Ejemplo n.º 2
0
def doodle2_fun():
    d = [
        ag.Circle(c=(0.5, 0.5), r=0.45),
        ag.Circle(c=(1, 0.5), r=0.45),
        ag.Circle(c=(1.5, 0.5), r=0.45),
    ]
    ag.set_style(d, "fill", "red")
    return d
Ejemplo n.º 3
0
import os
import algoraphics as ag

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

c = ag.Canvas(400, 400)

###########
# Shadows #
###########

x = [
    ag.Circle(c=(100, 150), r=50, stroke="#FFDDDD"),
    ag.Circle(c=(150, 100), r=50, stroke="#DDDDFF"),
]
ag.set_style(x, "stroke-width", 20)
ag.add_shadows(x, stdev=20, darkness=0.5)

y = [[
    ag.Circle(c=(300, 250), r=50, fill="#FFDDDD"),
    ag.Circle(c=(250, 300), r=50, fill="#DDDDFF"),
]]
# ag.add_paper_texture(y)

# Note that add_shadows adds shadows to the immediate list elements as
# wholes, meaning the top circle should not project a shadow onto the
# one behind it.
ag.add_shadows(y, stdev=20, darkness=0.5)

c.add(x, y)
c.png("png/textures1.png")
Ejemplo n.º 4
0
#############
# Hazy text #
#############

pts = ex.text_points("abcdefg", height=50, pt_spacing=1 / 4, char_spacing=0.15)
points = [ag.Translation(p, (20, 250)) for p in pts]
points = [
    ag.Move(p, direction=ag.Uniform(0, 360), distance=ag.Uniform(0, 10)) for p in points
]
x1 = []
for p in points:
    radius = 0.5 * np.sqrt(10 - p.distance.state())
    x1.append(ag.Circle(c=p, r=radius))
# ag.reposition(x1, (w / 2, h - 100), "center", "top")
ag.set_style(x1, "fill", "green")

pts = ex.text_points("hijklm", height=50, pt_spacing=1 / 4, char_spacing=0.15)
points = [ag.Translation(p, (20, 100)) for p in pts]
points = [
    ag.Move(p, direction=ag.Uniform(0, 360), distance=ag.Uniform(0, 10)) for p in points
]
x2 = []
for p in points:
    radius = 0.5 * np.sqrt(10 - p.distance.state())
    x2.append(ag.Circle(c=p, r=radius))
# ag.reposition(x2, (w / 2, h - 250), "center", "top")
ag.set_style(x2, "fill", "green")

c.new(x1, x2)
c.png("png/text3.png")
Ejemplo n.º 5
0
import algoraphics.extras as ex

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

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

###################################
# Straight-line maze-like pattern #
###################################

outline = ag.rectangle(bounds=(0, 0, w, h))
x = ex.fill_maze(outline,
                 spacing=20,
                 style=ex.Maze_Style_Straight(rel_thickness=0.2))
ag.set_style(x.members, "fill", "blue")

c.add(x)
c.png("png/mazes1.png")

##################################
# Jagged-width maze-like pattern #
##################################

outline = ag.rectangle(bounds=(0, 0, w, h))
x = ex.fill_maze(outline,
                 spacing=20,
                 style=ex.Maze_Style_Jagged(min_w=0.2, max_w=0.8))
ag.set_style(x.members, "fill", "blue")

c.new(x)
Ejemplo n.º 6
0
def doodle1_fun():
    d = ag.Circle(c=(0.5, 0.5), r=0.45)
    ag.set_style(d, "fill", "green")
    return d
Ejemplo n.º 7
0
    x.append(ex.tentacle(backbone, width=15))
ag.set_styles(x, "fill", ag.Color(ag.Uniform(min=0.6, max=0.75), 1, 0.5))

c.new(x)
c.png("png/structures3.png")

################################################
# Blow-paint effects (polygon, line, and spot) #
################################################

pts1 = [(50, 50), (50, 100), (100, 70), (150, 130), (200, 60)]
x1 = ex.blow_paint_area(pts1)

pts2 = [(250, 50), (350, 50), (300, 200)]
x2 = ex.blow_paint_area(pts2, spacing=20, length=20, len_dev=0.4, width=8)
ag.set_style(x2, "fill", "orange")

pts3 = [(50, 300), (100, 350), (200, 250), (300, 300)]
y = ex.blow_paint_line(pts3,
                       line_width=8,
                       spacing=15,
                       length=30,
                       len_dev=0.4,
                       width=6)
ag.set_style(y, "fill", "red")

z = ex.blow_paint_spot((350, 350), length=20)
ag.set_style(z, "stroke", "blue")

c.new(x1, x2, y, z)
c.png("png/structures4.png")
Ejemplo n.º 8
0
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)

c.new(x)
c.png("png/images2.png")

####################################
# Image segments with pattern fill #
####################################

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 i, outline in enumerate(x):
    color = ex.region_color(outline, image)
    maze = ex.Maze_Style_Pipes(rel_thickness=0.6)