Modulo?
Moderator: Moderators
Hi darkhog,
There is no modulo operator in ZGameEditor at the moment ( no idea why ). You can define it as a function yourself though .. simply copy-paste the following into the App.OnLoaded node of your project.
K
There is no modulo operator in ZGameEditor at the moment ( no idea why ). You can define it as a function yourself though .. simply copy-paste the following into the App.OnLoaded node of your project.
Code: Select all
ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<ZLibrary Comment="Standard">
<Source>
<![CDATA[//
float mod(float a, float n)
{
return a - n * floor(a / n);
}]]>
</Source>
</ZLibrary>
Your code doesn't work. This BitmapExpression should fill every second column leaving anything else black, but instead it only fills first column:
if (mod(this.X,2)==0){
this.Pixel.R=((abs(sin(this.X-3))*5)-abs(atan2(this.Y+3,this.X*6)*5))*cos(this.Pixel.B);
this.Pixel.G=((abs(cos(this.X-3))*5)-abs(sin(this.Y-3))*5)*cos(this.Pixel.R);
this.Pixel.B=cos(this.Pixel.G)*cos(this.X*sin(this.Y));
}
if (mod(this.X,2)==0){
this.Pixel.R=((abs(sin(this.X-3))*5)-abs(atan2(this.Y+3,this.X*6)*5))*cos(this.Pixel.B);
this.Pixel.G=((abs(cos(this.X-3))*5)-abs(sin(this.Y-3))*5)*cos(this.Pixel.R);
this.Pixel.B=cos(this.Pixel.G)*cos(this.X*sin(this.Y));
}
Hi darkhog,
The X and Y properties of the BitmapExpression component are floating point variables in the 0-1 range* So you need to calculate the pixel coordinates yourself if you want to use those ( i know .. it's counter-intuitive ).
*Actually, 1-1/resolution instead of 1 to be precise.
K
The X and Y properties of the BitmapExpression component are floating point variables in the 0-1 range* So you need to calculate the pixel coordinates yourself if you want to use those ( i know .. it's counter-intuitive ).
Code: Select all
float X, Y;
X = this.X * 64; // 64 is the horizontal resolution of the bitmap
Y = this.Y * 64; // 64 is the vertical resolution of the bitmap
if(mod(X,2) == 0)
{
// Your algorithm :-)
}
K