[Add feature] Change brightness based on color segment in rendering
paduLAB opened this issue · 1 comments
paduLAB commented
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])
I hope my little work was useful.
Regards
peerdavid commented
Very nice idea. Thanks a lot also for the code. I will include this soon :)