unlong getcolor(DC *dc, const char *colstr) { char *rgbcs = strdup(colstr); char *freeme = rgbcs; uint8_t value; switch(strlen(colstr)) { case 4: // #rgb case 7: // #rrggbb free(freeme); return _getcolor(dc, colstr); case 9: // #aarrggbb value = 16*hex(colstr[1]) + hex(colstr[2]); rgbcs += 2; break; case 5: // #argb value = hex(colstr[1]) * 17; rgbcs += 1; break; } rgbcs[0] = '#'; unlong result = _getcolor(dc, rgbcs); result = alphaset(result, value); free(freeme); return result; }
void _GrClear( short x1, short y1, short x2, short y2 ) /*===================================================== Clear area of screen in graphics mode. */ { unsigned char prev_mask[ MASK_LEN ]; grcolor prev_colour; short prev_action; prev_action = _setplotaction( _GPSET ); _getfillmask( prev_mask ); _setfillmask( NULL ); prev_colour = _getcolor(); _setcolor( 0 ); _L1Block( x1, y1, x2, y2 ); _setcolor( prev_colour ); _setfillmask( prev_mask ); _setplotaction( prev_action ); }
void Object::draw(QPainter *painter, Matrix m, vector<double> canvsize){ for(std::vector< vector <int> >::iterator i = facets.begin(); i != facets.end(); ++i){ int a = (*i)[0]; int b = (*i)[1]; int c = (*i)[2]; Point n = (p[b] - p[a]) * (p[c] - p[a]); Point l(10000, 20000, 0000); l = m * l - p[a]; Point eye(0, 0, -100); eye = eye - p[a]; if (n.z() > 0) continue; QPointF polygon[i->size()]; int t = 0; for(std::vector <int>::iterator j = i->begin(); j != i->end(); ++j, ++t){ polygon[t] = QPointF(p[*j].x(), p[*j].y()); } painter->setPen(Qt::NoPen); painter->setBrush(_getcolor(n, l, eye)); painter->drawConvexPolygon(polygon, i->size()); } }
/* _pg_chartpie accepts a chart environment variable, three arrays of data, and the number of data items then draws a pie graph based on the contents of the chartenv variable, the current palette, and the styleset variable. */ { short error; short oldcolor; fillmap oldfillmask; short x1, y1; short x2, y2; /* Record old settings. */ _getcliprgn( &x1, &y1, &x2, &y2 ); oldcolor = _getcolor(); _getfillmask( &oldfillmask ); error = _pg_analyzepie( env, categories, values, explode, n ); if( error > 100 ) { return( error ); } _CommonSetup( env, NULL, n ); _DrawPie( env, values, explode, n ); if( env->legend.legend ) { _DrawLegendWindow( env, categories, n ); } /* Reset graphics attributes. */ _setcliprgn( x1, y1, x2, y2 ); _setcolor( oldcolor );