Operators: *

Multiplication operator.

Syntax

integer‑operand*integer‑operand

float‑operand*float‑operand

rect‑operand*point‑operandorpoint‑operand*rect‑operand

color‑operand*color‑operand

color‑operand*integer‑operandorinteger‑operand*color‑operand

Integer multiplication

In its first version, the * operator multiplies the both integer operands. If used with two signed integer operands, the resulting data type is always int32. In all other cases, the operation results in the unsigned uint32 value. For example:

var int32 a = 13; var int32 b = -14; var uint32 c = 13; var uint32 d = 12; var int32 result = a * b; // result = -182 var uint32 result = c * d; // result = 156 var uint32 result = b * d; // result = 0xFFFFFF58

Floating point multiplication

In its second version, the * operator multiplies the both floating-point operands. The resulting data type of the operation is always a float. For example:

var float a = 13.69; var float b = -14.96; var float result = a * b; // result = --204.8024

Rectangle inflation

In its third version, the * operator inflates a rectangle operand by an offset specified in the point operand. The operation affects the top-left and the bottom-right rectangle corners to be moved away from the rectangle's center by the offset specified in the point operand. The resulting data type of the operation is always a rect. For example:

var rect a = <100,200,110,220>; var point b = <50,70>; var rect result = a * b; // result = <50,130,160,290> var rect result = b * a; // result = <50,130,160,290>

Color alpha-blending

In its fourth version, the * operator performs the alpha-blending operation between the both color operands. The result is the left color operand alpha-blended with the right color operand. The alpha component of the right operand decides about the intensity of the alpha blending. If this alpha component is 0 (zero), the operator returns the left color operand. If the alpha component of the right operand is 255, the operator returns the right color operand. In all other cases, the operator returns a color value lying in between. The resulting data type of the operation is always a color. For example:

var color a = #FF000080; var color b = #00FF0080; var color result = a * b; // result = #7F8000C0

Color modulation with saturation

In its fifth version, the * operator modulates a color operand with an integer operand. If the integer operand is <= 0 (zero), the operation results in a fully transparent color #00000000. If the integer operand is >= 255, the original and unmodified color operand is returned. In all other cases, the operator returns a color value lying in between. The operation is performed individually for every red, green, blue and alpha color components. The resulting data type of the operation is always a color. For example:

var color a = #AAEE77FF; var int32 b = 128; var int32 c = -10; var int32 d = 500; var color result = a * b; // result = #55773B80 var color result = b * a; // result = #55773B80 var color result = a * c; // result = #00000000 var color result = a * d; // result = #AAEE77FF