Você está na página 1de 2

5/16/13

dummyworld.net | KSP: Custom UI graphics

KSP: Custom UI graphics A brief overview of how to use custom graphics in your scripts

I wanted to make some really short tutorials for Kontakt 4 scripting. There's tons of resources out there so I figured that this series would only really cover tips and tricks that I use. Therefore I'll warn that this series is aimed at people who have played with Kontakt scripting a little and know what they're doing. If you don't, I definitely recommend checking out the documentation that comes with Kontakt, and poking about scripts included in Kontakt 4's library Custom UI graphics - Things to know This tutorial give a brief overview of custom UI graphics in Kontakt 4. It's intended to fill in the basics and provide a reference for experienced users.

Share

What image formats can Kontakt read? Kontakt can read images that are either TGA or PNG. TGA files must be uncompressed and either 16 or 24bit. Images can contain an alpha channel that defines opacity. This will not be used by default, however - I'll explain that in a further tutorial.

Where do I put them so my script can use them? I'll start by saying that graphics can go in two places (on a typical PC ): My Documents\Native Instruments\Kontakt 4 or Program Files\Common\Native Instruments\Kontakt 4 My advice is to always use the (My) Documents folder option for several reasons. Firstly, on Windows Vista/7 access controls prevent most users or software from changing or accessing the Program Files folder. Secondly, it's much easier for the average user to access it in My Documents. Lastly, it's just nice for everyone to do something consistently. I'd also recommend that you put your custom pictures inside an intuitively named folder. For example, my Documents\NI\Kontakt 4 folder looks like this:

If everyone does this, it should keep our Kontakt folders clean and allow
dummyworld.net/media/?pageid=75 1/2

5/16/13

dummyworld.net | KSP: Custom UI graphics

musicians to easily edit, copy or remove scripts as they require.

How do I use them in a script? Now that you've got your images in the right format and the right place, how do we go about using them in a script? It's really quite simple. Lets look at the code.
d e c l a r eu i _ l a b e l$ t e s t( 1 , 1 ) s e t _ c o n t r o l _ p a r _ s t r ( g e t _ u i _ i d ( $ t e s t ) ,$ C O N T R O L _ P A R _ P I C T U R E ," f o l d e r / f i l e n a m e " )

On the first line we declare our ui control. In this instance it's a label. The second line is where we assign this control it's picture. We use set_control_par_str . This command assigns a string parameter to a control and takes three parameters: g e t _ u d _ i d ( $ t e s t ) The ID of the control we're editing. In this case we use get_ui_id on $test to retrieve it's ID. $ C O N T R O L _ P A R _ P I C T U R E This specifies that we're changing the picture parameter " f o l d e r / f i l e " And this is the relative path to our image. Notice that we omit the file extension as Kontakt will auto detect this. Also notice that we use a forward slash. Never use a backslash as this will not work on the Mac version of Kontakt!

Are there any limits? There are :( The ui_knob control cannot be given a custom image. There is a workaround in another tutorial of mine.

Conclusion And so that wraps up this basic tutorial on custom images. This should let you create much more intricate scripts and UIs. Be sure to include your custom graphics with any scripts you distribute. It's also a nice idea to provide users with instructions on how to install them correctly.

Things to note There are a few points to consider when using custom graphics. TGA images must be uncompressed or they won't load correctly. You must use forward slashes when referencing image filenames. Mac Kontakt will fail to load them if you use a backslash. ui_knob cannot have a custom image. For custom knobs use a slider and follow this tutorial instead.

dummyworld.net/media/?pageid=75

2/2

Você também pode gostar