Last active
June 2, 2020 11:09
-
-
Save AndersDeleuran/82fa2a8a69ec10ac68176e1b848fdeea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Rhino as rc | |
def mapValuesAsColors(values,srcMin,srcMax,targetMin,targetMax): | |
""" Make a list of HSL colors where the values are mapped onto a | |
targetMin-targetMax hue domain. Meaning that low values will be red, medium | |
values green and large values blue if targetMin: 0.0 and targetMax: 0.7 """ | |
# Remap numbers into new numeric domain | |
remappedValues = [] | |
for v in values: | |
if srcMax-srcMin > 0: | |
rv = ((v-srcMin)/(srcMax-srcMin))*(targetMax-targetMin)+targetMin | |
else: | |
rv = (targetMin+targetMax)/2 | |
remappedValues.append(rv) | |
# Make colors and return | |
colors = [] | |
for v in remappedValues: | |
c = rc.Display.ColorHSL(v,1.0,0.5).ToArgbColor() | |
colors.append(c) | |
return colors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment