color.anubis 814 Bytes
/*
 * Created by PyramIDE.
 * User: フランスのトトロ aka (David RENÉ) 
 * Date: 07/01/2018
 * Time: 11:59
 * © David RENÉ
 */

transmit system/string.anubis
transmit system/convert.anubis
transmit tools/maybefloat.anubis


public define Int
/**
 */
  brightness
  (
    String  color //color value in hexadecimal form without any prefixed '0x' or '#'
  )=
  with   red = hexa_to_mb_Float(color, 0, 2),
  with green = hexa_to_mb_Float(color, 2, 2),
  with  blue = hexa_to_mb_Float(color, 4, 2),
  if sqrt(red * red * success(0.241) + green * green * success(0.691) + blue * blue * success(0.068)) is
  {
    failure         then  /*println("brightness failure");*/255,
    success(value)  then  
      with result = integral_part(value),
      //println("brightness value"+result);
      result
  }
.