Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds some extra options to eggbot_hatch. #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Adds some extra options to eggbot_hatch. #57

wants to merge 1 commit into from

Conversation

javl
Copy link

@javl javl commented Aug 30, 2016


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).

selection_238

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 the effect() 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).

usefull 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
and gray elements can use any value in between. This allows for
the creation of some nice effects.
@oskay
Copy link
Contributor

oskay commented Aug 30, 2016

I think that it's a clever idea to have an option like this. I don't think that I've ever seen a suggestion to do something quite like this.

I do have some concerns:

  • This adds complexity to the GUI, both on the main screen and on the descriptions. Perhaps this (and a couple of the other options) should be relegated to an "advanced" tab, which could have some less commonly used options.
  • The definition of "brightness" is a tricky subject. There are many ways of styling an SVG file, including using CSS styles that are defined over the full document, and locally defined brightness on individual objects. Adding a feature that cares what the color is means that we now need to be able to pick that out... and may in may fail in some circumstances that the existing version would work in.
    Some testing is called for.
  • If you call this on an object with a gradient fill, it will crash when trying to calculate the brightness.
  • I do not immediately see the reason to have an angle as a function of brightness. I could imagine a few similar things-- like giving all matched-brightness groups the same angle, or perhaps giving each object a random hatch angle.
  • If the angle option is included, perhaps it should have a separate checkbox to enable it.

On note 1: If you have any whitespace edits or other "small random changes" (that are improvements) to contribute, please separate these out and submit a separate pull request for them.

On note 2: Yup. That's python.

@javl
Copy link
Author

javl commented Aug 30, 2016

Sorry, I guess this should have been more of a 'check out this beta feature' thing than a pull request.

To respond to your points

  • This was the first time I did anything with a Inkscape plugin, so for me just changing what was already there was the easiest way to get it to work. Moving the settings to their own tab would indeed be cleaner.
  • I ran into this problem myself just now, with a file that was styled in a different way, so yeah, the way of getting the values should be more fool-proof. Also, I called it brightness but the way I use it myself is basically with grayscales, so "bright" is white and "less bright" is more towards black. I don't use light blue vs. dark red or things like that.
  • I didn't check with gradients. So yeah, buggy beta stuff indeed ;)
  • Going from a grayscale value to an angle can give really nice optic effects. The following image was generated using a lot of small triangles. The further they we're from the bottom of the image, the whiter they became. By combining the spacing and angle ranges you can get optical effects that look amazing when plotted. I really think this is one of those things where you're not quite sure how it will be used, but with the right circumstances can give amazing results.
  • You can 'disable' a range by using the same values for its min and max.

selection_240

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