User:Alphappy/reddust

The  particle, when summoned by , can take on customized colors. The behavior of the relevant parameters is outlined here. Note, however, that this special behavior only applies if count is  and speed is not.

Colors
The xd yd zd parameters for the command specify the Red, Green and Blue channel values, respectively. The red channel for  will default to   if it is set to , but an arbitrarily small number can be used to effectively set it to zero.

Behavior
There are several peculiarities to the processing of a  particle's color:
 * If xd is set to, it will be treated as.
 * The xd yd zd parameters can be set outside the range  to  ; a modulo operator fixes the color channels to the appropriate range.
 * Each channel's value is multiplied by a separate random value from 0.8 to 1.0, then by a single random value from 0.6 to 1.0.
 * A conversion to a Byte is applied to each channel, resulting in effective rounding towards zero.

This process may be understood by the following pseudocode: Set Red = xd, Green = yd, Blue = zd Multiply each (Red, Green, Blue) by speed If Red = 0 then set Red = 1 Set AllChannelMultiplier = RandomBetween(0.6, 1.0) For each channel (Red, Green, Blue): # Multiply (so that we step towards the range of a Byte) Multiply channel by 256 # Randomize Multiply channel by RandomBetween(0.8, 1.0) Multiply channel by AllChannelMultiplier # Convert (to an actual Byte value) Round channel toward zero, to the nearest integer Set channel = channel Mod 256 Return color of this particle as (Red, Green, Blue)

To better illustrate this process, consider these particular values, which can be used for any of xd yd zd to affect their respective channels (with the exception of xd = Red = ).