 Operators: *

Multiplication operator.

Syntax

integer‑operand*integer‑operand

float‑operand*float‑operand

float‑operand*integer‑operandorinteger‑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 in combination with 8-, 16- or 32-bit signed integer operands, the data type resulting from the operation is consequently int32. When mixing signed and unsigned integer operands, the operation results in the unsigned uint32 value. In the case, one of the operands is 64-bit large, the resulting data type is int64 or uint64 according to whether the 64-bit operand is signed or unsigned. For example:

var int32  a = 13;
var int32  b = -14;
var uint32 c = 13;
var uint32 d = 12;
var uint64 e =  8975466489;
var int64  f = -1496136912;

var int32  result = a * b; // result = -182
var uint32 result = c * d; // result = 156
var uint32 result = b * d; // result = 0xFFFFFF58
var int64  result = f * d; // result = -17953642944
var uint64 result = e * d; // result = 107705597868

Floating point multiplication

In its second version, the * operator multiplies the both floating-point operands. If used in combination with a signed or unsigned integer operand, the integer operand is automatically converted to float before performing the multiplication. The resulting data type of the operation is always a float. For example:

var float  a = 13.69;
var float  b = -14.96;
var int32  c = 2;

var float  result = a * b; // result = -204.8023986
var float  result = a * c; // result = 27.37999916

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