New graphic command to gui_grid.c - General Discussion and Assistance - CHDK Forum

New graphic command to gui_grid.c

  • 3 Replies
New graphic command to gui_grid.c
« on: 08 / March / 2008, 10:14:05 »

I wanted to add a command of the type: @mesh x1,y1,x2,y2,rows,columns,color  to the gui_grid.c.
But since I am a raw recruit in programming, it only works this way (color clf and color clb are read as rows, columns
and one additional color clm is defined in struct gline) - so what would be the elegant solution?
Many thanks...

Code: [Select]
typedef enum {
} grid_elem_type;
struct gline {
    grid_elem_type      type;
    coord               x0,y0,x1,y1;
    color               clf,clb,clm;
    struct gline        *next;
long nums[7];
....................if (gptr) {
        gptr->x0=nums[0];  gptr->y0=nums[1];
        gptr->x1=nums[2];  gptr->y1=nums[3];
        gptr->clf=nums[4]; gptr->clb=nums[5];
} else if (strncmp("@mesh", ptr, 5)==0) {
                process_element(ptr, 7, GRID_ELEM_MESH);
                 draw_mesh(ptr->x0, ptr->y0, ptr->x1, ptr->y1,(unsigned int)(ptr->clb),(unsigned int)(ptr->clf),(unsigned int)(ptr->clm))

« Last Edit: 08 / March / 2008, 10:23:40 by cosmograph »


Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: New graphic command to gui_grid.c
« Reply #1 on: 17 / March / 2008, 17:06:06 »
what exactly is it your function should accomplish? i like new graphic commands, but i'm slow in comprehension, as i cant draw by coordinates. maybe you can give an example?

Re: New graphic command to gui_grid.c
« Reply #2 on: 17 / March / 2008, 21:58:10 »
The command [@mesh x1,y1,x2,y2,rows,columns,color] added to a grid-file simply draws a mesh of a given number of even-spaced rows and columns within a rectangle given by two coordinates (x1,y1 and x2,y2) - it works already,
I just was asking for the correct and elegant implementation to the gui_grid.c file - I just don't know how to change the way the parameters are read - so I altered it a bit and now the parameters for rows and columns are read from the colors clf and clb -
I just added a third color in the struct gline{.. clm} for the color of the mesh to draw. Since my @mesh-command has more
parameters to set than the other grid-commands this is a bit confusing. What would be the best solution for the code taking
into consideration that other commands with even more parameters could be added later?


Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: New graphic command to gui_grid.c
« Reply #3 on: 18 / March / 2008, 10:12:29 »
Yep, adding a new "color" not for color but for a mesh sounds confusing. Someone in the future could ask: Why does a mesh has 3 colours?

I am thinking: You are proposing a new structure that is not a line, is a mesh. So may be if you declare a new struct called "mesh" with all the variables you need.

That sounds more "elegant" to me. But I don't know the impact in terms of performance adding a new structure will bring.


Related Topics

SimplePortal 2.3.6 © 2008-2014, SimplePortal