Skip to content

color transformations #16

@anandology

Description

@anandology

Right now we can apply transformations on shapes, but there no way to generate patterns in color.

It would be nice to be able to specify a color range to repeat.

How about this?

c1 = color(r=255, g=0, b=0, a=0.5)
c2 = color(r=0, g=255, b=0, a=0.5)

ellipse() | repeat(36, rotate(10), fill=color_range(c1, c2), stroke="none")

This would apply colors from red to green to all the shapes.

The fill and stoke can also take a list of colors and it would cycle over the colors.

circle(x=100, y=0, r=25) | repeat(12, rotate(30), fill=['red', 'black'])

The same API could be applied to the combine function, which takes a list of shapes and converts into a single shape.

n = 6
d = 300/n
r = d/2
shapes = [circle(x=-150+r+i*d, y=0, r=r) for i in range(n)]
shape = combine(shapes, fill=['red', 'black'])
show(shape)

@amitkaps what do you think?

@vsrigayatri do you have any comments?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions