Skip to content

Instantly share code, notes, and snippets.

@melMass
Last active June 1, 2021 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save melMass/8e919e853c83793391f25ae0ba14b0db to your computer and use it in GitHub Desktop.
Save melMass/8e919e853c83793391f25ae0ba14b0db to your computer and use it in GitHub Desktop.

PaintCode Expressions

Operators

!b boolean logical negation of b
x * y numbers product of numbers x and y
x / y numbers quotient of numbers x and y
x % y numbers remainder after performing division of x and y (modulus)
m + n texts concatenation of the texts m and n
x + y numbers sum of numbers x and y
x - y numbers difference of x and y
x > y numbers true if x is greater than y, false otherwise
x >= y numbers true if x is greater than or equal to y, false otherwise
x < y numbers true if x is less than y, false otherwise
x <= y numbers true if x is less than or equal to y, false otherwise
a == b same type true if a is equal to b, false otherwise
a != b same type true if a is not equal to b, false otherwise
a && b booleans true if a and b both true, false otherwise
a || b booleans false if a and b both false, true otherwise
b ? x : y b - boolean if b is true, result is x, otherwise result is y

Functions

Math

floor(x)

returns x rounded downwards

ceil(x)

returns x rounded upwards

round(x)

returns x rounded to nearest integer

frac(x)

returns the fractional part of x

sqrt(x)

returns the square root of x

abs(x)

returns the absolute value of x

min(x, y)

returns the smaller of the two parameters

max(x, y)

returns the larger of the two parameters

Goniometric Functions

sin(a), cos(a), tan(a)

goniometric functions. Note: parameter a should be in degrees

atan2(y, x)

arc tangent in degrees of y/x based on the signs of both values to determine the correct quadrant

Colors, gradients and shadows

makeColor(r, g, b, a)

returns color with components r, g, b, a (red, green, blue, alpha). All parameters should be from interval 0..1

makeGradient(c1, c2)

returns two step gradient with colors c1 and c2

makeShadow(color, xOffset, yOffset, blurRadius)

returns shadow

Other Functions

makePoint(x, y)

returns point

makeSize(width, height)

returns size

makeRect(x, y, width, height)

returns rect with position of origin (x, y) and size (width, height)

stringFromNumber(x)

converts number x to text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment