Cabbage Logo
Back to Cabbage Site

Help me please about example dynamic envelope

Admin you can write comment in example (Dynamic Envelope) every array. some array i don’t know mean as

if chnget:k(“MOUSE_DOWN_LEFT”)==1 && kY< iGtHeight+iGtYPos then ;;;;; <<<< do for what
if kX > -2 && kX < kDPos && kDecDragging!=1 && kSusDragging!=1 && kRelDragging!=1 then ;;;;;<<<< do for what
kAPos = kX - iGtXPos ;;;;;<<<< do for what
SMessage sprintfk “pos(%f, 5)”, kAPos ;;;;;<<<< do for what
chnset SMessage, “attIdent” ;;;;;<<<< do for what
kAttDragging = 1 ;;;;;<<<< do for what

I don’t know mean about operation of something

thanks you :smiley:

The entire block of code concerns moving the ‘attack’ handle on the envelope.

if chnget:k("MOUSE_DOWN_LEFT")==1 && kY< iGtHeight+iGtYPos then

The above line asks: “is the mouse button pressed and is the mouse Y position over the ‘A’ handle?”. (iGtHeigth is the height of the envelope panel. iGtYPos is the position of the envelope panel within the main panel.) If both parts of the above question are true, the next line of code is executed.

if kX > -2 && kX < kDPos && kDecDragging!=1 && kSusDragging!=1 && kRelDragging!=1 then

This line asks: "is the mouse X position greater than -2 (i.e. over the main panel), and less than the position of the ‘D’/decay handle, and that none of the other handles ‘D’, ‘S’ and ‘R’, are currently being dragged. (These three variables, kDecDragging etc, are ‘flags’ that are used to indicate whether a particular handle is being dragged.

kAPos = kX - iGtXPos

This line sets the variable for the X position of the ‘A’ handle to the X position of the mouse.

SMessage sprintfk "pos(%f, 5)", kAPos

This creates a string variable message that will be send to the ‘A’ handle. This message will give details about a new position for the widget.

chnset SMessage, "attIdent"

This sends the message to the widget. The widget is moved to its new location.

kAttDragging = 1

This is a so-called ‘flag’ which is used to indicate that the ‘A’ handle is being moved. It is used to ensure that the other handles, ‘D’, ‘S’ and ‘R’, can’t be moved simultaneosly.

Thanks you very much :smiley: