Image creates a static shape or graphic. It can be used to show pictures or it can be used to draw simple shapes. If you wish to display a picture you must pass the file name to the file() identifier. For convenience, the file passed to file() should be in the same directory as your Cabbage instrument.
image corners(val), crop(x, y, width, height), file("filename"), mouseInteraction(val), outlineColour("colour"), outlineThickness(value), popup(val), shape("shape"), active(val), alpha(val), bounds(x, y, width, height), channel("chan"), colour("colour"), identChannel("channel"), parent(val), rotate(radians, pivotx, pivoty), visible(val), toFront(), moveBehind("widgetName"), widgetArray("chan", number),
corners(val) Sets the radius size of the widget's corners.
crop(x, y, width, height) Crops an image. This is usually intended to be used with an identifier channel and is very useful when using filmstrips or spritesheets.
file("filename") This identifier is used across a number of widgets.
listbox - will load lines from a file as selectable items.
soundfiler - will load a sound file to display
image - will load an iamge to display (PNG/JPG/SVG)
infobutton - sets the file to display when the button is clicked This can be a local html file, or a URL.
texteditor - sets the file to load, should be a text file.
If a full file path is not given, file() will search in the current directory, i.e., the directory that contains the csd file that is open. It is best to keep all files in the same directory as your csd file. If you wish to keep them in a separate folder use relative paths, i.e,
Avoid absolute path at all costs. Failure to do so will most likely problems with your instruments as soon as you share them.
mouseInteraction(val) Enables or disable mouse interaction. Set to 1 by default.
outlineColour("colour") Sets the colour of a button outline, or a rotary slider`s tracker outline. In the case of rslider's this is the line that is drawn around the rslider's tracker. If you don't wish to display the tracker outline set the colour to something with an alpha value of 0. See above for details on valid colours.
outlineThickness(value) Sets the thickness of the widget's outline. Set to 0 to disable.
popup(val) This identifier, used with an image or groupbox will convert the plant into a popup plant. The plant will not be shown on the instrument's main interface, but will instead appear when the user sets
visible to 1. < DAWs treat popup dialogue windows in different ways. As a result, you may notice inconsistent behaviour when running your instruments as plugins across a variety of different hosts.
shape("shape") Sets the shape of the LED. Default is "square" but users can use "circle" also.
. Note that by settings the corners to a high value one can also create elliptical shapes.
plant("name") [DEPRECATED] Sets the name of the plant. No two plants can have the same name. See Plants
active(val) Will deactivate a control if 0 is passed. Controls which are deactivate can still be updated from Csound.
alpha(val) A value between 0 and 1 will set the alpha blend value for the entire component. Can be useful if you need to fade widgets in and out.
bounds(x, y, width, height) integer values that set position and size on screen(in pixels).
channel("chan1", "chan2") in the case of widgets that accept two channels such as xypad, soundfiler and range widgets.
channel() accepts a string/s that names the channel/s that Cabbage will communicate with Csound on. The current value of this widget can be retrieved in Csound using a
chnget, or a
cabbageGetValue opcode. Its value can be set using the
soundfiler all take two channels:
hrange, vrange :
channel("min", "max") - min and max values
channel("x", "y") - x and y values
channel("start", "length") - start time and length of user selection, in samples
Channels named should start with a letter and cannot have any white spaces. Note that all widgets should have a unique channel name.
A left-mouse click on an image will send a 1 to the channel passed to channel(). Subsequent clicks will toggle between 0 and 1.
colour("colour") This sets the main colour. Any CSS or HTML colour string can be passed to this identifier. The colour identifier can also be passed an RBG, or RGBA value. All channel values must be between 0 and 255. For instance colour(0, 0, 255) will create a blue, while colour(0, 255, 0, 255) will create a green with an alpha channel set to full.
identChannel("channel") [!!! DEPRECATED !!!] Although identifier channels still work, they are no longer supported. Please use the new guiMode("queue") system and the
cabbageSet opcodes instead. They are far more efficient then identifiers channel.
rotate(radians, pivotx, pivoty) Rotates the widget by a number of radians(2xPI=full rotation). pivotx and pivoty will determine the rotation pivot points, where 0, 0 represents the component's top-left position.
visible(val) A value of 0 will cause the widget to become invisible. Widgets have their visibility set to 1 by default.
toFront() Brings a widget to the front of the z order. This identifier takes no arguments and is only intended for use within the Csound orchestra. it makes no sense to call it when declaring the widget.
moveBehind("widgetName") Moves a widget directly behind another. This identifier should only ever be called from your Csound orchestra using a
This only works with widgets or plants that have the same parent.
widgetArray("chan", number) [!!! DEPRECATED !!!] Deprecated. Please see the section on Managing large numbers of widgets
<Cabbage> form caption("Image Example") size(380,440), guiMode("queue"), colour(2, 145, 209) pluginId("def1") texteditor bounds(18, 280, 341, 150) channel("infoText"), readOnly(1), wrap(1), scrollbars(1) image bounds(72, 22, 234, 234) channel("image1"), file("cabbage.png") image bounds(42, 26, 280, 190) channel("image2"), file("headphones.png") </Cabbage> <CsoundSynthesizer> <CsOptions> -n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5 </CsOptions> <CsInstruments> ; Initialize the global variables. ksmps = 16 nchnls = 2 0dbfs = 1 ; Rory Walsh 2021 ; ; License: CC0 1.0 Universal ; You can copy, modify, and distribute this file, ; even for commercial purposes, all without asking permission. instr 99 SText = "An image widget can be used to display images. PNGs, JPEGSs and basic SVGs are supported. As with all Cabbage widgets, an image widget's attributes can be updated in real time by sending updated identifiers data to its channel. Images can also as as buttons, where a mouse click will toggle between 0 and 1.\n\nIn this example the RMS value from a simple loop is used to drive the size of the Cabbage." cabbageSet "infoText", "text", SText endin instr 1 a1, a2 diskin2 "beat.ogg", 1, 0, 1 outs a1, a2 kRms rms a1+a2, 20 cabbageSet metro(10), "image1", "bounds", 72, 22, 234+(kRms*10), 234+(kRms*10) endin </CsInstruments> <CsScore> ;causes Csound to run for about 7000 years... f0 z i99 0 0 i1 1 z </CsScore> </CsoundSynthesizer>