/* examples/canvas/couleur.c */ #include He_node *princ, *canvas; int rouge, vert, bleu, gris; void init_couleurs () { rouge = HeAllocRgb (255, 0, 0, he_black); vert = HeAllocRgb (0, 255, 0, he_black); bleu = HeAllocRgb (0, 0, 255, he_black); gris = HeAllocRgb (150, 150, 150, he_black); } void dessin_ligne (Window win, int x1, int y1, int x2, int y2, int coul) { XSetForeground (he_display, he_gc, coul); XDrawLine (he_display, win, he_gc, x1, y1, x2, y2); } void canvas_repaint_proc (He_node *hn, Window win) { dessin_ligne (win, 50, 50, 250, 50, rouge); dessin_ligne (win, 250, 50, 250, 250, vert); dessin_ligne (win, 250, 250, 50, 250, bleu); dessin_ligne (win, 50, 250, 50, 50, gris); } int main (int argc, char *argv[]) { HeInit (&argc, &argv); princ = HeCreateFrame(); HeSetFrameLabel (princ, "carré en couleur"); canvas = HeCreateCanvas (princ); HeSetCanvasRepaintProc (canvas, canvas_repaint_proc); init_couleurs (); HeSetWidth (canvas, 300); HeSetHeight (canvas, 300); HeFit (princ); return HeMainLoop (princ); }