You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Add feature] Change brightness based on color segment in rendering #22
I would suggest to add a function to render the pen according both the name of layer and the color of the pen.
So for example, if you choose to have a red layer "#red":
black pen will give a dark red colour;
grey pen will give the colour you chose;
white pen will give a light red coulor.
To achieve this I have added some code in render.py
This function is used to get darker or lighter a color: Bleach power >=1 has a bleach effect, <1 and >0 has a darker effect
def _bleach_color(color,bleach_power):
COEFF=1.04
OFFSET=0.1
red = (COEFF*color.red+OFFSET)*bleach_power
green = (COEFF*color.green+OFFSET)*bleach_power
blue = (COEFF*color.blue+OFFSET)*bleach_power
new_color = (red,green,blue)
return _get_color(new_color)
I also edited a part of _render_rm_file, adding a piece of code that choose a darker or lighter color based on segment color
segment_blackDistance=colors.colorDistance(segment_color,colors.black)
if layer_colors[layer] is None:
segment_colors.append(segment_color)
elif segment_blackDistance<0.75: #black
segment_colors.append(_bleach_color(layer_colors[layer],0.5))
elif segment_blackDistance>1: #white
segment_colors.append(_bleach_color(layer_colors[layer],5))
else: #grey
segment_colors.append(layer_colors[layer])
Activity
peerdavid commentedon Dec 13, 2020
Very nice idea. Thanks a lot also for the code. I will include this soon :)