Adds some extra options to eggbot_hatch. #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please see the additional notes below
These changes are especially useful when working with generated content that has a lot of elements you don't want to have to alter one-by-one.
First is the option to delete the original object that was hatched. This allows you to only plot the newly made hatched fill, not the outline of the original object.
Second is an option to use ranges for the hatchAngle and hatchSpacing variables. For each element it's brightness is calculated (0.1-1.0, where 0.0 is a black element and 1.0 is a white one) and this brightness is then mapped to the range. So if you select 0 to 30 for your angle range, black elements will use 0 degrees, white elements will use 30 degrees and gray elements can use any value in between. This allows for the creation of some nice effects.
The hatches in the attached image were created in a single pass (instead of 6).
Note 1: The small random changes changes here and there are because of my text editor automatically removing trailing spaces. These changes shouldn't give any problems.
Note 2: Github shows a lot of changes because of the indent needed to move a lot of existing code into in
for...in
loop. Basically the only change has been made at the top of theeffect()
function.For each element its brightness is calculated and its id gets moved into a dict with all other elements that have the same brightness. Then, instead of applying the hatch code to all elements, it is applied to each group of elements so the angle and spacing can be changed based on the needed value. The hatching itself has not been changed (everything below line
1233: # Build a grid of possible hatch lines
is the same, just indented).