// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Aspect-aware image crop // Not compiled or tested in-world // Setup: Set FACE, IMAGE_WIDTH/HEIGHT and DISPLAY_WIDTH/HEIGHT to positive values. Use default texture mapping. Owner-touch applies/restores. // Stop / restore: Owner-touch again to restore the startup snapshot before removal or reset, unless setup describes a different cycle. Do not relink during a preview. // Notes: Use a spare modifiable build. Saved state lives only in script memory. Dimensions are supplied by you; the script cannot inspect image pixels or infer mesh face dimensions. It crops, rather than adding letterbox bars. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer preview; integer FACE=0; float IMAGE_WIDTH=1024.0; float IMAGE_HEIGHT=512.0; float DISPLAY_WIDTH=1.0; float DISPLAY_HEIGHT=1.0; list saved; default { state_entry() { saved=llGetLinkPrimitiveParams(LINK_THIS,[PRIM_TEXTURE,FACE]); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(IMAGE_WIDTH<=0.0||IMAGE_HEIGHT<=0.0||DISPLAY_WIDTH<=0.0||DISPLAY_HEIGHT<=0.0)return; preview=!preview; if(preview) { float source=IMAGE_WIDTH/IMAGE_HEIGHT; float target=DISPLAY_WIDTH/DISPLAY_HEIGHT; vector repeats=<1.0,1.0,0.0>; if(source>target)repeats.x=target/source; else repeats.y=source/target; llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXTURE,FACE,llList2String(saved,0),repeats,ZERO_VECTOR,0.0]); } else { llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXTURE,FACE]+saved); } } }