+void ScopeGUI::draw_scope()
+{
+ int graticule = use_vector < 0 ? grat_idx : 0;
+ if( grat_image && use_graticule != graticule ) {
+ delete grat_image; grat_image = 0;
+ }
+ if( !grat_image && graticule > 0 )
+ grat_image = VFramePng::vframe_png(grat_paths[graticule]);
+ if( grat_image ) {
+ if( !overlay )
+ overlay = new OverlayFrame(1);
+ int cx = vector_cx, cy = vector_cy, r = radius;
+ int iw = grat_image->get_w(), ih = grat_image->get_h();
+ overlay->overlay(vector_vframe, grat_image,
+ 0,0, iw, ih, cx-r,cy-r, cx+r, cy+r,
+ 1, TRANSFER_NORMAL, CUBIC_CUBIC);
+ }
+ use_graticule = graticule;
+ vectorscope->draw_vframe(vector_vframe);
+ if( use_vector > 0 ) {
+ int margin = theme->widget_border;
+ set_line_dashes(1);
+ for( int i=1; i<=VECTORSCOPE_DIVISIONS; i+=2 ) {
+ int y = vector_cy - radius * i / VECTORSCOPE_DIVISIONS;
+ int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
+ set_color(text_color);
+ char string[BCTEXTLEN];
+ sprintf(string, "%d",
+ (int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
+ int text_x = vector_x - get_text_width(SMALLFONT, string) - margin;
+ draw_text(text_x, text_y, string);
+ int x = vector_cx - radius * i / VECTORSCOPE_DIVISIONS;
+ int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
+ int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
+ if( i+2 > VECTORSCOPE_DIVISIONS )
+ set_line_dashes(0);
+ set_color(dark_color);
+ vectorscope->draw_circle(x, y, w, h);
+ }
+ float th = TO_RAD(90 + 32.875);
+ vectorscope->draw_radient(th, 0.1f, .75f, dark_color);
+ }
+}
+
+
+void ScopeGUI::update_graticule(int idx)
+{
+ grat_idx = idx;
+ update_scope();
+ toggle_event();
+}
+
+void ScopeGUI::draw_colorwheel(VFrame *dst, int bg_color)
+{
+// downfactor radius to prevent extreme edge from showing behind graticule
+ float cx = vector_cx, cy = vector_cy, rad = radius * 0.99;
+ int color_model = dst->get_color_model();
+ int bpp = BC_CModels::calculate_pixelsize(color_model);
+ int bg_r = (bg_color>>16) & 0xff;
+ int bg_g = (bg_color>> 8) & 0xff;
+ int bg_b = (bg_color>> 0) & 0xff;
+ int w = dst->get_w(), h = dst->get_h();
+ unsigned char **rows = dst->get_rows();
+ for( int y=0; y<h; ++y ) {
+ unsigned char *row = rows[y];
+ for( int x=0; x<w; ++x,row+=bpp ) {
+ int dx = cx-x, dy = cy-y;
+ float d = sqrt(dx*dx + dy*dy);
+ float r, g, b;
+ if( d < rad ) {
+ float h = TO_DEG(atan2(cx-x, cy-y));
+ if( h < 0 ) h += 360;
+ float s = d / rad, v = 255;
+ HSV::hsv_to_rgb(r, g, b, h, s, v);
+ }
+ else {
+ r = bg_r; g = bg_g; b = bg_b;
+ }
+ row[0] = r; row[1] = g; row[2] = b; row[3] = 0xff;
+ }
+ }
+}