working on patterns

This commit is contained in:
tTh 2023-09-22 14:20:26 +02:00
parent 806c9b0071
commit ba7ba3d666
2 changed files with 37 additions and 62 deletions

View File

@ -9,8 +9,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_000(Image_Desc *img, int foo)
Image_pattern_000(Image_Desc *img, int foo)
{ {
int x, y, xx, yy, r, g, b; int x, y, xx, yy, r, g, b;
@ -18,11 +17,9 @@ int x, y, xx, yy, r, g, b;
fprintf(stderr, "%s : foo = %d\n", __func__, foo); fprintf(stderr, "%s : foo = %d\n", __func__, foo);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
xx = (x * 256) / img->width; xx = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
yy = (y * 256) / img->height; yy = (y * 256) / img->height;
r = xx & yy & foo; r = xx & yy & foo;
g = ((xx * yy) & 0xf8 ); g = ((xx * yy) & 0xf8 );
@ -37,8 +34,7 @@ for (x=0; x<img->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_001(Image_Desc *img, int foo)
Image_pattern_001(Image_Desc *img, int foo)
{ {
int x, y; int x, y;
@ -50,11 +46,10 @@ for (x=0; x<img->width; x++)
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++)
Image_plotRGB(img, x, y, x^y^foo, (x*y)>>4, x&y); Image_plotRGB(img, x, y, x^y^foo, (x*y)>>4, x&y);
return FUNC_NOT_FINISH; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_002(Image_Desc *img, int foo)
Image_pattern_002(Image_Desc *img, int foo)
{ {
int x, y, x2, y2; int x, y, x2, y2;
@ -62,11 +57,9 @@ int x, y, x2, y2;
fprintf(stderr, "Pattern 002: %d\n", foo); fprintf(stderr, "Pattern 002: %d\n", foo);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
x2 = (x * 256) / img->width; x2 = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
y2 = (y * 256) / img->height; y2 = (y * 256) / img->height;
Image_plotRGB(img, x, y, (x2/2)&(y2/2)&foo, (x2*y2)>>3, x2^y2); Image_plotRGB(img, x, y, (x2/2)&(y2/2)&foo, (x2*y2)>>3, x2^y2);
} }
@ -75,8 +68,7 @@ for (x=0; x<img->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_003(Image_Desc *img, int foo)
Image_pattern_003(Image_Desc *img, int foo)
{ {
int x, x2, y, y2; int x, x2, y, y2;
@ -85,11 +77,9 @@ fprintf(stderr, "Pattern 003: foo is %d\n", foo);
#endif #endif
/* added some ugly code the 28 february 2008 */ /* added some ugly code the 28 february 2008 */
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
x2 = (x * 256) / img->width; x2 = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
y2 = (y * 256) / img->height; y2 = (y * 256) / img->height;
Image_plotRGB(img, x, y, (x2/4)&(y2/4)&foo, (x2*y2)>>5, x2^y2); Image_plotRGB(img, x, y, (x2/4)&(y2/4)&foo, (x2*y2)>>5, x2^y2);
} }
@ -98,8 +88,7 @@ for (x=0; x<img->width; x++)
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Pattern 004: %d, %d, %d, %d\n", a, b, c, d); fprintf(stderr, "Pattern 004: %d, %d, %d, %d\n", a, b, c, d);
@ -122,11 +111,9 @@ if (NULL == map) {
return NULL_POINTER; return NULL_POINTER;
} }
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
fy = (double)y; fy = (double)y;
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
fx = (double)x; fx = (double)x;
idx = (int)(127.0+(sin(fx)*cos(fy)*254.99)); idx = (int)(127.0+(sin(fx)*cos(fy)*254.99));
@ -140,8 +127,7 @@ for (y=0; y<img->height; y++)
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_042(Image_Desc *img, int foo)
Image_pattern_042(Image_Desc *img, int foo)
{ {
int x, y, r, g, b; int x, y, r, g, b;
@ -150,10 +136,8 @@ fprintf(stderr, "Pattern 042: threshold level is %d\n", foo);
#endif #endif
r = g = b = 42; r = g = b = 42;
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{ for (y=0; y<img->height; y++) {
for (y=0; y<img->height; y++)
{
r += rand() % 4; r += rand() % 4;
if (r > foo) r = 0; if (r > foo) r = 0;

View File

@ -16,15 +16,15 @@
/* /*
* c'est quasiment impossible de documenter cette fonction. * c'est quasiment impossible de documenter cette fonction.
*/ */
int int Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
{ {
int x, y, r,g, b; int x, y, r,g, b;
for (x=0; x<dst->width; x++) fprintf(stderr, ">>> %s ( %p %d %d %d )\n", __func__,
{ dst, kr, kg, kb);
for (y=0; y<dst->height; y++)
{ for (x=0; x<dst->width; x++) {
for (y=0; y<dst->height; y++) {
r = abs(x+y-(dst->width/3)) * kr; r = abs(x+y-(dst->width/3)) * kr;
g = abs(x-y-(dst->height/3)) * kg; g = abs(x-y-(dst->height/3)) * kg;
b = (rand() % 42) + kb; b = (rand() % 42) + kb;
@ -36,19 +36,19 @@ for (x=0; x<dst->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
{ {
int x, y, r,g, b; int x, y, r,g, b;
fprintf(stderr, ">>> %s ( %p %d %d %d )\n", __func__,
dst, kr, kg, kb);
if (kr == 0) kr = 1; if (kr == 0) kr = 1;
if (kg == 0) kg = 1; if (kg == 0) kg = 1;
if (kb == 0) kb = 1; if (kb == 0) kb = 1;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{ for (y=0; y<dst->height; y++) {
for (y=0; y<dst->height; y++)
{
if (x < dst->width/2) if (x < dst->width/2)
{ r=x/kr; g=y/kg; b=x/kb; } { r=x/kr; g=y/kg; b=x/kb; }
else else
@ -59,18 +59,15 @@ for (x=0; x<dst->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
{ {
int x, y, r,g, b; int x, y, r,g, b;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{ for (y=0; y<dst->height; y++) {
for (y=0; y<dst->height; y++)
{
r = x ^ kr; r = x ^ kr;
g = y ^ kg; g = y ^ kg;
b = (x+y) ^ kb; b = (x+y+param) ^ kb;
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
} }
} }
@ -80,26 +77,20 @@ return FUNC_NOT_FINISH;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* hop, 31 mars 2008, une petite evolution stochastique de base... /* hop, 31 mars 2008, une petite evolution stochastique de base...
* */ * */
int int Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
{ {
int x, y, r, g, b; int x, y, r, g, b;
long surface;
double dx, dy; double dx, dy;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s: acting on image %p\n", __func__, dst); fprintf(stderr, "%s: acting on image %p\n", __func__, dst);
#endif #endif
surface = dst->width * dst->height; for (x=0; x<dst->width; x++) {
for (x=0; x<dst->width; x++)
{
dx = (double)x / (double)dst->width; dx = (double)x / (double)dst->width;
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{
dy = (double)x / (double)dst->height; dy = (double)x / (double)dst->height;
r = (int)round(256.0 * sqrt(dx * dy)); /* XXX */ r = (int)(256.0 * sqrt(dx * dy)); /* XXX */
g = b = rand() & 0xf0; g = b = rand() & 0xf0;
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
} }