Skip to content

Cells effect#1589

Merged
cameronwhite merged 23 commits into
PintaProject:masterfrom
Lehonti:feature/cells_effect
Jul 5, 2025
Merged

Cells effect#1589
cameronwhite merged 23 commits into
PintaProject:masterfrom
Lehonti:feature/cells_effect

Conversation

@Lehonti

@Lehonti Lehonti commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

I stumbled upon the term "Worley noise", and found that it's the same basic idea as the Voronoi diagram, except that the color of the location varies depending on the distance to the closest control point.

image

When I googled it, I immediately mapped its appearance to the "cellular" filter from Jerry Huxtable (http://www.jhlabs.com/ip/filters/CellularFilter.html). I used a similar name, but my implementation is actually completely independent, and based on the Voronoi diagram code we already had.

The various customization options (and very notably the "Color Scheme Edge Behavior" option and the customizable gradients option) allow us to obtain other results that look very different from the default one and from each other too

cells7

cells9

image

@cameronwhite

Copy link
Copy Markdown
Member

This is very fun to use :)

A couple small thoughts on parameters:

  • Perhaps Reverse Color Scheme should be off by default? When I switched to Selected Colors I thought it was doing the wrong thing until I noticed that parameter.
  • Maybe Random Point Locations should move up near the Number of Cells / Cell Radius since it's closely related to those?

}
}

public static ImmutableHashSet<PointI> CreateControlPoints (RectangleI roi, int pointCount, RandomSeed pointLocationsSeed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be an argument for putting this in the Sampling class, with a different name. This function is producing randomly sampled points within a region, so it's related to the other function which producing uniformly distributed samples within a pixel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name to CreateCellControlPoints in 62b92fc and moved the method to Sampling in 06c9328. However, I wouldn't consider them samples.

I reverted this last one on c2ca1ec, which you could keep if you want the method in SpatialPartition or discard if you want it in Sampling.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think I'm okay with it staying in SpatialPartition for now until there's another use for it in the future

Comment thread Pinta.Effects/Effects/CellsEffect.cs Outdated
@Lehonti

Lehonti commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

@cameronwhite regarding the Reverse Color Scheme issue you mentioned, I think it's debatable whether the primary color should be at the center of the cell or on the outside. I would think that the primary color is what one draws the cell with, but it makes sense too as a background color.

Regardless, I changed the default to false (and the related tests) in 628fd6b, which you coud keep or discard as desired.

@cameronwhite

Copy link
Copy Markdown
Member

Thanks, I think false makes the most sense as a default so that the cells are drawn with the primary color 👍

@cameronwhite cameronwhite merged commit d8ef562 into PintaProject:master Jul 5, 2025
6 checks passed
@cameronwhite cameronwhite added this to the 3.1 milestone Jul 5, 2025
@Lehonti Lehonti deleted the feature/cells_effect branch July 5, 2025 06:02
@Lehonti

Lehonti commented Jul 5, 2025

Copy link
Copy Markdown
Contributor Author

That's great @cameronwhite, but setting it to false by default does the opposite. If you look at the Cells1 test you will see that the background is black (which is the primary color in the mock palette) and the cells are white (which is the secondary color in the mock palette).

@cameronwhite

Copy link
Copy Markdown
Member

In my testing this was working as expected when using Pinta's palette:

Screenshot 2025-07-05 at 11 25 16 PM

But I think that unit test would be defaulting to the preset "Black and White" gradient, which seems to actually go from white to black?

@Lehonti

Lehonti commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

Great point @cameronwhite it somehow escaped me that the default ColorSchemeSource is PresetGradients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants