+void ScopeGUI::draw_graticule()
+{
+ 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);
+ }
+ else if( use_vector < 0 ) {
+ if( grad_image && grad_idx != use_graticule ) {
+ delete grad_image; grad_image = 0;
+ use_graticule = 0;
+ }
+ if( !grad_image && grad_idx > 0 ) {
+ grad_image = VFramePng::vframe_png(grad_paths[grad_idx]);
+ }
+ int rr = 2*radius;
+ if( grad_pixmap && (!use_graticule ||
+ rr != grad_pixmap->get_w() || rr != grad_pixmap->get_h()) ) {
+ delete grad_pixmap; grad_pixmap = 0;
+ use_graticule = 0;
+ }
+ if( !grad_pixmap && grad_image ) {
+ VFrame grad(rr, rr, BC_RGBA8888);
+ grad.transfer_from(grad_image);
+ grad_pixmap = new BC_Pixmap(this, &grad, PIXMAP_ALPHA);
+ use_graticule = grad_idx;
+ }
+ if( grad_pixmap ) {
+ int px = vector_cx - radius, py = vector_cy - radius;
+ vectorscope->draw_pixmap(grad_pixmap, px, py);
+// vectorscope->flash(0);
+ }
+ }
+}
+
+
+void ScopeGUI::update_graticule(int idx)
+{
+ grad_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;
+ }
+ }
+}