void Kek::redraw()
{
	img->fill();

	p->begin(img);
	auto pen = QPen(Qt::red);
	pen.setWidth(2);
	p->setPen(pen);
	p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
	QPoint center = QPoint(size().width(), size().height())/2;
	ProjectionCenter = center;
	//auto d = center.x()/2;
	//auto m = center/2;

	FigureRotateAlpha = float(rot_x) / 100.0;
	FigureRotateBeta = float(rot_y) / 100.0;
	FigurePlace.setX( float(mov_x));
	FigurePlace.setY( float(mov_y));
	FigureSize += float(fsize) / 12.0;
	transform(vert_l, fig_v, fig_t);
	axonom(vert_l, fig_t, fig_p);
	perspective(vert_l, fig_p, fig_kek);
	draw_figure(p, vert_l, fig_kek, edges, fig_e);

	p->end();
	setPixmap(*img);
}
Beispiel #2
0
void main()
{
    char c;
    int gata = 0;
    double xx1[DIM], xx2[DIM], yy1[DIM], yy2[DIM];

    initialize_graphic_mode();
    initialize_variable_spaces();
    create_figure();
    draw_figure();
    draw_axes();
    draw_line();

    do
    {
        c = getch();
        for (int i = 0; i < DIM; i++)
        {
            xx1[i] = x1[i];
            xx2[i] = x2[i];
            yy1[i] = y1[i];
            yy2[i] = y2[i];
        }
        switch (c)
        {
        case 9:
            idx++;
            if (idx == 9)
                idx = 1;
            variable_space(1);
            break;
        case '+':
            modify_variable(1);
            break;
        case '-':
            modify_variable(0);
            break;
        case 't':
            draw_figure();
            translate(transX, transY);
            draw_figure();
            break;
        case 's':
            draw_figure();
            scale(scaleX, scaleY);
            draw_figure();
            break;
        case 'c':
            draw_figure();
            center_rotate(rotA);
            draw_figure();
            break;
        case 'r':
            draw_figure();
            origin_rotate(rotA);
            draw_figure();
            break;
        case 'x':
            draw_figure();
            Ox_simetry();
            draw_figure();
            break;
        case 'y':
            draw_figure();
            Oy_simetry();
            draw_figure();
            break;
        case 'o':
            draw_figure();
            origin_simetry();
            draw_figure();
            break;
        case 'd':
            draw_figure();
            random_line_simetry(simX, simY, simA);
            draw_figure();
            break;
        case 27:
            gata = 1;
            break;
        case 0:
            c = getch();
            switch (c)
            {
            case 15:
                idx--;
                if (idx == 0)
                    idx = 8;
                variable_space(0);
                break;
            case 80:
                draw_axes();
                if (y < 427)
                    y++;
                draw_axes();
                break;
            case 72:
                draw_axes();
                if (y > 0)
                    y--;
                draw_axes();
                break;
            case 77:
                draw_axes();
                if (x < 638)
                    x++;
                draw_axes();
                break;
            case 75:
                draw_axes();
                if (x > 0)
                    x--;
                draw_axes();
                break;
            }
        }
        if (not_on_the_screen())
        {
            draw_figure();
            for (int i = 0; i < DIM; i++)
            {
                x1[i] = xx1[i];
                x2[i] = xx2[i];
                y1[i] = yy1[i];
                y2[i] = yy2[i];
            }
            draw_figure();
        }
    }
    while (!gata);

    closegraph();
}
Beispiel #3
0
static xtk_widget_t*
create_skinned_list(xtk_widget_t *win, skin_t *skin, tcconf_section_t *sec,
                    tchash_table_t *parameters)
{
    int x, y;
    int width, height;
    int i=0;
    char *action = NULL;
    widget_data_t *wd = tcallocdz(sizeof(*wd), NULL, widgetdata_free);
    xtk_widget_t *l;
    int disable = 0;
    int alpha = 0xff, calpha = 0xff;
    char *font, *color, *ccolor = NULL;
    tcconf_section_t *bfnt = NULL;
    tcconf_section_t *fig = NULL;
    int rows, spacing;
    int xs, ys;

    i += tcconf_getvalue(sec, "position", "%d %d", &x, &y);
    i += tcconf_getvalue(sec, "size", "%d %d", &width, &height);

    if((bfnt = tcconf_getsection(sec, "bitmap"))){
        tcconf_setvalue(bfnt, "path", "%s", skin->path);
        i++;
    } else if(tcconf_getvalue(sec, "font", "%s", &font) == 1){
        i++;
    }

    i += tcconf_getvalue(sec, "color", "%s %d", &color, &alpha) > 0;
    i += tcconf_getvalue(sec, "spacing", "%d", &spacing);
    i += tcconf_getvalue(sec, "rows", "%d", &rows);

    if(i != 8){
        return NULL;
    }

    tcconf_getvalue(sec, "current-color", "%s %d", &ccolor, &calpha);

    fig = tcconf_getsection(sec, "background_figure");

    tcconf_getvalue(sec, "action", "%s", &action);

    wd->action = action;
    wd->skin = tcref(skin);
    wd->values = calloc(1, sizeof(char *));

    l = xtk_widget_list_create(win, x, y, width, height);

    if(tcconf_getvalue(sec, "scroll", "%d %d", &xs, &ys) == 2) {
        xtk_widget_list_set_scroll(l, xs, ys);
    }

    if(fig != NULL) {
        tcconf_setvalue(fig, "position", "%d %d", 0, 0);
        tcconf_setvalue(fig, "size", "%d %d", width, height);

        image_t *img = draw_figure(fig);

        xtk_widget_list_set_image(l, img);

        tcfree(img);

        tcfree(fig);
    }

    xtk_widget_list_set_data(l, wd);
    xtk_widget_list_set_action(l, lookup_action);

    if(l) {
        void *c = NULL;
        char *value, *variable;

        if(bfnt){
            xtk_widget_list_set_bitmapfont(l, bfnt);
            tcfree(bfnt);
        } else {
            xtk_widget_list_set_font(l, font);
            free(font);
        }

        xtk_widget_list_set_color(l, color, alpha);
        free(color);

        if(ccolor) {
            xtk_widget_list_set_current_color(l, ccolor, calpha);
            free(ccolor);
        }

        xtk_widget_list_set_spacing(l, spacing);

        xtk_widget_list_set_rows(l, rows);

        while(i = tcconf_nextvalue(sec, "value", &c, "%s %s",
                                   &variable, &value), c) {
            if(i == 2) {
                if(strcmp(variable, "current_position") == 0) {
                    int *val = NULL, *def = NULL;
                    int p;

                    save_varcb(l, list_set_current, "integer", value);
                    register_varwidget(l, list_set_current, "integer",
                                       value);

                    parse_variable("integer", value, (void *)&val,
                                   (void *)&def);
                    if(!val) {
                        if(def) {
                            p = *def;
                            tcfree(def);
                        }
                        val = &p;
                    }

                    list_set_current(l, val);
                } else if(strcmp(variable, "number_of_entries") == 0) {
                    int *val = NULL, *def = NULL;
                    int p;

                    save_varcb(l, list_set_number_of_entries, "integer",
                               value);
                    register_varwidget(l, list_set_number_of_entries,
                                       "integer", value);

                    parse_variable("integer", value, (void *)&val,
                                   (void *)&def);
                    if(!val) {
                        if(def) {
                            p = *def;
                            tcfree(def);
                        }
                        val = &p;
                    }

                    list_set_number_of_entries(l, val);
                } else if(strcmp(variable, "entries") == 0) {
                    void *val = NULL;

                    save_varcb(l, list_set_entries, "string_array",
                               value);
                    register_varwidget(l, list_set_entries,
                                       "string_array", value);

                    parse_variable("string_array", value, &val, NULL);
                    if(val) {
                        list_set_entries(l, val);
                        tcfree(val);
                    }
                }
                free(value);
                free(variable);
            }
        }

        l->on_destroy = destroy_skinned_list;
        if(disable) xtk_widget_disable(l);
    }

    return l;
}
//GLUT display callback
void display( void )
{
  ClearScreen();
  glColor3f(1.0,1.0,1.0);
  draw_figure(data);
}