Beispiel #1
0
//---------------------------------------------------------------------------
void uv_image::draw(vector<GLuint> * clist)
{
   if(!get_visible())
      return;

   if(retranslate)
   {
      glNewList(stranslation, GL_COMPILE);
      glTranslatef(get_x(), get_y(), 0);
      glEndList();

      glNewList(etranslation, GL_COMPILE);
      glTranslatef(-1*get_x(), -1*get_y(), 0);
      glEndList();

      retranslate = false;
   }

   if(redraw)
   {
      glNewList(drawing, GL_COMPILE);
      glColor3f(1, 1, 1);
      if(picx == -1)
         draw_size(0, 0, get_w(), get_h());
      else
         draw_size(0, 0, get_w(), get_h(), picx, picy, picw, pich);
      glEndList();

      redraw = false;
   }

   clist->push_back(stranslation);
   clist->push_back(drawing);
   clist->push_back(etranslation);
};
Beispiel #2
0
static void do_replay(void)
{
    HDC dc;
    struct timeval delay;
    LARGE_INTEGER del;

again:
    if (play_state!=2)
    {
        set_buttons(0);
        CancelWaitableTimer(timer);
        return;
    }
    EnterCriticalSection(&vt_mutex);
    replay_play(&delay);
    draw_size();
    dc=GetDC(termwnd);
    draw_vt(dc, chx*vt->sx, chy*vt->sy, vt);
    ReleaseDC(termwnd, dc);
    LeaveCriticalSection(&vt_mutex);
    set_prog();
    if (play_state!=2)
    {
        set_buttons(1); // finished
        return;
    }
    del.QuadPart=delay.tv_sec;
    del.QuadPart*=1000000;
    del.QuadPart+=delay.tv_usec;
    if (del.QuadPart<=0)
        goto again;
    del.QuadPart*=-10;
    SetWaitableTimer(timer, &del, 0, 0, 0, 0);
    set_buttons(0);
}
Beispiel #3
0
void
label_draw(const struct rich_text *rich, struct pack_label * l, struct srt *srt, const struct sprite_trans *arg) {
	shader_texture(Tex, 0);
	uint32_t color = label_get_color(l, arg);
	const char *str = rich->text;

	char utf8[7];
	int i;
	int ch = 0, w = 0, cy = 0, pre = 0, char_cnt = 0, idx = 0;
	for (i=0; str && str[i];) {
		int unicode;
		int len = unicode_len(str[i]);
		unicode = copystr(utf8, str+i, len);
		i+=len;
		w += draw_size(unicode, utf8, l->size, l->edge) + l->space_w;
		if (ch == 0) {
				ch = draw_height(unicode, utf8, l->size, l->edge) + l->space_h;
		}
		
		float space_scale=1.0;
		uint32_t lf = get_rich_filed_lf(rich, idx, &space_scale);
		if((l->auto_scale == 0 && lf) || unicode == '\n') {
				draw_line(rich, l, srt, arg, color, cy, w, pre, i, &char_cnt, space_scale);
				cy += ch;
				pre = i;
				w = 0; ch = 0;
		}
		idx++;
	}
    
	draw_line(rich, l, srt, arg, color, cy, w, pre, i, &char_cnt, 1.0);
}
Beispiel #4
0
static void redraw_term(void)
{
    HDC dc;

    EnterCriticalSection(&vt_mutex);
    draw_size();
    dc=GetDC(termwnd);
    draw_vt(dc, chx*vt->sx, chy*vt->sy, vt);
    ReleaseDC(termwnd, dc);
    LeaveCriticalSection(&vt_mutex);
}
Beispiel #5
0
void
label_draw(const char *str, struct pack_label * l, struct srt *srt, const struct sprite_trans *arg) {
	shader_texture(Tex);
	uint32_t color;
	if (arg->color == 0xffffffff) {
		color = l->color;
	}
	else if (l->color == 0xffffffff){
		color = arg->color;
	} else {
		color = color_mul(l->color, arg->color);
	}

	char utf8[7];
	int i;
    int ch = 0, w = 0, cy = 0, pre = 0;
	for (i=0; str[i];) {
		int unicode;
		uint8_t c = (uint8_t)str[i];
		if ((c&0x80) == 0) {
			unicode = copystr(utf8,str+i,1);
			i+=1;
		} else if ((c&0xe0) == 0xc0) {
			unicode = copystr(utf8,str+i,2);
			i+=2;
		} else if ((c&0xf0) == 0xe0) {
			unicode = copystr(utf8,str+i,3);
			i+=3;
		} else if ((c&0xf8) == 0xf0) {
			unicode = copystr(utf8,str+i,4);
			i+=4;
		} else if ((c&0xfc) == 0xf8) {
			unicode = copystr(utf8,str+i,5);
			i+=5;
		} else {
			unicode = copystr(utf8,str+i,6);
			i+=6;
		}
		w += draw_size(unicode, utf8, l->size);
        if (ch == 0) {
            ch = draw_height(unicode, utf8, l->size);
        }
        
        if(w > l->width || unicode == '\n') {
            draw_line(str, l, srt, arg, color, cy, w, pre, i);
            cy += ch;
            pre = i;
            w = 0; ch = 0;
        }
	}
    
    draw_line(str, l, srt, arg, color, cy, w, pre, i);
}
Beispiel #6
0
cairo_surface_t *draw_fractal(void)
{
	static cairo_surface_t *surface = 0;

	if (surface)
		return surface;

	struct lsys_opts *o = get_lsys_opts();
	const struct lsys_limits *l = get_lsys_limits();

	double width;
	double height;
	
	draw_size(&width, &height);

	surface = cairo_image_surface_create(CAIRO_FORMAT_A8, width, height);

	cr = cairo_create(surface);

	double area_width  = l->max_x - l->min_x + (2 * MARGIN);
	double area_height = l->max_y - l->min_y + (2 * MARGIN);

	cairo_scale(cr, width / area_width, height / area_height);

#define ABS(a) (((a) < 0) ? -(a) : (a))

	cairo_translate(cr,
			ABS(l->min_x - MARGIN),
			ABS(l->min_y - MARGIN));

	cairo_set_line_width(cr, (l->max_x - l->min_x) * 0.001);

	/* Paint! */
	cairo_save(cr);
	cairo_set_source_rgb(cr, 0, 0, 0);
	draw_rule('#', 0);
	compute_figure(o->axiom, o->depth, draw_rule);
	cairo_stroke(cr);
	cairo_restore(cr);

	cairo_destroy(cr);

	return surface;
}
Beispiel #7
0
void draw_menu_full(void)
{
	draw_edge();
	draw_logo();
	draw_color_list();
	draw_init_size();
	draw_direction();
	draw_speed();
	draw_function();
	draw_control_buttons();
	draw_io_buttons();
	draw_size();
	draw_steps();
	draw_labels();
	wnoutrefresh(menuw);

	if (dialogw) {
		draw_dialog();
	}
}
Beispiel #8
0
int APIENTRY WinMain(HINSTANCE instance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    inst = instance;

    win32_init();

    speed=1000;
    play_f=-1;
    play_state=-1;
    tsx=tsy=0;

    defsx=80;
    defsy=25;

    vt=tty_init(defsx, defsy, 1);
    vt->cp437=1;

    if (*lpCmdLine=='"')        // FIXME: proper parsing
    {
        strncpy(filename, lpCmdLine+1, MAXFILENAME-1);
        filename[strlen(filename)-1]=0;
    }
    else
        strncpy(filename, lpCmdLine, MAXFILENAME-1);
    filename[MAXFILENAME-1]=0;

    create_window(nCmdShow);

    print_banner();
    draw_size();
    UpdateWindow(wndMain);

    ttr=0;

    if (*filename)
        if (!start_file(filename))
        {
            tty_printf(vt, "\n\e[41;1mFile not found: %s\e[0m\n", filename);
            *filename=0;
            redraw_term();
        }