OSL ‐ Modifiers - Mistium/Origin-OS GitHub Wiki
Modifiers in originOS Scripting
Modifiers in OriginOS scripting allow for dynamic adjustments to various properties of UI elements, such as color, position, and size. They provide a flexible way to customize the appearance and behavior of UI elements based on different conditions. Below is a guide to common modifiers and how to use them effectively:
There are new docs that contain all the modifiers in osl
https://osl.mistium.com/#C_About
Modifier Syntax
The general syntax for applying modifiers is:
command : modifier modifier
Modifiers are appended after a colon (:
) following a command, and multiple modifiers can be chained together.
Common Modifiers
c#hex_code
or colour #hex_code
)
1. Set Color (Changes the color of the UI element.
Example:
square 100 100 2 : c#ff0000
This example draws a square with a width and height of 100 pixels, a border weight of 2, and sets its color to red (#ff0000
).
chx#int
)
2. Change X Position (Adjusts the X position of the UI element.
Example:
icon "icon-name" 20 : chx#50
This example draws an icon named "icon-name" with a size of 20 and shifts its X position by 50 pixels.
chy#int
)
3. Change Y Position (Adjusts the Y position of the UI element.
Example:
text "Hello" 16 : chy#-30
This example renders the text "Hello" with a font size of 16 and shifts its Y position upward by 30 pixels.
hover_c#hex_code
)
4. Hover Color (Specifies the color when the UI element is being hovered.
Example:
button "Click me" : hover_c#00ff00
In this case, a button with the label "Click me" is created, and its color changes to green (#00ff00
) when hovered.
hover_size#1
)
5. Hover Size (Adjusts the size of the UI element when it is being hovered.
Example:
image "image-url" 120 : hover_size#1.2
This example renders an image with a specified URL and width of 120 pixels. When hovered, the image size increases to 1.2 times its original size.
Combined Example
square 50 50 1 : c#336699 chx#20 chy#-10 hover_c#ff9900 hover_size#1.1
In this combined example, a square with a size of 50 pixels, border weight of 1, color #336699
, and initial X and Y positions is drawn. When hovered, the color changes to #ff9900
, and the size increases by 10%.
Feel free to experiment with different combinations of modifiers to achieve the desired appearance and behavior for your UI elements in originOS scripting.