void wheel2(const char *fn, int nres, char *resnm[], real rot0, char *title) { const real fontsize = 14; const real gray = 0.9; const real fontasp = 0.45; const int angle = 9; const real fontwidth = fontsize*fontasp; t_psdata out; int i, slen; real ring, inner, outer; real xc, yc, box; inner = 60.0; slen = 0; for (i = 0; (i < nres); i++) { slen = std::max(slen, static_cast<int>(strlen(resnm[i]))); } fprintf(stderr, "slen = %d\n", slen); ring = slen*fontwidth; outer = inner+ring; box = (1+(nres / (2*angle)))*outer; out = ps_open(fn, 0, 0, 2.0*box, 2.0*box); xc = box; yc = box; ps_font(out, efontHELV, 1.5*fontsize); ps_translate(out, xc, yc); ps_color(out, 0, 0, 0); if (title) { ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter); } ps_font(out, efontHELV, fontsize); ps_rotate(out, rot0); for (i = 0; (i < nres); ) { if ((i % 5) == 4) { ps_color(out, gray, gray, 1.0); ps_fillarcslice(out, 0, 0, inner, outer, -angle, angle); ps_color(out, 0, 0, 0); } ps_arcslice(out, 0, 0, inner, outer, -angle, angle); ps_ctext(out, inner+fontwidth, -fontsize/2.0, resnm[i], eXLeft); ps_rotate(out, -2*angle); i++; if ((i % (2*angle)) == 0) { inner = outer; outer += ring; } } ps_close(out); }
int ps_drotate(t_ps *ps) { if (!ps->a || !ps->b || !ps->a->next || !ps->b->next) return (0); ps_rotate(ps, 'a'); ps_rotate(ps, 'b'); return (build_steps(ps, RR)); }
void init_context (ps_context* gc, ps_canvas* cs, unsigned char* buf) { float version = (float)ps_version() / 10000; fprintf(stderr, "picasso version %.2f\n", version); pa = ps_path_create(); pm = ps_matrix_create(); ps_translate(gc, 203, 35); ps_rotate(gc, 0.32f); }
static int sub2_ps_optiop(t_ps *ps, int op_num, int op_max, int p) { int c; if (p != PA && (c = ps_push(ps, 'b'))) { if (ps_optiop(ps, 1 + op_num, op_max, c)) return (1); ps_push(ps, 'a'); } if (p != RRA && p != RRR && (c = ps_rotate(ps, 'a'))) { if (ps_optiop(ps, 1 + op_num, op_max, c)) return (1); ps_rrotate(ps, 'a'); } if (p != RA && p != RR && (c = ps_rrotate(ps, 'a'))) { if (ps_optiop(ps, 1 + op_num, op_max, c)) return (1); ps_rotate(ps, 'a'); } return (0); }
void wheel(const char *fn, int nres, char *resnm[], int r0, real rot0, char *title) { const real fontsize = 16; const real gray = 0.9; const real fontasp = 0.6; const real fontwidth = fontsize*fontasp; t_psdata out; int i, sl, slen; real ring, inner, outer; real xc, yc, box; gmx_bool *bPh; char **rnms; char sign; inner = 75.0; slen = 0; snew(rnms, nres); for (i = 0; (i < nres); i++) { snew(rnms[i], 256); sl = std::strlen(resnm[i]); sign = resnm[i][sl-1]; if ((sign == '+') || (sign == '-')) { resnm[i][sl-1] = '\0'; } sprintf(rnms[i], "%s-%d", resnm[i], i+r0); if ((sign == '+') || (sign == '-')) { sl = std::strlen(rnms[i]); rnms[i][sl] = sign; rnms[i][sl+1] = '\0'; } slen = std::max(slen, static_cast<int>(std::strlen(rnms[i]))); } ring = (2+slen)*fontwidth; outer = inner+ring; box = inner*1.5+(1+(nres / 18))*ring; bPh = bPhobics(nres, resnm); out = ps_open(fn, 0, 0, 2.0*box, 2.0*box); xc = box; yc = box; ps_font(out, efontHELV, 1.5*fontsize); ps_translate(out, xc, yc); if (title) { ps_ctext(out, 0, -fontsize*1.5/2.0, title, eXCenter); } ps_font(out, efontHELV, fontsize); ps_rotate(out, rot0); for (i = 0; (i < nres); ) { if (bPh[i]) { ps_color(out, gray, gray, gray); ps_fillarcslice(out, 0, 0, inner, outer, -10, 10); ps_color(out, 0, 0, 0); } ps_arcslice(out, 0, 0, inner, outer, -10, 10); ps_ctext(out, inner+fontwidth, -fontsize/2.0, rnms[i], eXLeft); ps_rotate(out, -100); i++; if ((i % 18) == 0) { inner = outer; outer += ring; } } ps_close(out); }
void draw_test (int id, ps_context* gc) { // int i; // double w; ps_font* old; // ps_size ts; // ps_font_info info; // ps_glyph g[5]; ps_glyph tg; // ps_point s1; // ps_point e1; ps_color c1= {1, 0, 0, 0.8f}; ps_color c2= {0, 0, 1, 0.8f}; //ps_color x = {0, 0, 0, 1}; ps_rect r = {150, 150, 400, 250}; /* ps_rect er = {150, 50, 100, 100}; ps_reset_clip(gc); ps_ellipse(gc, &er); ps_clip(gc); */ ps_point s = {100, 100}; ps_point e = {250, 100}; // ps_set_shadow(gc, 1, 1, 0.15f); // ps_set_shadow_color(gc, &x); ps_translate(gc, -200, -200); ps_rotate(gc, 0.02f); ps_translate(gc, 200, 200); // ps_set_text_antialias(gc, False); // double ds[] = {5, 3.1, 1.2, 5.5}; // ps_set_line_dash(gc, 0, ds, 4); ps_move_to(gc, &s); ps_line_to(gc, &e); ps_stroke(gc); // ps_set_text_render_type(gc, TEXT_TYPE_MONO); ps_set_text_matrix(gc, pn); ps_text_out_length(gc, 100, 100, text, strlen(text)); /* if (a) { // ps_font_set_size(pf, 16); ps_set_text_color(gc, &c1); a = 0; } else { // ps_font_set_size(pf, 26); ps_set_text_color(gc, &c2); a = 1; } */ //ps_matrix_rotate(pm, 0.13); ps_set_text_matrix(gc, pm); //ps_font_set_weight(pf, w); ps_set_text_color(gc, &c1); ps_set_text_stroke_color(gc, &c2); ps_rectangle(gc, &r); ps_stroke(gc); // ps_wide_text_out_length(gc, 200, 100, wtext, 5); old = ps_set_font(gc, pf); //ts = ps_text_extent(gc, wtext, 5); //fprintf(stderr, "w: %.2f - h: %.2f \n", ts.w, ts.h); /// s1.x = s1.y = 150; // e1.y = 150; // e1.x = 150 + ts.w; // ps_move_to(gc, &s1); // ps_line_to(gc, &e1); // ps_stroke(gc); ps_draw_text(gc, &r, wtext, 5, DRAW_TEXT_STROKE, TEXT_ALIGN_LEFT | TEXT_ALIGN_TOP); //ps_set_source_gradient(gc, gr); //ps_set_source_image(gc, pi); ps_set_source_pattern(gc, pt); ps_get_glyph(gc, 0x56fe, &tg); // ts = ps_glyph_extent(&tg); //fprintf(stderr, "w: %.2f - h: %.2f \n", ts.w, ts.h); ps_get_path_from_glyph(gc, &tg, pa); ps_set_path(gc, pa); ps_fill(gc); // ps_get_font_info(gc, &info); //fprintf(stderr, "h: %.2f - a: %.2f - d: %.2f - l: %.2f \n", info.size, info.ascent, info.descent, info.leading); ps_set_font(gc, old); ps_set_text_render_type(gc, TEXT_TYPE_STROKE); /* for (i=0; i<5; i++) ps_get_glyph(gc, gtext[i], &g[i]); ps_show_glyphs(gc, 200, 200, g, 5); */ }
void on_draw(ps_context* gc) { int i; ps_color color = {1, 1, 1, 1}; ps_set_source_color(gc, &color); ps_clear(gc); ps_set_line_cap(gc, LINE_CAP_BUTT); ps_set_composite_operator(gc, COMPOSITE_SRC_OVER); ps_identity(gc); ps_set_matrix(gc, adjust); ps_scale(gc, (float)scale, (float)scale); // draw background ps_set_source_gradient(gc, shadowGradient); ps_set_path(gc, shadowPath); ps_fill(gc); // draw quadrant ps_set_source_gradient(gc, quadrantGradient); ps_set_path(gc, quadrantPath); ps_fill(gc); ps_identity(gc); ps_scale(gc, (float)scale, (float)scale); // draw inner bevel ps_set_source_gradient(gc, bevelsGradient); ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD); ps_set_path(gc, innerBevelPath); ps_fill(gc); ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)PI); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_source_gradient(gc, bevelsGradient); ps_set_fill_rule(gc, FILL_RULE_EVEN_ODD); ps_set_path(gc, outerBevelPath); ps_fill(gc); // draw seconds tags { ps_color sc = {0.11f, 0.12f, 0.13f, 0.65f}; ps_set_line_width(gc, 2.0f); ps_set_line_cap(gc, LINE_CAP_ROUND); ps_set_stroke_color(gc, &sc); for (i = 0; i < 60; i++) { if ((i % 5) != 0) { ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, 2 * PI - ((float)i/60.0f) * PI * 2); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondTagPath); ps_stroke(gc); } } // draw hours and milliseconds tags for (i = 0; i < 12; i++) { float rot = 2 * PI - (((float)i / 12.0f) * PI * 2); ps_set_line_width(gc, 7.0); ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)rot); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourTagPath); ps_stroke(gc); ps_set_line_width(gc, 2.0); ps_identity(gc); ps_translate(gc, -356, -256); ps_rotate(gc, (float)rot); ps_translate(gc, 356, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, msTagPath); ps_stroke(gc); } } //draw cursors { time_t ctime; struct tm *ltime; ctime = time(NULL); ltime = localtime(&ctime); drawCursors(gc, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, millsecons); } //draw glass { ps_color gcol = {0.04f, 0.045f, 0.05f, 0.8f}; ps_identity(gc); ps_set_matrix(gc, adjust); ps_scale(gc, (float)scale, (float)scale); ps_set_composite_operator(gc, COMPOSITE_PLUS); ps_set_source_color(gc, &gcol); ps_set_path(gc, glassPath); ps_fill(gc); } }
static void drawCursors(ps_context*gc, unsigned hours, unsigned minutes, unsigned seconds, unsigned milliseconds) { float hh, mm, ss, ks; ps_color col; if (hours < 13) hh = (((float)hours / 12.0f + (float)minutes / 720.0f) * PI * 2) - PI; else hh = (((float)(hours - 12.0f) / 12.0f + (float)minutes / 720.0f) * PI * 2) - PI; mm = (((float)minutes / 60.0f + (float)seconds / 3600.0f) * 2 * PI) - PI; ss = (((float)seconds / 60.0f) * 2 * PI) - PI; ks = (((float)milliseconds / 1000.0f) * 2 * PI) - PI; // milliseconds col.r = 0.0f; col.g = 0.2f; col.b = 0.6f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -356, -256); ps_rotate(gc, (float)ks); ps_translate(gc, 356, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, msCursorPath); ps_fill(gc); // seconds shadow col.r = 0.3f; col.g = 0.3f; col.b = 0.3f; col.a = 0.25f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -255, -257); ps_rotate(gc, (float)ss); ps_translate(gc, 255, 257); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondCursorPath); ps_fill(gc); // minutes shadow ps_identity(gc); ps_translate(gc, -255.5f, -256.5f); ps_scale(gc, 1.25f, 1.01f); ps_rotate(gc, (float)mm); ps_translate(gc, 255.5f, 256.5f); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, minuteCursorPath); ps_fill(gc); // hours shadow ps_identity(gc); ps_translate(gc, -255.5f, -256.5f); ps_scale(gc, 1.25f, 1.01f); ps_rotate(gc, (float)hh); ps_translate(gc, 255.5f, 256.5f); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourCursorPath); ps_fill(gc); // hours col.r = 0.2f; col.g = 0.2f; col.b = 0.22f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -256, -256); ps_rotate(gc, (float)hh); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, hourCursorPath); ps_fill(gc); // draw screw ps_identity(gc); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, cursorScrewPath); ps_fill(gc); // minutes ps_identity(gc); ps_translate(gc, -256, -256); ps_rotate(gc, (float)mm); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, minuteCursorPath); ps_fill(gc); // seconds col.r = 0.65f; col.g = 0.1f; col.b = 0.075f; col.a = 1.0f; ps_identity(gc); ps_set_source_color(gc, &col); ps_translate(gc, -256, -256); ps_rotate(gc, (float)ss); ps_translate(gc, 256, 256); ps_scale(gc, (float)scale, (float)scale); ps_set_path(gc, secondCursorPath); ps_fill(gc); }