         |
|
The first in my Kontakt 4 script mini tutorials. This one covers adding new background images to scripts that you don't own.
|
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 backgrounds
This first tutorial shows how to create a background image for a library that you can't change the wallpaper for. This comes in handy when you're making a script for a locked library but want to implement your own GUI, or if you want custom UIs per script tab.
It's quite simple. We're going to create a label in on init and have it appear as background. Let's look at the code:
on init
declare ui_label $ui_background (0,0)
set_control_par_str (get_ui_id($ui_background), $CONTROL_PAR_TEXT, "")
set_control_par_str (get_ui_id($ui_background), $CONTROL_PAR_PICTURE, "background")
set_control_par (get_ui_id($ui_background), $CONTROL_PAR_POS_X, 0)
set_control_par (get_ui_id($ui_background), $CONTROL_PAR_POS_Y, 0)
end on
Line by line breakdown
declare ui_label $ui_background (0,0)
Create a new label called $ui_background and set its width and height to 0 by 0.
set_control_par_str (get_ui_id($ui_background), $CONTROL_PAR_TEXT, "")
Set the label's text to blank. This will prevent any text appearing and will hide the label's background box.
set_control_par_str (get_ui_id($ui_background), $CONTROL_PAR_PICTURE, "background")
Set the label's image file name to "background". We miss off the file extension as Kontakt will automatically determine this.
set_control_par (get_ui_id($ui_background), $CONTROL_PAR_POS_X, 0)
set_control_par (get_ui_id($ui_background), $CONTROL_PAR_POS_Y, 0)
Position our label in pixels. We set it to 0,0 at the top of the script interface.
Conclusion
Tada! Your script now has a custom background. You'll need to move your background image to the pictures folder:
Documents\Native Instruments\Kontakt 4\pictures
Kontakt will automatically try all file extensions, so for the code above it would look for background.bmp, background.tga, background.png, etc.
Things to note
There are a few points to consider when using labels as background images:
- If your images are in directories inside the pictures folders, be sure to use a backslash in the path (eg. "requiem/background"). This will ensure your script works on Mac and PC Kontakt.
- The ui_label for your background must be the first control declared in the on init function. Kontakt's UI draw order correlates to declaration order.
|
|