// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Read hue, saturation and value from RGB // Not compiled or tested in-world // Setup: Use a spare owned prim. Set RGB components0..1. Touch for owner-only numeric output. // Stop / restore: Remove/disable; no colors or materials are applied. // Notes: Achromatic colors have undefined hue; this example reports zero for that case. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Color calculation only. vector RGB=<0.2,0.7,0.4>; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(RGB.x<0.0||RGB.y<0.0||RGB.z<0.0||RGB.x>1.0||RGB.y>1.0||RGB.z>1.0) { llOwnerSay("RGB must be0..1."); return; } float high=RGB.x; float low=RGB.x; if(RGB.y>high)high=RGB.y; if(RGB.z>high)high=RGB.z; if(RGB.y0.0)saturation=delta/high; if(delta>0.000001) { if(high==RGB.x)hue=(RGB.y-RGB.z)/delta; else if(high==RGB.y)hue=2.0+(RGB.z-RGB.x)/delta; else hue=4.0+(RGB.x-RGB.y)/delta; hue*=60.0; if(hue<0.0)hue+=360.0; } llOwnerSay("HSV="+(string)); } }