jasonlong / geo_pattern

Create beautiful generative geometric background images from a string.
http://jasonlong.github.io/geo_pattern/
MIT License
1.25k stars 88 forks source link

Extend the API #47

Closed maxmeyer closed 6 years ago

maxmeyer commented 9 years ago

Based on the work done in #46 we could extend the GeoPattern-api "a bit". If I look at the :color and the :base_color-options I ask myself, what they really stand for. From my point of view it's more some like

# use color as base_color
GeoPattern.generate('string', color: '#afafaf', color_mode: :base_color)

# use color as color (default)
GeoPattern.generate('string', color: '#afafaf', color_mode: :color)

If we change the api like this, we could add some more color generators easily, like :inverse. If we allow the use of multiple colors in :color we could also support something like :substract. If we use a similar algorithm :seed we use for the PatternGenerators we could also support more than two colors. Maybe should also use :colors instead of :color. This would make it easier to implement it.

For the time being I would support the old options as well, but would deprecate them.

Internally we could use a ColorModeStore, a ColorModeSive and use the same development "pattern" we used for the StructureGenerators.

If we go further, we could also support :background_mode with :solid (default) and maybe :linear_gradient.

@jasonlong @ttaylor What do you think about that?

@jasonlong If you're willing to accept such a PR I can put together the code for that.

jasonlong commented 9 years ago

Interesting ideas @maxmeyer. color and base_color aren't meant to be used together, so something like this would deal with that. I think we'd need to think of a clearer naming convention for the color mode (color and base_color still seem confusing in that context), but I see where you're going. The only part I think would be a no-go would be the gradient idea since these are these are repeating tiles and a repeating gradient would look janky.

My biggest thing is that I'd like to keep the simplest case in tact – where a user can just pass a string and maybe a color or base color and get the same pattern they get today. If we can come up with a clean way of making fancier patterns w/o cluttering the basic use case, I'm all for experimenting with it.

maxmeyer commented 9 years ago

My biggest thing is that I'd like to keep the simplest case in tact

I think that this is possible with reasonable defaults.

The only part I think would be a no-go would be the gradient idea since these are these are repeating tiles and a repeating gradient would look janky.

Ok. This was the thing which came into my mind first. :)

I will try and put together a PR.

jasonlong commented 6 years ago

Closing this for now.