GdkPixbuf *render_get_colour_scale(size_t w, size_t h, int scale) { guchar *data; size_t x, y; int max; data = malloc(3*w*h); if ( data == NULL ) return NULL; max = h; for ( y=0; y<h; y++ ) { double r, g, b; int val; val = y; render_scale(val, max, scale, &r, &g, &b); data[3*( 0+w*(h-1-y) )+0] = 0; data[3*( 0+w*(h-1-y) )+1] = 0; data[3*( 0+w*(h-1-y) )+2] = 0; for ( x=1; x<w; x++ ) { data[3*( x+w*(h-1-y) )+0] = 255*r; data[3*( x+w*(h-1-y) )+1] = 255*g; data[3*( x+w*(h-1-y) )+2] = 255*b; } } return gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, FALSE, 8, w, h, w*3, render_free_data, NULL); }
void GLGizmoRotate::on_render(const Selection& selection) const { if (!m_grabbers[0].enabled) return; const BoundingBoxf3& box = selection.get_bounding_box(); std::string axis; switch (m_axis) { case X: { axis = "X"; break; } case Y: { axis = "Y"; break; } case Z: { axis = "Z"; break; } } if (!m_dragging && (m_hover_id == 0)) set_tooltip(axis); else if (m_dragging) set_tooltip(axis + ": " + format((float)Geometry::rad2deg(m_angle), 4) + "\u00B0"); else { m_center = box.center(); m_radius = Offset + box.radius(); m_snap_coarse_in_radius = m_radius / 3.0f; m_snap_coarse_out_radius = 2.0f * m_snap_coarse_in_radius; m_snap_fine_in_radius = m_radius; m_snap_fine_out_radius = m_radius * (1.0f + ScaleLongTooth); } glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glPushMatrix()); transform_to_local(selection); glsafe(::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f)); glsafe(::glColor3fv((m_hover_id != -1) ? m_drag_color : m_highlight_color)); render_circle(); if (m_hover_id != -1) { render_scale(); render_snap_radii(); render_reference_radius(); } glsafe(::glColor3fv(m_highlight_color)); if (m_hover_id != -1) render_angle(); render_grabber(box); render_grabber_extension(box, false); glsafe(::glPopMatrix()); }
static GdkPixbuf *render_panel(float *hdr, int scale, double max, int w, int h) { guchar *data; int x, y; /* Rendered (colourful) version */ data = malloc(3*w*h); if ( data == NULL ) return NULL; /* These x,y coordinates are measured relative to the bottom-left * corner */ for ( y=0; y<h; y++ ) { for ( x=0; x<w; x++ ) { double val; double r, g, b; val = hdr[x+w*y]; if ( val > -INFINITY ) { render_scale(val, max, scale, &r, &g, &b); /* Stuff inside square brackets makes this pixel go to * the expected location in the pixbuf (which measures * from the top-left corner */ data[3*( x+w*y )+0] = 255*r; data[3*( x+w*y )+1] = 255*g; data[3*( x+w*y )+2] = 255*b; } else { data[3*( x+w*y )+0] = 30; data[3*( x+w*y )+1] = 20; data[3*( x+w*y )+2] = 0; } } } /* Create the pixbuf from the 8-bit display data */ return gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, FALSE, 8, w, h, w*3, render_free_data, NULL); }