Skip to content

Instantly share code, notes, and snippets.

@soltys
Created May 2, 2015 18:19
Show Gist options
  • Save soltys/7c0b1ea50affc2052332 to your computer and use it in GitHub Desktop.
Save soltys/7c0b1ea50affc2052332 to your computer and use it in GitHub Desktop.
#pragma scop
for ( i = 0; i < m; i++ )
{
for ( j = 0; j < n; j++ )
{
x = ( ( double ) ( j - 1 ) * x_max
+ ( double ) ( m - j ) * x_min )
/ ( double ) ( m - 1 );
y = ( ( double ) ( i - 1 ) * y_max
+ ( double ) ( n - i ) * y_min )
/ ( double ) ( n - 1 );
count[i][j] = 0;
x1 = x;
y1 = y;
for ( k = 1; k <= count_max; k++ )
{
x2 = x1 * x1 - y1 * y1 + x;
y2 = 2 * x1 * y1 + y;
if(x2 < -2.0 || 2.0 < x2 || y2 < -2.0 || 2.0 < y2 )
{
count[i][j] = k;
break;
}
x1 = x2;
y1 = y2;
}
if ( ( count[i][j] % 2 ) == 1 )
{
r[i][j] = 255;
g[i][j] = 255;
b[i][j] = 255;
}
else
{
c = ( int ) ( 255.0 * sqrt ( sqrt ( sqrt (
( ( double ) ( count[i][j] ) / ( double ) ( count_max ) ) ) ) ) );
r[i][j] = 3 * c / 5;
g[i][j] = 3 * c / 5;
b[i][j] = c;
}
}
}
#pragma endscop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment