
def mix_rgb(color1, color2):
    from nodebox.graphics import Color
    """
    Mixes two NodeBox RGB color objects in a subtractive way and returns the resulting color as a new NodeBox color object.
    
    Args:
    color1 (Color): The first NodeBox color object.
    color2 (Color): The second NodeBox color object.
    
    Returns:
    Color: The resulting NodeBox color object after subtractive mixing.
    """
    
    # Perform subtractive mixing
    # For subtractive color mixing, we subtract the second color from the first,
    # ensuring that we don't go below zero
    mixed_r = max(0, 255 - ((255 - color1.r*255) + (255 - color2.r*255)))
    mixed_g = max(0, 255 - ((255 - color1.g*255) + (255 - color2.g*255)))
    mixed_b = max(0, 255 - ((255 - color1.b*255) + (255 - color2.b*255)))
    
    # Normalize the values to 0-1 range expected by NodeBox
    mixed_r /= 255.0
    mixed_g /= 255.0
    mixed_b /= 255.0
    
    # Create and return the new blended color
    return Color(mixed_r, mixed_g, mixed_b, 1)




