Brush Patterns Feature #23

Closed
opened 2020-04-19 21:28:30 +00:00 by kirsle · 0 comments

This is an idea how to implement patterned brushes for drawing levels in Doodle.

Instead of each palette being just a simple solid color (red, black, blue) a palette swatch could have a "pattern" image associated to it.

A pattern could be a small, tile-able image (say 32x32 pixels). When a pixel is plotted in the level, it would sample the pattern image to pick the color for the pixel instead of just setting a simple color.

The pixel sampling algorithm would be:

  • Take the world coordinate of the pixel to be filled in (i.e. (1200,1234))
  • Modulo it by the size of the pattern image (1200 % 32, 1234 % 32)
  • The color of that pixel in the pattern is used for the pixel in the world.

Importantly, the color choice is handled dynamically, not hard-set in the level data; the level data just says, "the palette swatch with pattern X.png has a pixel set at world coordinate X,Y" and the color is computed as it's being rendered (and the chunk cached to image as normal).

Possible applications of this are:

  • Easy to add a "pencil graphite texture"
  • Colorful textures like wood, sand, stone, etc. could be used.

A possible "mode" of the pattern could combine the swatch Color with the greyscale pattern so it can be applied to any color. For example the "pencil graphite texture" would be a grayscale image and a black, red, or blue swatch color would be able to use it.


Data attributes to be added to a palette swatch:

  • Pattern (string): filename of the pattern, like "graphite.png", handled similarly to wallpapers.
  • PatternMode (enum): two options, image uses the pattern pixels directly (the Color attribute not used) or grayscale uses a grayscale pattern to mix with the swatch color (e.g. for pencil graphite mode).

When Doodle supports embedding assets inside level files, the user can attach a custom pattern image and otherwise it will use the built-in patterns.

This is an idea how to implement patterned brushes for drawing levels in Doodle. Instead of each palette being just a simple solid color (red, black, blue) a palette swatch could have a "pattern" image associated to it. A pattern could be a small, tile-able image (say 32x32 pixels). When a pixel is plotted in the level, it would sample the pattern image to pick the color for the pixel instead of just setting a simple color. The pixel sampling algorithm would be: * Take the world coordinate of the pixel to be filled in (i.e. `(1200,1234)`) * Modulo it by the size of the pattern image (`1200 % 32, 1234 % 32`) * The color of that pixel in the pattern is used for the pixel in the world. Importantly, the color choice is handled **dynamically**, not hard-set in the level data; the level data just says, "the palette swatch with pattern X.png has a pixel set at world coordinate X,Y" and the color is computed as it's being rendered (and the chunk cached to image as normal). Possible applications of this are: * Easy to add a "pencil graphite texture" * Colorful textures like wood, sand, stone, etc. could be used. A possible "mode" of the pattern could combine the swatch Color with the greyscale pattern so it can be applied to any color. For example the "pencil graphite texture" would be a grayscale image and a black, red, or blue swatch color would be able to use it. ----- Data attributes to be added to a palette swatch: * Pattern (string): filename of the pattern, like "graphite.png", handled similarly to wallpapers. * PatternMode (enum): two options, **image** uses the pattern pixels directly (the Color attribute not used) or **grayscale** uses a grayscale pattern to mix with the swatch color (e.g. for pencil graphite mode). When Doodle supports embedding assets inside level files, the user can attach a custom pattern image and otherwise it will use the built-in patterns.
kirsle added the
enhancement
label 2020-04-19 21:28:30 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#23
There is no content yet.