// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Quantize an RGB color to fixed channel levels // Not compiled or tested in-world // Setup: Use a spare owned prim. Set LEVELS2..256 and RGB0..1. Touch for owner-only numeric output. // Stop / restore: Remove/disable; no colors or materials are applied. // Notes: This produces a regular RGB cube palette; it is not adaptive image quantization. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Color calculation only. vector RGB=<0.18,0.53,0.87>; integer LEVELS=6; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(LEVELS<2||LEVELS>256||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("Invalid levels/color."); return; } float steps=LEVELS-1; vector q=; llOwnerSay("Quantized="+(string)q+" error magnitude="+(string)llVecDist(q,RGB)); } }