// alanwu: Draw functions void draw_line(char * image, int r, int g, int b, int x1, int y1, int x2, int y2) { // Distance start and end point int dx = x2 - x1; int dy = y2 - y1; // Determine sign for direction x int incx = 0; if (dx < 0) { dx = -dx; incx = -1; } else if (dx > 0) { incx = 1; } // Determine sign for direction y int incy = 0; if (dy < 0) { dy = -dy; incy = -1; } else if (dy > 0) { incy = 1; } // Which gradient is larger int pdx, pdy, odx, ody, es, el; if (dx > dy) { pdx = incx; pdy = 0; odx = incx; ody = incy; es = dy; el = dx; } else { pdx = 0; pdy = incy; odx = incx; ody = incy; es = dx; el = dy; } // Init start int x = x1; int y = y1; int error = el >> 1; if (x < 0) x = 0; if (x >= _width) x = _width - 1; if (y < 0) y = 0; if (y >= _height) y = _height - 1; // Walk the line! int i = 0; for (i = 0; i < el; i++) { // Update error term error -= es; // Decide which coord to use if (error < 0) { error += el; x += odx; y += ody; } else { x += pdx; y += pdy; } // Set pixel if (x < 0) x = 0; if (x >= _width) x = _width - 1; if (y < 0) y = 0; if (y >= _height) y = _height - 1; set_color(image, x, y, r, g, b); //texture.SetPixel(x, y, color); //pixel = pixelBuffer + ((y * m_videoWidth + x) * m_videoBPP); //*((int*)pixel) = color; } }
/* PROTO */ void input_send_message(char *arg) { char *msg, *msg_strip, *temp, *sn; char *fullmsg; size_t fullmsg_len; int offset; if (conn->conn == NULL) return; temp = strchr(arg, ' '); if (temp == NULL) { printf("\n"); b_echostr_s(); printf("No message to send.\n"); return; } if (strlen(temp + 1) == 0) { printf("\nNo message to send.\n"); return; } if (conn->netspeak_filter) msg = undo_netspeak(temp + 1); else msg = temp + 1; sn = malloc(temp - arg + 1); sn[temp - arg] = 0; strncpy(sn, arg, temp - arg); fullmsg_len = strlen(msg) + strlen(SEND_FORMAT_BEGIN) + strlen(SEND_FORMAT_END) + 1; fullmsg = malloc(fullmsg_len + 1); snprintf(fullmsg, fullmsg_len, "%s%s%s", SEND_FORMAT_BEGIN, msg, SEND_FORMAT_END); imcomm_im_send_message(conn->conn, sn, fullmsg, 0); free(fullmsg); eraseline(); if (conn->timestamps) { addts(); putchar(' '); offset = 13; } else { offset = 2; } offset += strlen(sn) + 2; set_color(COLOR_OUTGOING_IM); printf("->%s", sn); set_color(0); printf(": "); msg_strip = strip_html(msg); wordwrap_print(msg_strip, offset); free(msg_strip); if (conn->lastsn != NULL) free(conn->lastsn); conn->lastsn = strdup(sn); log_event(EVENT_IMSEND, sn, msg); free(sn); if (conn->netspeak_filter) free(msg); }
void set_builtin_color(enum builtin_color c) { set_color(builtin_colors[c]); }
int parse_it8(const char *filename, chart_t *chart) { int result = 1; cmsHANDLE hIT8 = cmsIT8LoadFromFile(NULL, filename); if(!hIT8) { fprintf(stderr, "error loading IT8 file `%s'\n", filename); goto error; } if(cmsIT8TableCount(hIT8) != 1) { fprintf(stderr, "error with the IT8 file, we only support files with one table at the moment\n"); goto error; } dt_colorspaces_color_profile_type_t color_space = DT_COLORSPACE_NONE; int column_SAMPLE_ID = -1, column_X = -1, column_Y = -1, column_Z = -1, column_L = -1, column_a = -1, column_b = -1; char **sample_names = NULL; int n_columns = cmsIT8EnumDataFormat(hIT8, &sample_names); if(n_columns == -1) { fprintf(stderr, "error with the IT8 file, can't get column types\n"); goto error; } for(int i = 0; i < n_columns; i++) { if(!g_strcmp0(sample_names[i], "SAMPLE_ID")) column_SAMPLE_ID = i; else if(!g_strcmp0(sample_names[i], "XYZ_X")) column_X = i; else if(!g_strcmp0(sample_names[i], "XYZ_Y")) column_Y = i; else if(!g_strcmp0(sample_names[i], "XYZ_Z")) column_Z = i; else if(!g_strcmp0(sample_names[i], "LAB_L")) column_L = i; else if(!g_strcmp0(sample_names[i], "LAB_A")) column_a = i; else if(!g_strcmp0(sample_names[i], "LAB_B")) column_b = i; } if(column_SAMPLE_ID == -1) { fprintf(stderr, "error with the IT8 file, can't find the SAMPLE_ID column\n"); goto error; } char *columns[3] = { 0 }; if(column_X != -1 && column_Y != -1 && column_Z != -1) { color_space = DT_COLORSPACE_XYZ; columns[0] = "XYZ_X"; columns[1] = "XYZ_Y"; columns[2] = "XYZ_Z"; } else if(column_L != -1 && column_a != -1 && column_b != -1) { color_space = DT_COLORSPACE_LAB; columns[0] = "LAB_L"; columns[1] = "LAB_A"; columns[2] = "LAB_B"; } else { fprintf(stderr, "error with the IT8 file, can't find XYZ or Lab columns\n"); goto error; } GHashTableIter table_iter; gpointer key, value; g_hash_table_iter_init(&table_iter, chart->box_table); while(g_hash_table_iter_next(&table_iter, &key, &value)) { box_t *box = (box_t *)value; if(cmsIT8GetData(hIT8, key, "SAMPLE_ID") == NULL) { fprintf(stderr, "error with the IT8 file, can't find sample `%s'\n", (char *)key); goto error; } set_color(box, color_space, cmsIT8GetDataDbl(hIT8, key, columns[0]), cmsIT8GetDataDbl(hIT8, key, columns[1]), cmsIT8GetDataDbl(hIT8, key, columns[2])); } fprintf(stderr, "it8 `%s' done\n", filename); goto end; error: result = 0; end: if(hIT8) cmsIT8Free(hIT8); return result; }
void draw_graphics(struct gps_data_t *gpsdata) { int i, x, y; char buf[20]; if (gpsdata->satellites != 0) { i = (int)min(width, height); set_color("White"); (void)XFillRectangle(XtDisplay(draww),pixmap,drawGC,0,0,width,height); /* draw something in the center */ set_color("Grey"); draw_arc(width / 2, height / 2, 6); /* draw the 45 degree circle */ #ifdef PCORRECT #define FF 0.7 /* sin(45) ~ 0.7 */ #else #define FF 0.5 #endif draw_arc(width / 2, height / 2, (unsigned)((i - RM) * FF)); #undef FF set_color("Black"); draw_arc(width / 2, height / 2, (unsigned)(i - RM)); pol2cart(0, 0, &x, &y); set_color("Black"); (void)XDrawString(XtDisplay(draww),pixmap, drawGC, x, y, "N", 1); pol2cart(90, 0, &x, &y); set_color("Black"); (void)XDrawString(XtDisplay(draww),pixmap, drawGC, x+2, y, "E", 1); pol2cart(180, 0, &x, &y); set_color("Black"); (void)XDrawString(XtDisplay(draww),pixmap, drawGC, x, y+10, "S", 1); pol2cart(270, 0, &x, &y); set_color("Black"); (void)XDrawString(XtDisplay(draww),pixmap, drawGC, x-5,y, "W", 1); /* Now draw the satellites... */ for (i = 0; i < gpsdata->satellites; i++) { pol2cart((double)gpsdata->azimuth[i], (double)gpsdata->elevation[i], &x, &y); if (gpsdata->ss[i] < 10) set_color("Black"); else if (gpsdata->ss[i] < 30) set_color("Red"); else if (gpsdata->ss[i] < 35) set_color("Yellow"); else if (gpsdata->ss[i] < 40) set_color("Green3"); else set_color("Green1"); if (gpsdata->PRN[i] > GPS_PRNMAX) { /* SBAS satellites */ XPoint vertices[5]; /*@ -type @*/ vertices[0].x = x; vertices[0].y = y-IDIAM; vertices[1].x = x+IDIAM; vertices[1].y = y; vertices[2].x = x; vertices[2].y = y+IDIAM; vertices[3].x = x-IDIAM; vertices[3].y = y; vertices[4].x = x; vertices[4].y = y-IDIAM; /*@ +type -compdef @*/ if (gpsdata->used[i]) (void)XFillPolygon(XtDisplay(draww), pixmap, drawGC, vertices, 5, Convex, CoordModeOrigin); else (void)XDrawLines(XtDisplay(draww), pixmap, drawGC, vertices, 5, CoordModeOrigin); } else { /* ordinary GPS satellites */ if (gpsdata->used[i]) (void)XFillArc(XtDisplay(draww), pixmap, drawGC, x - IDIAM, y - IDIAM, /* x,y */ 2*IDIAM+1, 2*IDIAM+1, /* width, height */ 0, 360 * 64 /* angle1, angle2 */ ); else (void)XDrawArc(XtDisplay(draww), pixmap, drawGC, x - IDIAM, y - IDIAM, /* x,y */ 2*IDIAM+1, 2*IDIAM+1, /* width, height */ 0, 360 * 64 /* angle1, angle2 */ ); } /*@ +compdef @*/ (void)snprintf(buf, sizeof(buf), "%-3d", gpsdata->PRN[i]); set_color("Black"); (void)XDrawString(XtDisplay(draww), pixmap, drawGC, x,y+17, buf,3); } (void)XCopyArea(XtDisplay(draww), pixmap, XtWindow(draww), drawGC, 0, 0, width, height, 0, 0); } }
void textbuffer_line2text(LINE_REC *line, int coloring, GString *str) { unsigned char cmd, *ptr, *tmp; g_return_if_fail(line != NULL); g_return_if_fail(str != NULL); g_string_truncate(str, 0); for (ptr = line->text;;) { if (*ptr != 0) { g_string_append_c(str, (char) *ptr); ptr++; continue; } ptr++; cmd = *ptr; ptr++; if (cmd == LINE_CMD_EOL) { /* end of line */ break; } if (cmd == LINE_CMD_CONTINUE) { /* line continues in another address.. */ memcpy(&tmp, ptr, sizeof(unsigned char *)); ptr = tmp; continue; } if (!coloring) { /* no colors, skip coloring commands */ if (cmd == LINE_COLOR_EXT || cmd == LINE_COLOR_EXT_BG) ptr++; #ifdef TERM_TRUECOLOR else if (cmd == LINE_COLOR_24) ptr+=4; #endif continue; } if ((cmd & LINE_CMD_EOL) == 0) { /* set color */ set_color(str, cmd); } else switch (cmd) { case LINE_CMD_UNDERLINE: g_string_append_c(str, 31); break; case LINE_CMD_REVERSE: g_string_append_c(str, 22); break; case LINE_CMD_BLINK: g_string_append_printf(str, "\004%c", FORMAT_STYLE_BLINK); break; case LINE_CMD_BOLD: g_string_append_printf(str, "\004%c", FORMAT_STYLE_BOLD); break; case LINE_CMD_COLOR0: g_string_append_printf(str, "\004%c%c", '0', FORMAT_COLOR_NOCHANGE); break; case LINE_CMD_INDENT: g_string_append_printf(str, "\004%c", FORMAT_STYLE_INDENT); break; case LINE_COLOR_EXT: format_ext_color(str, 0, *ptr++); break; case LINE_COLOR_EXT_BG: format_ext_color(str, 1, *ptr++); break; #ifdef TERM_TRUECOLOR case LINE_COLOR_24: g_string_append_printf(str, "\004%c", FORMAT_COLOR_24); break; #endif } } }
void cairo_container::draw_borders( litehtml::uint_ptr hdc, const litehtml::borders& borders, const litehtml::position& draw_pos, bool root ) { cairo_t* cr = (cairo_t*) hdc; cairo_save(cr); apply_clip(cr); cairo_new_path(cr); int bdr_top = 0; int bdr_bottom = 0; int bdr_left = 0; int bdr_right = 0; if(borders.top.width != 0 && borders.top.style > litehtml::border_style_hidden) { bdr_top = (int) borders.top.width; } if(borders.bottom.width != 0 && borders.bottom.style > litehtml::border_style_hidden) { bdr_bottom = (int) borders.bottom.width; } if(borders.left.width != 0 && borders.left.style > litehtml::border_style_hidden) { bdr_left = (int) borders.left.width; } if(borders.right.width != 0 && borders.right.style > litehtml::border_style_hidden) { bdr_right = (int) borders.right.width; } // draw right border if (bdr_right) { set_color(cr, borders.right.color); double r_top = (double) borders.radius.top_right_x; double r_bottom = (double) borders.radius.bottom_right_x; if(r_top) { double end_angle = 2.0 * M_PI; double start_angle = end_angle - M_PI / 2.0 / ((double) bdr_top / (double) bdr_right + 0.5); if (!add_path_arc(cr, draw_pos.right() - r_top, draw_pos.top() + r_top, r_top - bdr_right, r_top - bdr_right + (bdr_right - bdr_top), end_angle, start_angle, true)) { cairo_move_to(cr, draw_pos.right() - bdr_right, draw_pos.top() + bdr_top); } if (!add_path_arc(cr, draw_pos.right() - r_top, draw_pos.top() + r_top, r_top, r_top, start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.right(), draw_pos.top()); } } else { cairo_move_to(cr, draw_pos.right() - bdr_right, draw_pos.top() + bdr_top); cairo_line_to(cr, draw_pos.right(), draw_pos.top()); } if(r_bottom) { cairo_line_to(cr, draw_pos.right(), draw_pos.bottom() - r_bottom); double start_angle = 0; double end_angle = start_angle + M_PI / 2.0 / ((double) bdr_bottom / (double) bdr_right + 0.5); if (!add_path_arc(cr, draw_pos.right() - r_bottom, draw_pos.bottom() - r_bottom, r_bottom, r_bottom, start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.right(), draw_pos.bottom()); } if (!add_path_arc(cr, draw_pos.right() - r_bottom, draw_pos.bottom() - r_bottom, r_bottom - bdr_right, r_bottom - bdr_right + (bdr_right - bdr_bottom), end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.bottom() - bdr_bottom); } } else { cairo_line_to(cr, draw_pos.right(), draw_pos.bottom()); cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.bottom() - bdr_bottom); } cairo_fill(cr); } // draw bottom border if(bdr_bottom) { set_color(cr, borders.bottom.color); double r_left = borders.radius.bottom_left_x; double r_right = borders.radius.bottom_right_x; if(r_left) { double start_angle = M_PI / 2.0; double end_angle = start_angle + M_PI / 2.0 / ((double) bdr_left / (double) bdr_bottom + 0.5); if (!add_path_arc(cr, draw_pos.left() + r_left, draw_pos.bottom() - r_left, r_left - bdr_bottom + (bdr_bottom - bdr_left), r_left - bdr_bottom, start_angle, end_angle, false)) { cairo_move_to(cr, draw_pos.left() + bdr_left, draw_pos.bottom() - bdr_bottom); } if (!add_path_arc(cr, draw_pos.left() + r_left, draw_pos.bottom() - r_left, r_left, r_left, end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.left(), draw_pos.bottom()); } } else { cairo_move_to(cr, draw_pos.left(), draw_pos.bottom()); cairo_line_to(cr, draw_pos.left() + bdr_left, draw_pos.bottom() - bdr_bottom); } if(r_right) { cairo_line_to(cr, draw_pos.right() - r_right, draw_pos.bottom()); double end_angle = M_PI / 2.0; double start_angle = end_angle - M_PI / 2.0 / ((double) bdr_right / (double) bdr_bottom + 0.5); if (!add_path_arc(cr, draw_pos.right() - r_right, draw_pos.bottom() - r_right, r_right, r_right, end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.right(), draw_pos.bottom()); } if (!add_path_arc(cr, draw_pos.right() - r_right, draw_pos.bottom() - r_right, r_right - bdr_bottom + (bdr_bottom - bdr_right), r_right - bdr_bottom, start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.bottom() - bdr_bottom); } } else { cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.bottom() - bdr_bottom); cairo_line_to(cr, draw_pos.right(), draw_pos.bottom()); } cairo_fill(cr); } // draw top border if(bdr_top) { set_color(cr, borders.top.color); double r_left = borders.radius.top_left_x; double r_right = borders.radius.top_right_x; if(r_left) { double end_angle = M_PI * 3.0 / 2.0; double start_angle = end_angle - M_PI / 2.0 / ((double) bdr_left / (double) bdr_top + 0.5); if (!add_path_arc(cr, draw_pos.left() + r_left, draw_pos.top() + r_left, r_left, r_left, end_angle, start_angle, true)) { cairo_move_to(cr, draw_pos.left(), draw_pos.top()); } if (!add_path_arc(cr, draw_pos.left() + r_left, draw_pos.top() + r_left, r_left - bdr_top + (bdr_top - bdr_left), r_left - bdr_top, start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.left() + bdr_left, draw_pos.top() + bdr_top); } } else { cairo_move_to(cr, draw_pos.left(), draw_pos.top()); cairo_line_to(cr, draw_pos.left() + bdr_left, draw_pos.top() + bdr_top); } if(r_right) { cairo_line_to(cr, draw_pos.right() - r_right, draw_pos.top() + bdr_top); double start_angle = M_PI * 3.0 / 2.0; double end_angle = start_angle + M_PI / 2.0 / ((double) bdr_right / (double) bdr_top + 0.5); if (!add_path_arc(cr, draw_pos.right() - r_right, draw_pos.top() + r_right, r_right - bdr_top + (bdr_top - bdr_right), r_right - bdr_top, start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.top() + bdr_top); } if (!add_path_arc(cr, draw_pos.right() - r_right, draw_pos.top() + r_right, r_right, r_right, end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.right(), draw_pos.top()); } } else { cairo_line_to(cr, draw_pos.right() - bdr_right, draw_pos.top() + bdr_top); cairo_line_to(cr, draw_pos.right(), draw_pos.top()); } cairo_fill(cr); } // draw left border if (bdr_left) { set_color(cr, borders.left.color); double r_top = borders.radius.top_left_x; double r_bottom = borders.radius.bottom_left_x; if(r_top) { double start_angle = M_PI; double end_angle = start_angle + M_PI / 2.0 / ((double) bdr_top / (double) bdr_left + 0.5); if (!add_path_arc(cr, draw_pos.left() + r_top, draw_pos.top() + r_top, r_top - bdr_left, r_top - bdr_left + (bdr_left - bdr_top), start_angle, end_angle, false)) { cairo_move_to(cr, draw_pos.left() + bdr_left, draw_pos.top() + bdr_top); } if (!add_path_arc(cr, draw_pos.left() + r_top, draw_pos.top() + r_top, r_top, r_top, end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.left(), draw_pos.top()); } } else { cairo_move_to(cr, draw_pos.left() + bdr_left, draw_pos.top() + bdr_top); cairo_line_to(cr, draw_pos.left(), draw_pos.top()); } if(r_bottom) { cairo_line_to(cr, draw_pos.left(), draw_pos.bottom() - r_bottom); double end_angle = M_PI; double start_angle = end_angle - M_PI / 2.0 / ((double) bdr_bottom / (double) bdr_left + 0.5); if (!add_path_arc(cr, draw_pos.left() + r_bottom, draw_pos.bottom() - r_bottom, r_bottom, r_bottom, end_angle, start_angle, true)) { cairo_line_to(cr, draw_pos.left(), draw_pos.bottom()); } if (!add_path_arc(cr, draw_pos.left() + r_bottom, draw_pos.bottom() - r_bottom, r_bottom - bdr_left, r_bottom - bdr_left + (bdr_left - bdr_bottom), start_angle, end_angle, false)) { cairo_line_to(cr, draw_pos.left() + bdr_left, draw_pos.bottom() - bdr_bottom); } } else { cairo_line_to(cr, draw_pos.left(), draw_pos.bottom()); cairo_line_to(cr, draw_pos.left() + bdr_left, draw_pos.bottom() - bdr_bottom); } cairo_fill(cr); } cairo_restore(cr); }
//-------- VOID WYSWIETLAJACY PLANSZE -------- void INTERFACE::wyswietl_drzewo() { system("CLS"); set_color_default(); //SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE | FOREGROUND_INTENSITY ) ; //wyswietlenie pola gry gotoxy(10,2); if (pusty[1]==true) cout<<"~"; else if (statek[1]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(15,2); if (pusty[2]==true) cout<<"~"; else if (statek[2]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(20,2); if (pusty[3]==true) cout<<"~"; else if (statek[3]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(25,2); if (pusty[4]==true) cout<<"~"; else if (statek[4]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(30,2); if (pusty[5]==true) cout<<"~"; else if (statek[5]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(10,4); if (pusty[6]==true) cout<<"~"; else if (statek[6]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(15,4); if (pusty[7]==true) cout<<"~"; else if (statek[7]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(20,4); if (pusty[8]==true) cout<<"~"; else if (statek[8]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(25,4); if (pusty[9]==true) cout<<"~"; else if (statek[9]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(30,4); if (pusty[10]==true) cout<<"~"; else if (statek[10]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(10,6); if (pusty[11]==true) cout<<"~"; else if (statek[11]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(15,6); if (pusty[12]==true) cout<<"~"; else if (statek[12]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(20,6); if (pusty[13]==true) cout<<"~"; else if (statek[13]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(25,6); if (pusty[14]==true) cout<<"~"; else if (statek[14]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(30,6); if (pusty[15]==true) cout<<"~"; else if (statek[15]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(10,8); if (pusty[16]==true) cout<<"~"; else if (statek[16]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(15,8); if (pusty[17]==true) cout<<"~"; else if (statek[17]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(20,8); if (pusty[18]==true) cout<<"~"; else if (statek[18]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(25,8); if (pusty[19]==true) cout<<"~"; else if (statek[19]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(30,8); if (pusty[20]==true) cout<<"~"; else if (statek[20]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(10,10); if (pusty[21]==true) cout<<"~"; else if (statek[21]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(15,10); if (pusty[22]==true) cout<<"~"; else if (statek[22]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(20,10); if (pusty[23]==true) cout<<"~"; else if (statek[23]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(25,10); if (pusty[24]==true) cout<<"~"; else if (statek[24]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; set_color_default(); gotoxy(30,10); if (pusty[25]==true) cout<<"~"; else if (statek[25]==true) set_color_hit(), cout<<"X"; else set_color(),cout<<"P"<<endl; cout<<endl<<endl<<endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15); }
void main(void) { int xy,i,j,c,x,y,front,back,n,minc,maxc; int ix,iy,k,address,jx,jy,kx,ky; float dzdx,dzdy,a,b,dot,norm; float rx,ry,sx,sy,px,py; long p,q; RGB rgb; for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { rx=(float)x/scrwid*2-1; ry=(float)y/scrhei*2-1; sx=rx*.8; sy=ry*.8; px=(sx+1)/2*scrwid; py=(sy+1)/2*scrhei; ix=(int)px; iy=(int)py; amount[x][y][0][0]=((float)ix+1-(float)px)*((float)(iy+1)-(float)py); amount[x][y][1][0]=((float)px-(float)ix)*((float)(iy+1)-(float)py); amount[x][y][0][1]=((float)ix+1-(float)px)*((float)py-(float)iy); amount[x][y][1][1]=((float)px-(float)ix)*((float)py-(float)iy); pix[x][y]=ix; piy[x][y]=iy; // printf("%f",amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]); if (mysquare(amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]-1)>0.00001) { printf("%d %d %f %f ",ix,iy,px,py); printf("%f+%f(%f*%f)+%f+%f=%f? \n",amount[x][y][0][0],amount[x][y][1][0],(float)px-(float)ix,(float)(iy+1)-(float)py,amount[x][y][0][1],amount[x][y][1][1],amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]); } } } // srand(456789); srand((int)time(NULL)); //printf("%d\n",(int)time(NULL)); allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { putpixel(buffer,x,y,128); } } blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); _farsetsel(screen->seg); while(!key[KEY_ESC]) { for (y=0; y<scrhei; y++) { movedata(screen->seg, bmp_read_line(screen,y), _my_ds(), tmp[y], scrwid); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=0; kx=x-scrwid/2; ky=y-scrhei/2; jx=kx*cos(ang)+ky*sin(ang); jy=-kx*sin(ang)+ky*cos(ang); ix=scrwid/2+0.9*jx; iy=scrhei/2+0.9*jy; k=0; i=0;j=0; // for (i=-1;i<=1;i++) { // for (j=-1;j<=1;j++) { // c=c+getpixel(screen, ix+i, iy+j); // address = bmp_read_line(screen, iy)+ix; c=c+tmp[iy][ix]; k++; // } // } c=c/k; c--; // address = bmp_write_line(buffer, y)+x; // _farnspokeb(address, c); tmp2[y][x]=c; // putpixel(buffer, x, y, c); } } for (y=0; y<scrhei; y++) { movedata(_my_ds(), tmp2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (i=1;i<=10;i++) circlefill(screen,myrnd()*scrwid,myrnd()*scrhei,8,myrnd()*255); // putpixel(buffer,scrwid/2,scrhei/2,255); // blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); } destroy_bitmap(buffer); exit(0); getch(); // GrSetMode(GR_default_text); printf("max col %d\n",maxc); printf("min col %d\n",minc); }
void led_uninit(void) { set_color(screen_light, 0xffffffff); }
int AboutPrefs::create_objects() { int x, y; BC_Resources *resources = BC_WindowBase::get_resources(); // add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, // mwindow->theme->preferencestitle_y, // _("About"), // LARGEFONT, // resources->text_default)); x = mwindow->theme->preferencesoptions_x; y = mwindow->theme->preferencesoptions_y + get_text_height(LARGEFONT); set_font(LARGEFONT); set_color(resources->text_default); draw_text(x, y, PROGRAM_NAME " " CINELERRA_VERSION); y += get_text_height(LARGEFONT); set_font(MEDIUMFONT); draw_text(x, y, COPYRIGHTTEXT1 #if defined(COPYRIGHTTEXT2) "\n" COPYRIGHTTEXT2 #endif #if defined(REPOMAINTXT) "\n" REPOMAINTXT #endif ); y += get_text_height(MEDIUMFONT) * 4; char versions[BCTEXTLEN]; sprintf(versions, _("Quicktime version %d.%d.%d (%s)\n" "Libmpeg3 version %d.%d.%d\n"), quicktime_major(), quicktime_minor(), quicktime_release(), FFMPEG_EXTERNALTEXT, mpeg3_major(), mpeg3_minor(), mpeg3_release()); draw_text(x, y, versions); y += get_text_height(MEDIUMFONT) * 3; set_font(LARGEFONT); draw_text(x, y, "Credits:"); y += get_text_height(LARGEFONT); set_font(MEDIUMFONT); char credits[BCTEXTLEN]; sprintf(credits, "Jack Crossfire\n" "Richard Baverstock\n" "Karl Bielefeldt\n" "Kevin Brosius\n" "Jean-Luc Coulon\n" "Jean-Michel POURE\n" "Jerome Cornet\n" "Pierre Marc Dumuid\n" "Alex Ferrer\n" "Jan Gerber\n" "Koen Muylkens\n" "Stefan de Konink\n" "Nathan Kurz\n" "Greg Mekkes\n" "Eric Seigne\n" "Joe Stewart\n" "Dan Streetman\n" #ifdef X_HAVE_UTF8_STRING "Gustavo Iñiguez\n" #else "Gustavo I\361iguez\n" #endif "Johannes Sixt\n" "Mark Taraba\n" "Andraz Tori\n" "Jonas Wulff\n" "David Arendt\n" ); draw_text(x, y, credits); int x_indented; x_indented = x + get_text_width(MEDIUMFONT, "Pierre Marc Dumuid") + 20; char credits_cont1[BCTEXTLEN]; sprintf(credits_cont1, #ifdef X_HAVE_UTF8_STRING "Einar Rünkaru\n" #else "Einar R\374nkaru\n" #endif "Monty Montgomery\n" ); draw_text(x_indented, y, credits_cont1); y = get_h() - 135; set_font(LARGEFONT); draw_text(x, y, "License:"); y += get_text_height(LARGEFONT); set_font(MEDIUMFONT); char license3[BCTEXTLEN]; sprintf(license3, _( "This program is free software; you can redistribute it and/or modify it under the terms\n" "of the GNU General Public License as published by the Free Software Foundation; either version\n" "2 of the License, or (at your option) any later version.\n" "\n" "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n" "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n" "PURPOSE. See the GNU General Public License for more details.\n" "\n")); draw_text(x, y, license3); x = get_w() - mwindow->theme->about_bg->get_w() - 10; y = mwindow->theme->preferencesoptions_y; BC_Pixmap *temp_pixmap = new BC_Pixmap(this, mwindow->theme->about_bg, PIXMAP_ALPHA); draw_pixmap(temp_pixmap, x, y); delete temp_pixmap; x += mwindow->theme->about_bg->get_w() + 10; y += get_text_height(LARGEFONT) * 2; flash(); flush(); return 0; }
void HealthWindow::init() { mesh_.reset(new Rect()); set_color(Vector3f(1.0f, 1.0f, 1.0f)); }
/* redraw channel */ static void statusbar_channel(SBAR_ITEM_REC *item, int ypos) { WINDOW_REC *window; WI_ITEM_REC *witem; CHANNEL_REC *channel; SERVER_REC *server; gchar channame[21], winnum[MAX_INT_STRLEN], *tmpname; int size_needed; int mode_size; window = item->bar->pos != STATUSBAR_POS_MIDDLE ? active_win : mainwindow_find_sbar(item); server = window == NULL ? NULL : window->active_server; ltoa(winnum, window == NULL ? 0 : window->refnum); witem = window != NULL && (IS_CHANNEL(window->active) || IS_QUERY(window->active)) ? window->active : NULL; if (witem == NULL) { /* display server tag */ channame[0] = '\0'; mode_size = 0; channel = NULL; size_needed = 3 + strlen(winnum) + (server == NULL ? 0 : (17+strlen(server->tag))); } else { /* display channel + mode */ tmpname = show_lowascii(witem->name); strncpy(channame, tmpname, 20); channame[20] = '\0'; g_free(tmpname); channel = CHANNEL(witem); if (channel == NULL) { mode_size = 0; } else { mode_size = strlen(channel->mode); if (mode_size > 0) mode_size += 3; /* (+) */ } size_needed = 3 + strlen(winnum) + strlen(channame) + mode_size; } if (item->size != size_needed) { /* we need more (or less..) space! */ statusbar_item_resize(item, size_needed); return; } move(ypos, item->xpos); set_color(stdscr, sbar_color_dim); addch('['); /* window number */ set_color(stdscr, sbar_color_normal); addstr(winnum); set_color(stdscr, sbar_color_dim); addch(':'); if (channame[0] == '\0' && server != NULL) { /* server tag */ set_color(stdscr, sbar_color_normal); addstr(server->tag); addstr(" (change with ^X)"); } else if (channame[0] != '\0') { /* channel + mode */ set_color(stdscr, sbar_color_normal); addstr(channame); if (mode_size) { set_color(stdscr, sbar_color_bold); addch('('); set_color(stdscr, sbar_color_dim); addch('+'); set_color(stdscr, sbar_color_normal); addstr(channel->mode); set_color(stdscr, sbar_color_bold); addch(')'); } } set_color(stdscr, sbar_color_dim); addch(']'); screen_refresh(NULL); }
void Video_GL::init() { std::cout << "Initializing OpenGL" << std::endl; //double buffer, no stencil, no accumulation buffer SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0); if(get_multisampling() > 1) { SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, get_multisampling()); SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1); } set_opengl_flag(true); Video::init(); #if SDL_VERSION_ATLEAST(1,3,0) m_context = SDL_GL_CreateContext(get_window()); #endif { const GLenum err = glewInit(); if(GLEW_OK != err) { std::cerr << "GLEW Error: " << glewGetErrorString(err) << std::endl; throw Video_Init_Failure(); } } // Set Fill/Shade Mode glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_NORMALIZE); //GL_RESCALE_NORMALIZE); // Enable Alpha Blitting glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glBlendEquation(GL_FUNC_ADD); // default // would require ARB ext // Set lighting variables glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); if(glGetError() == GL_INVALID_ENUM) std::cerr << "Quality Warning: Your graphics card does not support separate specular lighting in OpenGL.\n"; // Initialize Assorted Variables glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //glPointSize(static_cast<GLfloat>(sqrt(pow(double(get_screen_width()), 2.) * pow(double(get_screen_height()), 2.)) / 1000000)); //glLineWidth(static_cast<GLfloat>(sqrt(pow(double(get_screen_width()), 2.) * pow(double(get_screen_height()), 2.)) / 1000000)); // Finish with a few function calls set_2d(); set_color(get_color()); set_clear_color(get_clear_color()); set_backface_culling(get_backface_culling()); set_lighting(get_lighting()); set_ambient_lighting(get_ambient_lighting()); set_alpha_test(is_alpha_test_enabled(), get_alpha_test_function(), get_alpha_test_value()); set_zwrite(is_zwrite_enabled()); set_ztest(is_ztest_enabled()); union { void * v; #ifdef _LINUX PFNGLXSWAPINTERVALEXTPROC pglSwapIntervalEXT; PFNGLXSWAPINTERVALSGIPROC pglSwapIntervalSGI; #endif PFNGLBINDBUFFERARBPROC pglBindBufferARB; PFNGLDELETEBUFFERSARBPROC pglDeleteBuffersARB; PFNGLGENBUFFERSARBPROC pglGenBuffersARB; PFNGLBUFFERDATAARBPROC pglBufferDataARB; } ptr; #ifdef _LINUX ptr.v = SDL_GL_GetProcAddress("glXSwapIntervalEXT"); if(!ptr.v) ptr.v = SDL_GL_GetProcAddress("wglSwapIntervalEXT"); m_pglSwapIntervalEXT = ptr.pglSwapIntervalEXT; ptr.v = SDL_GL_GetProcAddress("glXSwapIntervalSGI"); if(!ptr.v) ptr.v = SDL_GL_GetProcAddress("wglSwapIntervalSGI"); m_pglSwapIntervalSGI = ptr.pglSwapIntervalSGI; #endif // Has to be done after finding the function pointer set_vertical_sync(get_vertical_sync()); m_vertex_buffers = strstr(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)), "ARB_vertex_buffer_object") != 0; if(m_vertex_buffers) { ptr.v = SDL_GL_GetProcAddress("glBindBufferARB"); m_pglBindBufferARB = ptr.pglBindBufferARB; ptr.v = SDL_GL_GetProcAddress("glDeleteBuffersARB"); m_pglDeleteBuffersARB = ptr.pglDeleteBuffersARB; ptr.v = SDL_GL_GetProcAddress("glGenBuffersARB"); m_pglGenBuffersARB = ptr.pglGenBuffersARB; ptr.v = SDL_GL_GetProcAddress("glBufferDataARB"); m_pglBufferDataARB = ptr.pglBufferDataARB; } else std::cerr << "Performance Warning: Your graphics card does not offer Vertex Buffer Objects (VBO) in OpenGL.\n"; if(strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_filter_anisotropic")) glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, reinterpret_cast<GLint *>(&m_maximum_anisotropy)); else m_maximum_anisotropy = 0; }
static void print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, long end_col, unsigned int line[]) { unsigned int *p; int x = start_col_real + EDIT_TEXT_HORIZONTAL_OFFSET; int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET; int y = row + EDIT_TEXT_VERTICAL_OFFSET; int cols_to_skip = abs (x); set_color (EDITOR_NORMAL_COLOR); edit_move (x1, y); hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1); edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y); p = line; while (*p) { int style; int textchar; int color; if (cols_to_skip) { p++; cols_to_skip--; continue; } style = *p & 0xFF00; textchar = *p & 0xFF; color = *p >> 16; if (style & MOD_ABNORMAL) { /* Non-printable - use black background */ color = 0; } if (style & MOD_WHITESPACE) { if (style & MOD_MARKED) { textchar = ' '; set_color (EDITOR_MARKED_COLOR); } else { #if 0 if (color != EDITOR_NORMAL_COLOR) { textchar = ' '; lowlevel_set_color (color); } else #endif set_color (EDITOR_WHITESPACE_COLOR); } } else { if (style & MOD_BOLD) { set_color (EDITOR_BOLD_COLOR); } else if (style & MOD_MARKED) { set_color (EDITOR_MARKED_COLOR); } else { lowlevel_set_color (color); } } addch (textchar); p++; } }
/** * Insert node in tree. * * @return the existing key if the key already existed, NULL if the node * was properly inserted. */ void * G_HOT erbtree_insert(erbtree_t *tree, rbnode_t *node) { rbnode_t *key, *parent; const void *kbase; bool is_left; erbtree_check(tree); g_assert(node != NULL); kbase = const_ptr_add_offset(node, -tree->offset); if (erbtree_is_extended(tree)) { key = do_lookup_ext(ERBTREE_E(tree), kbase, &parent, &is_left); } else { key = do_lookup(tree, kbase, &parent, &is_left); } if (key != NULL) return ptr_add_offset(key, -tree->offset); g_assert(!is_valid(node)); /* Not yet part of the tree */ node->left = NULL; node->right = NULL; set_color(node, RB_RED); set_parent(node, parent); tree->count++; if (parent != NULL) { if (is_left) { if (parent == tree->first) tree->first = node; } else { if (parent == tree->last) tree->last = node; } set_child(parent, node, is_left); } else { tree->root = node; tree->first = node; tree->last = node; } /* * Fixup the modified tree by recoloring nodes and performing * rotations (2 at most) hence the red-black tree properties are * preserved. */ while (NULL != (parent = get_parent(node)) && is_red(parent)) { rbnode_t *grandpa = get_parent(parent); if (parent == grandpa->left) { rbnode_t *uncle = grandpa->right; if (uncle != NULL && is_red(uncle)) { set_color(parent, RB_BLACK); set_color(uncle, RB_BLACK); set_color(grandpa, RB_RED); node = grandpa; } else { if (node == parent->right) { rotate_left(tree, parent); node = parent; parent = get_parent(node); } set_color(parent, RB_BLACK); set_color(grandpa, RB_RED); rotate_right(tree, grandpa); } } else { rbnode_t *uncle = grandpa->left; if (uncle != NULL && is_red(uncle)) { set_color(parent, RB_BLACK); set_color(uncle, RB_BLACK); set_color(grandpa, RB_RED); node = grandpa; } else { if (node == parent->left) { rotate_right(tree, parent); node = parent; parent = get_parent(node); } set_color(parent, RB_BLACK); set_color(grandpa, RB_RED); rotate_left(tree, grandpa); } } } set_color(tree->root, RB_BLACK); return NULL; }
/*-------------------------------------------------------------------*/ void tx_message_success() { set_color(RGB(0,0,0)); broadcast_word = false; }
/** * Remove node from tree. * * @attention * It is assumed that the node is already part of the tree. */ void G_HOT erbtree_remove(erbtree_t *tree, rbnode_t *node) { rbnode_t *removed = node; rbnode_t *parent = get_parent(node); rbnode_t *left = node->left; rbnode_t *right = node->right; rbnode_t *next; enum rbcolor color; erbtree_check(tree); g_assert(size_is_positive(tree->count)); g_assert(node != NULL); g_assert(is_valid(node)); /* Does not verify it is part of THIS tree */ tree->count--; if (node == tree->first) tree->first = erbtree_next(node); if (node == tree->last) tree->last = erbtree_prev(node); if (NULL == left) next = right; else if (NULL == right) next = left; else next = get_first(right); if (parent != NULL) set_child(parent, next, parent->left == node); else tree->root = next; if (left != NULL && right != NULL) { color = get_color(next); set_color(next, get_color(node)); next->left = left; set_parent(left, next); if (next != right) { parent = get_parent(next); set_parent(next, get_parent(node)); node = next->right; parent->left = node; next->right = right; set_parent(right, next); } else { set_parent(next, parent); parent = next; node = next->right; } } else { color = get_color(node); node = next; } /* * 'node' is now the sole successor's child and 'parent' its * new parent (since the successor can have been moved). */ if (node != NULL) set_parent(node, parent); invalidate(removed); /* * The "easy" cases. */ if (color == RB_RED) return; if (node != NULL && is_red(node)) { set_color(node, RB_BLACK); return; } do { if (node == tree->root) break; if (node == parent->left) { rbnode_t *sibling = parent->right; if (is_red(sibling)) { set_color(sibling, RB_BLACK); set_color(parent, RB_RED); rotate_left(tree, parent); sibling = parent->right; } if ( (NULL == sibling->left || is_black(sibling->left)) && (NULL == sibling->right || is_black(sibling->right)) ) { set_color(sibling, RB_RED); node = parent; parent = get_parent(parent); continue; } if (NULL == sibling->right || is_black(sibling->right)) { set_color(sibling->left, RB_BLACK); set_color(sibling, RB_RED); rotate_right(tree, sibling); sibling = parent->right; } set_color(sibling, get_color(parent)); set_color(parent, RB_BLACK); set_color(sibling->right, RB_BLACK); rotate_left(tree, parent); node = tree->root; break; } else { rbnode_t *sibling = parent->left; if (is_red(sibling)) { set_color(sibling, RB_BLACK); set_color(parent, RB_RED); rotate_right(tree, parent); sibling = parent->left; } if ( (NULL == sibling->left || is_black(sibling->left)) && (NULL == sibling->right || is_black(sibling->right)) ) { set_color(sibling, RB_RED); node = parent; parent = get_parent(parent); continue; } if (NULL == sibling->left || is_black(sibling->left)) { set_color(sibling->right, RB_BLACK); set_color(sibling, RB_RED); rotate_left(tree, sibling); sibling = parent->left; } set_color(sibling, get_color(parent)); set_color(parent, RB_BLACK); set_color(sibling->left, RB_BLACK); rotate_right(tree, parent); node = tree->root; break; } } while (is_black(node)); if (node != NULL) set_color(node, RB_BLACK); }
void cairo_container::draw_background( litehtml::uint_ptr hdc, const litehtml::background_paint& bg ) { cairo_t* cr = (cairo_t*) hdc; cairo_save(cr); apply_clip(cr); rounded_rectangle(cr, bg.border_box, bg.border_radius); cairo_clip(cr); cairo_rectangle(cr, bg.clip_box.x, bg.clip_box.y, bg.clip_box.width, bg.clip_box.height); cairo_clip(cr); if(bg.color.alpha) { set_color(cr, bg.color); cairo_paint(cr); } std::wstring url; t_make_url(bg.image.c_str(), bg.baseurl.c_str(), url); lock_images_cache(); images_map::iterator img_i = m_images.find(url.c_str()); if(img_i != m_images.end() && img_i->second) { image_ptr bgbmp = img_i->second; image_ptr new_img; if(bg.image_size.width != bgbmp->getWidth() || bg.image_size.height != bgbmp->getHeight()) { new_img = image_ptr(new CTxDIB); bgbmp->resample(bg.image_size.width, bg.image_size.height, new_img.get()); bgbmp = new_img; } cairo_surface_t* img = cairo_image_surface_create_for_data((unsigned char*) bgbmp->getBits(), CAIRO_FORMAT_ARGB32, bgbmp->getWidth(), bgbmp->getHeight(), bgbmp->getWidth() * 4); cairo_pattern_t *pattern = cairo_pattern_create_for_surface(img); cairo_matrix_t flib_m; cairo_matrix_init(&flib_m, 1, 0, 0, -1, 0, 0); cairo_matrix_translate(&flib_m, -bg.position_x, -bg.position_y); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); cairo_pattern_set_matrix (pattern, &flib_m); switch(bg.repeat) { case litehtml::background_repeat_no_repeat: draw_txdib(cr, bgbmp.get(), bg.position_x, bg.position_y, bgbmp->getWidth(), bgbmp->getHeight()); break; case litehtml::background_repeat_repeat_x: cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.clip_box.left(), bg.position_y, bg.clip_box.width, bgbmp->getHeight()); cairo_fill(cr); break; case litehtml::background_repeat_repeat_y: cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.position_x, bg.clip_box.top(), bgbmp->getWidth(), bg.clip_box.height); cairo_fill(cr); break; case litehtml::background_repeat_repeat: cairo_set_source(cr, pattern); cairo_rectangle(cr, bg.clip_box.left(), bg.clip_box.top(), bg.clip_box.width, bg.clip_box.height); cairo_fill(cr); break; } cairo_pattern_destroy(pattern); cairo_surface_destroy(img); } unlock_images_cache(); cairo_restore(cr); }
void main(void) { int i,j,k,c,x,y; RGB rgb; srand((int)time(NULL)); for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { rx=(float)x/scrwid*2-1; ry=(float)(y-scrhei/2)/scrwid*2; px=(qx+1)/2*scrwid; py=scrhei/2+(qy)/2*scrwid; ix=(int)px; iy=(int)py; amount[x][y][0][0]=((float)ix+1-(float)px)*((float)(iy+1)-(float)py); amount[x][y][1][0]=((float)px-(float)ix)*((float)(iy+1)-(float)py); amount[x][y][0][1]=((float)ix+1-(float)px)*((float)py-(float)iy); amount[x][y][1][1]=((float)px-(float)ix)*((float)py-(float)iy); pix[x][y]=ix; piy[x][y]=iy; } } allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); _farsetsel(screen->seg); for (c=0;c<=255;c++) { if (c<128) { rgb.r=c*63/127; rgb.g=0; rgb.b=0; } else { rgb.r=127; rgb.g=(c-128)*63/127; rgb.b=rgb.g; } set_color(c,&rgb); } while(!key[KEY_ESC]) { for (y=0; y<scrhei; y++) { movedata(screen->seg, bmp_read_line(screen,y), _my_ds(), map[y], scrwid); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=0; for (i=0;i<=1;i++) { for (j=0;j<=1;j++) { c=c+amount[x][y][i][j]*map[piy[x][y]+j][pix[x][y]+i]; } } c--; map2[y][x]=c; } } for (y=0; y<scrhei; y++) { movedata(_my_ds(), map2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (i=1;i<=10;i++) { circlefill(screen,myrnd()*scrwid,myrnd()*scrhei,8,myrnd()*255); } } }
// according to cht_format.html from argyll: // "The keywords and associated data must be used in the following order: BOXES, BOX_SHRINK, REF_ROTATION, // XLIST, YLIST and EXPECTED." chart_t *parse_cht(const char *filename) { chart_t *result = (chart_t *)calloc(1, sizeof(chart_t)); int lineno = 0; FILE *fp = fopen(filename, "rb"); if(!fp) { fprintf(stderr, "error opening `%s'\n", filename); ERROR; } // parser control char line[MAX_LINE_LENGTH] = { 0 }; parser_state_t last_block = BLOCK_NONE; int skip_block = 0; // data gathered from the CHT file unsigned int n_boxes; result->d_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free); result->box_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free); result->patch_sets = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_labels_list); float x_min = FLT_MAX, x_max = FLT_MIN, y_min = FLT_MAX, y_max = FLT_MIN; // main loop over the input file while(fgets(line, MAX_LINE_LENGTH, fp)) { if(line[0] == '\0' || line[0] == '\n') { skip_block = 0; continue; } if(skip_block) continue; // we should be at the start of a block now char *c = line; ssize_t len = strlen(line); char *keyword = parse_string(&c); if(!g_strcmp0(keyword, "BOXES") && last_block < BLOCK_BOXES) { last_block = BLOCK_BOXES; if(c - line >= len) ERROR; n_boxes = parse_double(&c); // let's have another loop reading from the file. while(fgets(line, MAX_LINE_LENGTH, fp)) { if(line[0] == '\0' || line[0] == '\n') break; char *c = line; ssize_t len = strlen(line); while(*c == ' ') c++; if(*c == 'F') { float x0, y0, x1, y1, x2, y2, x3, y3; // using sscanf would be nice, but parsign floats does only work with LANG=C // if(sscanf(line, " F _ _ %f %f %f %f %f %f %f %f", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3) != 8) // ERROR; c++; while(*c == ' ') c++; if(*c++ != '_') ERROR; while(*c == ' ') c++; if(*c++ != '_') ERROR; while(*c == ' ') c++; if(c - line >= len) ERROR; x0 = parse_double(&c); if(c - line >= len) ERROR; y0 = parse_double(&c); if(c - line >= len) ERROR; x1 = parse_double(&c); if(c - line >= len) ERROR; y1 = parse_double(&c); if(c - line >= len) ERROR; x2 = parse_double(&c); if(c - line >= len) ERROR; y2 = parse_double(&c); if(c - line >= len) ERROR; x3 = parse_double(&c); if(c - line >= len) ERROR; y3 = parse_double(&c); x_min = MIN(x_min, x0); x_min = MIN(x_min, x1); x_min = MIN(x_min, x2); x_min = MIN(x_min, x3); y_min = MIN(y_min, y0); y_min = MIN(y_min, y1); y_min = MIN(y_min, y2); y_min = MIN(y_min, y3); x_max = MAX(x_max, x0); x_max = MAX(x_max, x1); x_max = MAX(x_max, x2); x_max = MAX(x_max, x3); y_max = MAX(y_max, y0); y_max = MAX(y_max, y1); y_max = MAX(y_max, y2); y_max = MAX(y_max, y3); f_line_t *l = (f_line_t *)malloc(sizeof(f_line_t)); l->p[0].x = x0; l->p[0].y = y0; l->p[1].x = x1; l->p[1].y = y1; l->p[2].x = x2; l->p[2].y = y2; l->p[3].x = x3; l->p[3].y = y3; result->f_list = g_list_append(result->f_list, l); } // these get parsed the same way else if((*c == 'D') || (*c == 'X') || (*c == 'Y')) { char kl, *lxs, *lxe, *lys, *lye; float w, h, xo, yo, xi, yi; kl = *c; *c++ = '\0'; if(c - line >= len) ERROR; lxs = parse_string(&c); if(c - line >= len) ERROR; lxe = parse_string(&c); if(c - line >= len) ERROR; lys = parse_string(&c); if(c - line >= len) ERROR; lye = parse_string(&c); if(c - line >= len) ERROR; w = parse_double(&c); if(c - line >= len) ERROR; h = parse_double(&c); if(c - line >= len) ERROR; xo = parse_double(&c); if(c - line >= len) ERROR; yo = parse_double(&c); if(c - line >= len) ERROR; xi = parse_double(&c); if(c - line >= len) ERROR; yi = parse_double(&c); x_min = MIN(x_min, xo); y_min = MIN(y_min, yo); int x_steps = 1, y_steps = 1; size_t lxs_len = strlen(lxs), lxe_len = strlen(lxe), lys_len = strlen(lys), lye_len = strlen(lye); if(lxs_len > lxe_len || lys_len > lye_len) ERROR; // make sure there is enough room to add another char in the beginning const size_t x_label_size = lxe_len + 1; const size_t y_label_size = lye_len + 1; char *x_label = malloc(x_label_size * sizeof(char)); char *y_label = malloc(y_label_size * sizeof(char)); char *first_label = NULL, *last_label = NULL; GList *labels = NULL; float y = yo; memcpy(y_label, lys, lys_len + 1); while(1) { float x = xo; memcpy(x_label, lxs, lxs_len + 1); while(1) { // build the label of the box char *label; if(!g_strcmp0(x_label, "_")) label = g_strdup(y_label); else if(!g_strcmp0(y_label, "_")) label = g_strdup(x_label); else { if(kl == 'Y') label = g_strconcat(y_label, x_label, NULL); else label = g_strconcat(x_label, y_label, NULL); } if(!first_label) first_label = label; last_label = label; // store it box_t *box = (box_t *)calloc(1, sizeof(box_t)); box->p.x = x; box->p.y = y; box->w = w; box->h = h; box->color_space = DT_COLORSPACE_NONE; // no color for this box yet if(kl == 'D') g_hash_table_insert(result->d_table, label, box); else g_hash_table_insert(result->box_table, label, box); if(kl == 'X' || kl == 'Y') labels = g_list_append(labels, g_strdup(label)); // increment in x direction if(!g_strcmp0(x_label, lxe)) break; x += xi; x_steps++; if(!strinc(x_label, x_label_size)) ERROR; } x_max = MAX(x_max, x + w); // increment in y direction if(!g_strcmp0(y_label, lye)) break; y += yi; y_steps++; if(!strinc(y_label, y_label_size)) ERROR; } y_max = MAX(y_max, y + h); if(kl == 'X' || kl == 'Y') g_hash_table_insert(result->patch_sets, g_strdup_printf("%s .. %s", first_label, last_label), labels); free(y_label); free(x_label); } else ERROR; } if(n_boxes != g_hash_table_size(result->d_table) + g_hash_table_size(result->box_table)) ERROR; // all the box lines are read and we know the bounding box, // so let's scale all the values to have a bounding box with the longer side having length 1 and start // at (0, 0) result->bb_w = x_max - x_min; result->bb_h = y_max - y_min; #define SCALE_X(x) x = (x - x_min) / result->bb_w #define SCALE_Y(y) y = (y - y_min) / result->bb_h GList *iter = result->f_list; while(iter) { f_line_t *f = iter->data; for(int i = 0; i < 4; i++) { SCALE_X(f->p[i].x); SCALE_Y(f->p[i].y); } iter = g_list_next(iter); } GHashTableIter table_iter; gpointer key, value; g_hash_table_iter_init(&table_iter, result->d_table); while(g_hash_table_iter_next(&table_iter, &key, &value)) { box_t *box = (box_t *)value; SCALE_X(box->p.x); SCALE_Y(box->p.y); box->w /= result->bb_w; box->h /= result->bb_h; } g_hash_table_iter_init(&table_iter, result->box_table); while(g_hash_table_iter_next(&table_iter, &key, &value)) { box_t *box = (box_t *)value; SCALE_X(box->p.x); SCALE_Y(box->p.y); box->w /= result->bb_w; box->h /= result->bb_h; } #undef SCALE_X #undef SCALE_Y } else if(!g_strcmp0(keyword, "BOX_SHRINK") && last_block < BLOCK_BOX_SHRINK) { last_block = BLOCK_BOX_SHRINK; if(c - line >= len) ERROR; result->box_shrink = parse_double(&c); } else if(!g_strcmp0(keyword, "REF_ROTATION") && last_block < BLOCK_REF_ROTATION) { last_block = BLOCK_REF_ROTATION; if(c - line >= len) ERROR; result->ref_rotation = parse_double(&c); } else if(!g_strcmp0(keyword, "XLIST") && last_block < BLOCK_XLIST) { last_block = BLOCK_XLIST; // skip until empty line, we don't care about these skip_block = 1; } else if(!g_strcmp0(keyword, "YLIST") && last_block < BLOCK_YLIST) { last_block = BLOCK_YLIST; // skip until empty line, we don't care about these skip_block = 1; } else if(!g_strcmp0(keyword, "EXPECTED") && last_block < BLOCK_EXPECTED) { last_block = BLOCK_EXPECTED; dt_colorspaces_color_profile_type_t color_space = DT_COLORSPACE_NONE; if(c - line >= len) ERROR; char *cs = parse_string(&c); if(c - line >= len) ERROR; unsigned int n_colors = parse_double(&c); if(!g_strcmp0(cs, "XYZ")) color_space = DT_COLORSPACE_XYZ; else if(!g_strcmp0(cs, "LAB")) color_space = DT_COLORSPACE_LAB; else ERROR; // read and store the numbers. // we use them 1) to draw visual hints on the grid and 2) as a fallback reference set // let's have another loop reading from the file. while(fgets(line, MAX_LINE_LENGTH, fp)) { if(line[0] == '\0' || line[0] == '\n') break; n_colors--; ssize_t len = strlen(line); char *c = line; char *label = parse_string(&c); box_t *box = (box_t *)g_hash_table_lookup(result->box_table, label); if(!box) ERROR; if(c - line >= len) ERROR; float c0 = parse_double(&c); if(c - line >= len) ERROR; float c1 = parse_double(&c); if(c - line >= len) ERROR; float c2 = parse_double(&c); set_color(box, color_space, c0, c1, c2); } if(n_colors != 0) ERROR; } else { fprintf(stderr, "unknown keyword `%s'\n", keyword); ERROR; } } fprintf(stderr, "cht `%s' done\n", filename); goto end; error: fprintf(stderr, "error parsing CHT file, (%s:%d)\n", __FUNCTION__, lineno); // clean up free_chart(result); result = NULL; end: if(fp) fclose(fp); return result; }
void cairo_context::set_color(color const &color, double opacity) { set_color(color.red()/255.0, color.green()/255.0, color.blue()/255.0, color.alpha() * opacity / 255.0); }
void CDoProcess::DoProcess(CMData* pData,SubTestResult *testItem) { try { Hobject image = pData->m_Image; Hobject ROI,Circle1,Circle2; if((pData->r_real+m_Parameters.Regional_Out-m_Parameters.ROIWidth)>0) { gen_circle(&Circle1, (pData->m_center_y), (pData->m_center_x), (pData->r_real+m_Parameters.Regional_Out)); gen_circle(&Circle2, (pData->m_center_y), (pData->m_center_x), pData->r_real+m_Parameters.Regional_Out-m_Parameters.ROIWidth); difference(Circle1, Circle2, &ROI); if (ShowObject&&pData->m_isDebug) { set_color(pData->m_ShowHWindow,"blue"); disp_obj(Circle1,pData->m_ShowHWindow); set_color(pData->m_ShowHWindow,"green"); disp_obj(Circle2,pData->m_ShowHWindow); } } else { gen_circle(&ROI, (pData->m_center_y), (pData->m_center_x), (pData->r_real+m_Parameters.Regional_Out)); if (ShowObject&&pData->m_isDebug) { set_color(pData->m_ShowHWindow,"blue"); disp_obj(ROI,pData->m_ShowHWindow); } } // Local iconic variables Hobject region_tai,BlackImageMean,WhiteImageMean; Hobject BlackPointDynThresh, BLACK_POINT, SeriousBlackPointDynThresh; Hobject SeriousBlackConnected, SERIOUS_BlackPoint; Hobject WhitePointDynThresh, WHITE_POINT, SeriousWhitePointDynThresh; Hobject SeriousWhiteConnected, SERIOUS_WhitePoint; Hlong Number; Hobject Dilation,ExpandedImage; reduce_domain(image, ROI, ®ion_tai); expand_domain_gray(region_tai, &ExpandedImage, 2); reduce_domain(ExpandedImage, ROI, ®ion_tai); //*=================================================================== //*找黑色划痕与污点 mean_image(region_tai, &BlackImageMean, m_Parameters.BlackMaskSize, m_Parameters.BlackMaskSize); //*找大范围黑缺陷,适用于缺陷浅以及数量比较多的情况,参数越细,误报越高 dyn_threshold(region_tai, BlackImageMean, &BlackPointDynThresh,m_Parameters.BlackPointDynThresh, "dark"); select_shape(BlackPointDynThresh, &BLACK_POINT, "area", "and", m_Parameters.BlackPointSize, 99999); count_obj(BLACK_POINT, &Number); if (Number) { //pData->m_ErrorRegist = BLACK_POINT; pData->m_isFail =true; testItem->m_bFailSubTest = true; //testItem->m_ErrorMsg = "BlackPoint error"; //return; if (pData->m_isDebug) { dilation_circle(BLACK_POINT,&Dilation,2.5); set_color(pData->m_ShowHWindow,"red"); disp_obj(Dilation,pData->m_ShowHWindow); } } //*找单一块极黑缺陷,适用于伤的比较深,污点比较黑的情况 dyn_threshold(region_tai, BlackImageMean, &SeriousBlackPointDynThresh,m_Parameters.SeriousBlackPointDynThresh, "dark"); connection(SeriousBlackPointDynThresh, &SeriousBlackConnected); select_shape(SeriousBlackConnected, &SERIOUS_BlackPoint, "area", "and",m_Parameters.SeriousBlackPointSize, 99999); count_obj(SERIOUS_BlackPoint, &Number); if (Number) { pData->m_isFail =true; testItem->m_bFailSubTest = true; if (pData->m_isDebug) { dilation_circle(SERIOUS_BlackPoint,&Dilation,2.5); set_color(pData->m_ShowHWindow,"red"); disp_obj(Dilation,pData->m_ShowHWindow); } } //*=================================================================== //*找白色划痕与污点 mean_image(region_tai, &WhiteImageMean, m_Parameters.WhiteMaskSize, m_Parameters.WhiteMaskSize); //*找大范围白缺陷 dyn_threshold(region_tai, WhiteImageMean, &WhitePointDynThresh, m_Parameters.WhitePointDynThresh, "light"); select_shape(WhitePointDynThresh, &WHITE_POINT, "area", "and", m_Parameters.WhitePointSize, 99999); count_obj(WHITE_POINT, &Number); if (Number) { //pData->m_ErrorRegist = WHITE_POINT; pData->m_isFail =true; testItem->m_bFailSubTest = true; //testItem->m_ErrorMsg = "WhitePoint error"; if (pData->m_isDebug) { dilation_circle(WHITE_POINT,&Dilation,2.5); set_color(pData->m_ShowHWindow,"yellow"); disp_obj(Dilation,pData->m_ShowHWindow); } } //*找单一块极白污点 dyn_threshold(region_tai, WhiteImageMean, &SeriousWhitePointDynThresh, m_Parameters.SeriousWhitePointDynThresh, "light"); connection(SeriousWhitePointDynThresh, &SeriousWhiteConnected); select_shape(SeriousWhiteConnected, &SERIOUS_WhitePoint, "area", "and",m_Parameters.SeriousWhitePointSize, 99999); count_obj(SERIOUS_WhitePoint, &Number); if (Number) { //pData->m_ErrorRegist = SERIOUS_WhitePoint; pData->m_isFail =true; testItem->m_bFailSubTest = true; //testItem->m_ErrorMsg = "SeriousWhitePoint error"; if (pData->m_isDebug) { dilation_circle(SERIOUS_WhitePoint,&Dilation,2.5); set_color(pData->m_ShowHWindow,"yellow"); disp_obj(Dilation,pData->m_ShowHWindow); } } Hobject RegionUnionBlack,RegionUnionWhite,RegionUnionWhole; union2(BLACK_POINT, SERIOUS_BlackPoint, &RegionUnionBlack); union2(WHITE_POINT, SERIOUS_WhitePoint, &RegionUnionWhite); union2(RegionUnionBlack, RegionUnionWhite, &RegionUnionWhole); //dilation_circle(RegionUnionWhole, &RegionDilation, 2.5); union2(RegionUnionWhole, pData->m_ErrorRegist, &RegionUnionWhole); pData->m_ErrorRegist=RegionUnionWhole; } catch (HException &except) { if (pData->m_isDebug) { set_color(pData->m_ShowHWindow,"green"); set_tposition( pData->m_ShowHWindow,25, 145); #ifdef _ENGLISH write_string(pData->m_ShowHWindow,"DynThreshed1.3 parameter values error,please re-adjust"); #else write_string(pData->m_ShowHWindow,"DynThreshed1.3程序参数值出错,请重新调节参数"); #endif } pData->m_isFail = true; testItem->m_bFailSubTest = true; } }
void print_baudrate( xbee_serial_t * port) { set_color( SOURCE_STATUS); printf( "[%" PRIu32 " bps]", port->baudrate); fflush( stdout); }
int read_vlines(char *name, char *mapset) { char fullname[GNAME_MAX]; char buf[1024]; char *key, *data, *dp; double width; int itmp, vec; int r, g, b; int ret; struct Map_info Map; vector_alloc(); /* allocate space */ sprintf(fullname, "%s in %s", name, mapset); Vect_set_open_level(2); Vect_set_fatal_error(GV_FATAL_PRINT); if (2 > Vect_open_old(&Map, name, mapset)) { error(fullname, "", "can't open vector map"); gobble_input(); return 0; } Vect_close(&Map); vec = vector.count; vector.layer[vec].type = VLINES; vector.layer[vec].name = G_store(name); vector.layer[vec].mapset = G_store(mapset); vector.layer[vec].ltype = GV_LINE; vector.layer[vec].masked = 0; vector.layer[vec].field = 1; vector.layer[vec].cats = NULL; vector.layer[vec].where = NULL; vector.layer[vec].width = 1.; vector.layer[vec].cwidth = 0.; vector.layer[vec].offset = 0.; vector.layer[vec].coffset = 0.; set_color(&(vector.layer[vec].color), 0, 0, 0); vector.layer[vec].rgbcol = NULL; vector.layer[vec].linestyle = NULL; vector.layer[vec].linecap = LINECAP_BUTT; vector.layer[vec].ref = LINE_REF_CENTER; vector.layer[vec].hwidth = 0.; unset_color(&(vector.layer[vec].hcolor)); vector.layer[vec].label = NULL; vector.layer[vec].lpos = -1; vector.layer[vec].pwidth = 1.; while (input(2, buf, help)) { if (!key_data(buf, &key, &data)) continue; if (KEY("masked")) { vector.layer[vec].masked = yesno(key, data); if (vector.layer[vec].masked) PS.mask_needed = 1; continue; } if (KEY("type")) { G_strip(data); vector.layer[vec].ltype = 0; if (strstr(data, "line")) vector.layer[vec].ltype |= GV_LINE; if (strstr(data, "boundary")) vector.layer[vec].ltype |= GV_BOUNDARY; continue; } if (KEY("layer")) { G_strip(data); vector.layer[vec].field = atoi(data); continue; } if (KEY("cats")) { G_strip(data); vector.layer[vec].cats = G_store(data); continue; } if (KEY("where")) { G_strip(data); vector.layer[vec].where = G_store(data); continue; } if (KEY("style")) { G_strip(data); if (strcmp(data, "solid") == 0) { vector.layer[vec].linestyle = NULL; continue; } else if (strcmp(data, "dashed") == 0) { vector.layer[vec].linestyle = G_store("000000111"); continue; } else if (strcmp(data, "dotted") == 0) { vector.layer[vec].linestyle = G_store("100000"); continue; } else if (strcmp(data, "dashdotted") == 0) { vector.layer[vec].linestyle = G_store("000000111011111"); continue; } for (dp = data; *dp; dp++) if (*dp < '0' || *dp > '9') break; if (*dp != 0 || dp == data) { error(key, data, "illegal line style (vlines)"); continue; } vector.layer[vec].linestyle = G_store(data); continue; } if (KEY("linecap")) { G_strip(data); if (strcmp(data, "butt") == 0) { vector.layer[vec].linecap = LINECAP_BUTT; continue; } else if (strcmp(data, "round") == 0) { vector.layer[vec].linecap = LINECAP_ROUND; continue; } else if (strcmp(data, "extended_butt") == 0) { vector.layer[vec].linecap = LINECAP_EXTBUTT; continue; } else error(key, data, "illegal line cap (vlines)"); continue; } if (KEY("width")) { width = -1.; *mapset = 0; if (sscanf(data, "%lf%s", &width, mapset) < 1 || width < 0.) { width = 1.; error(key, data, "illegal width (vlines)"); continue; } if (mapset[0] == 'i') width = width / 72.; vector.layer[vec].width = width; continue; } if (KEY("cwidth")) { width = -1.; *mapset = 0; if (sscanf(data, "%lf%s", &width, mapset) < 1 || width < 0.) { width = 1.; error(key, data, "illegal cwidth (vlines)"); continue; } if (mapset[0] == 'i') width = width / 72.; vector.layer[vec].cwidth = width; continue; } if (KEY("offset")) { *mapset = 0; if (sscanf(data, "%lf%s", &width, mapset) < 1) { width = 0.; error(key, data, "illegal offset (vlines)"); continue; } if (mapset[0] == 'i') width = width / 72.; vector.layer[vec].offset = width; continue; } if (KEY("coffset")) { *mapset = 0; if (sscanf(data, "%lf%s", &width, mapset) < 1) { width = 0.; error(key, data, "illegal coffset (vlines)"); continue; } if (mapset[0] == 'i') width = width / 72.; vector.layer[vec].coffset = width; continue; } if (KEY("hwidth")) { width = -1.; if (sscanf(data, "%lf%s", &width, mapset) < 1 || width < 0.) { width = 0.; error(key, data, "illegal hwidth (vlines)"); continue; } if (mapset[0] == 'i') width = width / 72.; vector.layer[vec].hwidth = width; continue; } if (KEY("color")) { ret = G_str_to_color(data, &r, &g, &b); if (ret == 1) set_color(&(vector.layer[vec].color), r, g, b); else if (ret == 2) unset_color(&(vector.layer[vec].color)); else error(key, data, "illegal color request (vlines)"); continue; } if (KEY("rgbcolumn")) { G_strip(data); vector.layer[vec].rgbcol = G_store(data); continue; } if (KEY("hcolor")) { ret = G_str_to_color(data, &r, &g, &b); if (ret == 1) set_color(&(vector.layer[vec].hcolor), r, g, b); else if (ret == 2) unset_color(&(vector.layer[vec].hcolor)); else error(key, data, "illegal hcolor request (vlines)"); continue; } if (KEY("label")) { /* map legend label */ G_strip(data); vector.layer[vec].label = G_store(data); continue; } if (KEY("lpos")) { if (sscanf(data, "%d", &itmp) < 1 || itmp < 0) { itmp = -1; error(key, data, "illegal lpos (vlines)"); continue; } vector.layer[vec].lpos = itmp; continue; } if (KEY("ref")) { G_strip(data); if (strcmp(data, "left") == 0) { vector.layer[vec].ref = LINE_REF_LEFT; continue; } if (strcmp(data, "right") == 0) { vector.layer[vec].ref = LINE_REF_RIGHT; continue; } error(key, data, "illegal ref request (vlines)"); continue; } if (KEY("scale")) { G_strip(data); vector.layer[vec].scale = atof(data); continue; } error(key, "", "illegal request (vlines)"); } vector.count++; return 1; }
void xbee_term( xbee_serial_t *port) { int ch, retval; char buffer[40]; // set up the console for nonblocking xbee_term_console_init(); puts( "Simple XBee Terminal"); puts( "CTRL-X to EXIT, CTRL-K toggles break, CTRL-R toggles RTS, " "TAB changes bps."); print_baudrate( port); set_rts( port, RTS_ASSERT); check_cts( port); puts( ""); for (;;) { check_cts( port); ch = xbee_term_getchar(); if (ch == CTRL('X')) { break; // exit terminal } else if (ch == CTRL('R')) { set_rts( port, RTS_TOGGLE); } else if (ch == CTRL('K')) { set_break( port, BREAK_TOGGLE); } else if (ch == CTRL('I')) // tab { next_baudrate( port); } else if (ch > 0) { // Pass all characters out serial port, converting LF to CR // since XBee expects CR for line endings. xbee_ser_putchar( port, ch == '\n' ? '\r' : ch); // Only print printable characters or CR, LF or backspace to stdout. if (isprint( ch) || ch == '\r' || ch == '\n' || ch == '\b') { set_color( SOURCE_KEYBOARD); // stdout expects LF for line endings putchar( ch == '\r' ? '\n' : ch); fflush( stdout); } } retval = xbee_ser_read( port, buffer, sizeof buffer); if (retval > 0) { dump_serial_data( buffer, retval); } } xbee_term_console_restore(); puts( ""); }
void ParametricWindow::create_objects() { int y = 35; SET_TRACE add_subwindow(new BC_Title(X1, 10, _("Freq"))); add_subwindow(new BC_Title(X2, 10, _("Qual"))); add_subwindow(new BC_Title(X3, 10, _("Level"))); add_subwindow(new BC_Title(X4, 10, _("Mode"))); for(int i = 0; i < BANDS; i++) { bands[i] = new ParametricBandGUI(plugin, this, 10, y, i); bands[i]->create_objects(); y += 50; } SET_TRACE BC_Title *title; int x = plugin->get_theme()->widget_border; add_subwindow(title = new BC_Title(x, y + 10, _("Wetness:"))); x += title->get_w() + plugin->get_theme()->widget_border; add_subwindow(wetness = new ParametricWetness(plugin, x, y)); x += wetness->get_w() + plugin->get_theme()->widget_border; add_subwindow(title = new BC_Title(x, y + 10, _("Window:"))); x += title->get_w() + plugin->get_theme()->widget_border; add_subwindow(size = new ParametricSize(this, plugin, x, y + 10)); size->create_objects(); size->update(plugin->config.window_size); y += 50; int canvas_x = 30; int canvas_y = y; int canvas_w = get_w() - canvas_x - 10; int canvas_h = get_h() - canvas_y - 30; add_subwindow(canvas = new BC_SubWindow(canvas_x, canvas_y, canvas_w, canvas_h, BLACK)); SET_TRACE // Draw canvas titles set_font(SMALLFONT); #define MAJOR_DIVISIONS 4 #define MINOR_DIVISIONS 5 for(int i = 0; i <= MAJOR_DIVISIONS; i++) { int y1 = canvas_y + canvas_h - i * (canvas_h / MAJOR_DIVISIONS) - 2; int y2 = y1 + 3; int x1 = canvas_x - 25; int x2 = canvas_x - 10; int x3 = canvas_x - 2; char string[BCTEXTLEN]; if(i == 0) sprintf(string, "oo"); else sprintf(string, "%d", i * 5 - 5); set_color(BLACK); draw_text(x1 + 1, y2 + 1, string); draw_line(x2 + 1, y1 + 1, x3 + 1, y1 + 1); set_color(RED); draw_text(x1, y2, string); draw_line(x2, y1, x3, y1); if(i < MAJOR_DIVISIONS) { for(int j = 1; j < MINOR_DIVISIONS; j++) { int y3 = y1 - j * (canvas_h / MAJOR_DIVISIONS) / MINOR_DIVISIONS; int x4 = x3 - 5; set_color(BLACK); draw_line(x4 + 1, y3 + 1, x3 + 1, y3 + 1); set_color(RED); draw_line(x4, y3, x3, y3); } } } SET_TRACE #undef MAJOR_DIVISIONS #define MAJOR_DIVISIONS 5 for(int i = 0; i <= MAJOR_DIVISIONS; i++) { int freq = Freq::tofreq(i * TOTALFREQS / MAJOR_DIVISIONS); int x1 = canvas_x + i * canvas_w / MAJOR_DIVISIONS; int y1 = canvas_y + canvas_h + 20; char string[BCTEXTLEN]; sprintf(string, "%d", freq); int x2 = x1 - get_text_width(SMALLFONT, string); int y2 = y1 - 10; int y3 = y2 - 5; int y4 = canvas_y + canvas_h; set_color(BLACK); draw_text(x2 + 1, y1 + 1, string); draw_line(x1 + 1, y4 + 1, x1 + 1, y2 + 1); set_color(RED); draw_text(x2, y1, string); draw_line(x1, y4, x1, y2); if(i < MAJOR_DIVISIONS) { #undef MINOR_DIVISIONS #define MINOR_DIVISIONS 5 for(int j = 0; j < MINOR_DIVISIONS; j++) { int x3 = (int)(x1 + (canvas_w / MAJOR_DIVISIONS) - exp(-(double)j * 0.7) * (canvas_w / MAJOR_DIVISIONS)); set_color(BLACK); draw_line(x3 + 1, y4 + 1, x3 + 1, y3 + 1); set_color(RED); draw_line(x3, y4, x3, y3); } } } SET_TRACE update_canvas(); show_window(); SET_TRACE }
void ps_printer::set_char(int i, font *f, const environment *env, int w, const char *) { if (i == space_char_index || invis_count > 0) return; unsigned char code; subencoding *sub = set_subencoding(f, i, &code); style sty(f, sub, env->size, env->height, env->slant); if (sty.slant != 0) { if (sty.slant > 80 || sty.slant < -80) { error("silly slant `%1' degrees", sty.slant); sty.slant = 0; } } if (sbuf_len > 0) { if (sbuf_len < SBUF_SIZE && sty == sbuf_style && sbuf_vpos == env->vpos && sbuf_color == *env->col) { if (sbuf_end_hpos == env->hpos) { sbuf[sbuf_len++] = code; sbuf_end_hpos += w + sbuf_kern; return; } if (sbuf_len == 1 && sbuf_kern == 0) { sbuf_kern = env->hpos - sbuf_end_hpos; sbuf_end_hpos = env->hpos + sbuf_kern + w; sbuf[sbuf_len++] = code; return; } /* If sbuf_end_hpos - sbuf_kern == env->hpos, we are better off starting a new string. */ if (sbuf_len < SBUF_SIZE - 1 && env->hpos >= sbuf_end_hpos && (sbuf_kern == 0 || sbuf_end_hpos - sbuf_kern != env->hpos)) { if (sbuf_space_code < 0) { if (f->contains(space_char_index)) { sbuf_space_code = f->get_code(space_char_index); sbuf_space_width = env->hpos - sbuf_end_hpos; sbuf_end_hpos = env->hpos + w + sbuf_kern; sbuf[sbuf_len++] = sbuf_space_code; sbuf[sbuf_len++] = code; sbuf_space_count++; return; } } else { int diff = env->hpos - sbuf_end_hpos - sbuf_space_width; if (diff == 0 || (equalise_spaces && (diff == 1 || diff == -1))) { sbuf_end_hpos = env->hpos + w + sbuf_kern; sbuf[sbuf_len++] = sbuf_space_code; sbuf[sbuf_len++] = code; sbuf_space_count++; if (diff == 1) sbuf_space_diff_count++; else if (diff == -1) sbuf_space_diff_count--; return; } } } } flush_sbuf(); } sbuf_len = 1; sbuf[0] = code; sbuf_end_hpos = env->hpos + w; sbuf_start_hpos = env->hpos; sbuf_vpos = env->vpos; sbuf_style = sty; sbuf_space_code = -1; sbuf_space_width = 0; sbuf_space_count = sbuf_space_diff_count = 0; sbuf_kern = 0; if (sbuf_color != *env->col) set_color(env->col); }
/* redraw nick */ static void statusbar_nick(SBAR_ITEM_REC *item, int ypos) { CHANNEL_REC *channel; IRC_SERVER_REC *server; NICK_REC *nickrec; int size_needed; int umode_size; gchar nick[10]; server = (IRC_SERVER_REC *) (active_win == NULL ? NULL : active_win->active_server); umode_size = server == NULL || server->usermode == NULL ? 0 : strlen(server->usermode)+3; /* nick */ if (server == NULL || server->nick == NULL) { nick[0] = '\0'; nickrec = NULL; } else { strncpy(nick, server->nick, 9); nick[9] = '\0'; channel = irc_item_channel(active_win->active); nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick); } size_needed = 2 + strlen(nick) + umode_size + (server != NULL && server->usermode_away ? 7 : 0) + (nickrec != NULL && (nickrec->op || nickrec->voice) ? 1 : 0); /* @ + */ if (item->size != size_needed) { /* we need more (or less..) space! */ statusbar_item_resize(item, size_needed); return; } /* size ok, draw the nick */ move(ypos, item->xpos); set_color((1 << 4)+3); addch('['); if (nickrec != NULL && (nickrec->op || nickrec->voice)) { set_color((1 << 4)+15); addch(nickrec->op ? '@' : '+'); } set_color((1 << 4)+7); addstr(nick); if (umode_size) { set_color((1 << 4)+15); addch('('); set_color((1 << 4)+3); addch('+'); set_color((1 << 4)+7); addstr(server->usermode); set_color((1 << 4)+15); addch(')'); if (server->usermode_away) { set_color((1 << 4)+7); addstr(" ("); set_color((1 << 4)+10); addstr("zZzZ"); set_color((1 << 4)+7); addch(')'); } } set_color((1 << 4)+3); addch(']'); screen_refresh(); }
/* plot a colour smooth box bounded by the terminal's integer coordinates [x_from,y_from] to [x_to,y_to]. This routine is for non-postscript files, as it does an explicit loop over all thin rectangles */ static void draw_inside_color_smooth_box_bitmap(FILE * out) { int steps = 128; /* I think that nobody can distinguish more colours drawn in the palette */ int i, j, xy, xy2, xy_from, xy_to; int jmin = 0; double xy_step, gray, range; gpiPoint corners[4]; (void) out; /* to avoid "unused parameter" warning */ if (color_box.rotation == 'v') { corners[0].x = corners[3].x = color_box.bounds.xleft; corners[1].x = corners[2].x = color_box.bounds.xright; xy_from = color_box.bounds.ybot; xy_to = color_box.bounds.ytop; xy_step = (color_box.bounds.ytop - color_box.bounds.ybot) / (double)steps; } else { corners[0].y = corners[1].y = color_box.bounds.ybot; corners[2].y = corners[3].y = color_box.bounds.ytop; xy_from = color_box.bounds.xleft; xy_to = color_box.bounds.xright; xy_step = (color_box.bounds.xright - color_box.bounds.xleft) / (double)steps; } range = (xy_to - xy_from); for (i = 0, xy2 = xy_from; i < steps; i++) { /* Start from one pixel beyond the previous box */ xy = xy2; xy2 = xy_from + (int) (xy_step * (i + 1)); /* Set the colour for the next range increment */ /* FIXME - The "1 +" seems wrong, yet it improves the placement in gd */ gray = (double)(1 + xy - xy_from) / range; if (sm_palette.positive == SMPAL_NEGATIVE) gray = 1 - gray; set_color(gray); /* If this is a defined palette, make sure that the range increment */ /* does not straddle a palette segment boundary. If it does, split */ /* it into two parts. */ if (sm_palette.colorMode == SMPAL_COLOR_MODE_GRADIENT) for (j=jmin; j<sm_palette.gradient_num; j++) { int boundary = xy_from + (int)(sm_palette.gradient[j].pos * range); if (xy >= boundary) { jmin = j; } else { if (xy2 > boundary) { xy2 = boundary; i--; break; } } if (xy2 < boundary) break; } if (color_box.rotation == 'v') { corners[0].y = corners[1].y = xy; corners[2].y = corners[3].y = GPMIN(xy_to,xy2+1); } else { corners[0].x = corners[3].x = xy; corners[1].x = corners[2].x = GPMIN(xy_to,xy2+1); } #ifdef EXTENDED_COLOR_SPECS if (supply_extended_color_specs) corners[0].spec.gray = -1; /* force solid color */ #endif /* print the rectangle with the given colour */ if (default_fillstyle.fillstyle == FS_EMPTY) corners->style = FS_OPAQUE; else corners->style = style_from_fill(&default_fillstyle); term->filled_polygon(4, corners); } }