2022-06-26 20:06:35 +11:00
|
|
|
/*
|
|
|
|
turtle.c
|
|
|
|
---------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2022-07-07 21:52:00 +11:00
|
|
|
#include "../tthimage.h"
|
2022-06-26 20:06:35 +11:00
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2023-11-19 05:56:25 +11:00
|
|
|
int Image_turtle_infos(Image_Desc *img, int flags)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "Image turtle infos: flags = %04x\n", flags);
|
|
|
|
#endif
|
|
|
|
|
2023-11-19 05:56:25 +11:00
|
|
|
if ( flags & 1 ) {
|
2023-09-29 08:50:23 +11:00
|
|
|
Image_dump_descriptor(img, "turtle infos");
|
2023-11-19 05:56:25 +11:00
|
|
|
}
|
2022-06-26 20:06:35 +11:00
|
|
|
|
|
|
|
return FUNC_IS_ALPHA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
/*
|
|
|
|
* changer la couleur de l'encre de la tortue.
|
|
|
|
*
|
|
|
|
* Q: pourquoi le canal alpha n'est pas pris en compte ?
|
|
|
|
* A: parce que :)
|
|
|
|
*/
|
2023-11-19 05:56:25 +11:00
|
|
|
int Image_turtle_setcolors(Image_Desc *img, int r, int g, int b)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
img->rt = r; img->gt = g; img->bt = b;
|
|
|
|
|
|
|
|
img->at = 0; /* ? bonne valeur ? */
|
|
|
|
|
|
|
|
return FUNC_IS_ALPHA;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2023-11-19 05:56:25 +11:00
|
|
|
int Image_turtle_move(Image_Desc *img, double xt, double yt)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
|
|
|
|
2023-09-29 08:50:23 +11:00
|
|
|
fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
|
|
|
|
|
2023-11-19 05:56:25 +11:00
|
|
|
img->xt = xt;
|
|
|
|
img->yt = yt;
|
|
|
|
|
2022-06-26 20:06:35 +11:00
|
|
|
return FUNC_NOT_FINISH;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2023-11-19 05:56:25 +11:00
|
|
|
int Image_turtle_draw(Image_Desc *img, double xt, double yt)
|
2022-06-26 20:06:35 +11:00
|
|
|
{
|
2023-11-19 05:56:25 +11:00
|
|
|
int x1, y1, x2, y2;
|
|
|
|
RGBA color = { 200, 200, 200, 0, 0, 0 };
|
2022-06-26 20:06:35 +11:00
|
|
|
|
2023-09-29 08:50:23 +11:00
|
|
|
fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
|
2022-06-26 20:06:35 +11:00
|
|
|
|
2023-11-19 05:56:25 +11:00
|
|
|
x1 = (int)img->xt, y1 = (int)img->yt;
|
|
|
|
x2 = (int)xt , y2 = (int)yt;
|
|
|
|
|
|
|
|
Image_draw_line(img, x1, y1, x2, y2, &color);
|
2022-06-26 20:06:35 +11:00
|
|
|
|
|
|
|
return FUNC_NOT_FINISH;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|