const char* obj_data :: condition_name( char_data* ch, bool ansi ) { static char tmp [ ONE_LINE ]; int i; const char* txt; i = 1000*condition/pIndexData->durability; i = range( 0, i/100, 9 ); if( i == 0 ) txt = "worthless"; else if( i == 1 ) txt = "damaged"; else if( i == 2 ) txt = "very worn"; else if( i == 3 ) txt = "worn"; else if( i == 4 ) txt = "very scratched"; else if( i == 5 ) txt = "scratched"; else if( i == 6 ) txt = "reasonable"; else if( i == 7 ) txt = "good"; else if( i == 8 ) txt = "very good"; else txt = "excellent"; if( !ansi || ch->pcdata == NULL || ch->pcdata->terminal != TERM_ANSI ) return txt; sprintf( tmp, "%s%s%s", i > 4 ? ( i > 7 ? blue( ch ) : green( ch ) ) : ( i > 2 ? yellow( ch ) : red( ch ) ), txt, normal( ch ) ); return tmp; }
void erln8_log( const gchar* log_domain, GLogLevelFlags log_level, const gchar* message, gpointer user_data ) { switch(log_level & G_LOG_LEVEL_MASK) { case G_LOG_FLAG_RECURSION: case G_LOG_LEVEL_CRITICAL: case G_LOG_LEVEL_ERROR: fprintf(stderr, "%s", red()); fprintf(stderr, "ERROR: %s",message); fprintf(stderr, "%s", color_reset()); exit(-1); break; case G_LOG_LEVEL_WARNING: fprintf(stderr, "%s", yellow()); fprintf(stderr, "WARNING: %s",message); fprintf(stderr, "%s", color_reset()); break; case G_LOG_LEVEL_INFO: case G_LOG_LEVEL_MESSAGE: fprintf(stderr, "INFO: %s",message); break; case G_LOG_LEVEL_DEBUG: if(opt_debug) { fprintf(stderr, "DEBUG: %s",message); } break; default: fprintf(stderr, "%s", red()); fprintf(stderr, "UNHANDLED: %s",message); fprintf(stderr, "%s", color_reset()); break; } return; }
void decode_arp(const u_char * packet) { struct arphdr * arp_t; arp_t = (struct arphdr*)packet; V(1, "ARP %s ", str_arp_op(htons(arp_t->ar_op))); VV(0, "Protocol : %s\n", str_arp_pro(htons(arp_t->ar_pro))); VVV(1, "Hardware Type : %s\n", str_arp_hw(htons(arp_t->ar_hrd))); const u_char * arp_data = packet + sizeof(struct arphdr); u_char * hwd_addr = malloc(sizeof(arp_t->ar_hln)); u_char * pro_addr = malloc(sizeof(arp_t->ar_pln)); struct ether_addr mac,mac2; struct in_addr ip, ip2; memcpy(hwd_addr, arp_data, arp_t->ar_hln); memcpy(pro_addr, arp_data + arp_t->ar_hln, arp_t->ar_pln); VV(1, "From : "); if(htons(arp_t->ar_hrd) == 0x01 && arp_t->ar_hln == ETH_ALEN) { memcpy(&(mac.ether_addr_octet), hwd_addr, ETH_ALEN); VV(0, "%s (", ether_ntoa(&mac)); } if(htons(arp_t->ar_pro) == 0x0800 && arp_t->ar_pln == 0x04) { memcpy(&(ip.s_addr), pro_addr, arp_t->ar_pln); VV(0, "%s)\n", inet_ntoa(ip)); } memcpy(hwd_addr, arp_data + arp_t->ar_hln + arp_t->ar_pln, arp_t->ar_hln); memcpy(pro_addr, arp_data + 2*arp_t->ar_hln + arp_t->ar_pln, arp_t->ar_pln); VV(1, "To : "); if(htons(arp_t->ar_hrd) == 0x01 && arp_t->ar_hln == ETH_ALEN) { memcpy(&(mac2.ether_addr_octet), hwd_addr, ETH_ALEN); VV(0, "%s (", ether_ntoa(&mac2)); } if(htons(arp_t->ar_pro) == 0x0800 && arp_t->ar_pln == 0x04) { memcpy(&(ip2.s_addr), pro_addr, arp_t->ar_pln); VV(0, "%s)\n", inet_ntoa(ip2)); } char buffer[128]; bzero(buffer, 128); char * yellow_str; if(htons(arp_t->ar_op) == ARPOP_REQUEST) { sprintf(buffer, "Who is %s ? (to %s [%s])\n", inet_ntoa(ip2), inet_ntoa(ip), ether_ntoa(&mac)); } else if(htons(arp_t->ar_op) == ARPOP_REPLY) { sprintf(buffer, "%s is %s\n", inet_ntoa(ip), ether_ntoa(&mac)); } if(strcmp(buffer, "")) { yellow_str = yellow(buffer); V(1, yellow_str); free(yellow_str); } free(hwd_addr); free(pro_addr); }
osgToy::OctoStrip::OctoStrip() { osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() ); osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() ); setNormalBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() ); setColorBinding( osg::Geometry::BIND_PER_VERTEX ); osg::Vec3 xp( 1, 0, 0); osg::Vec4 red(1,0,0,1); osg::Vec3 xn(-1, 0, 0); osg::Vec4 cyan(0,1,1,1); osg::Vec3 yp( 0, 1, 0); osg::Vec4 green(0,1,0,1); osg::Vec3 yn( 0,-1, 0); osg::Vec4 magenta(1,0,1,1); osg::Vec3 zp( 0, 0, 1); osg::Vec4 blue(0,0,1,1); osg::Vec3 zn( 0, 0,-1); osg::Vec4 yellow(1,1,0,1); vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue); vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green); vAry->push_back(xn); nAry->push_back(xn); cAry->push_back(cyan); vAry->push_back(zn); nAry->push_back(zn); cAry->push_back(yellow); vAry->push_back(yn); nAry->push_back(yn); cAry->push_back(magenta); vAry->push_back(xp); nAry->push_back(xp); cAry->push_back(red); vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue); vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green); addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) ); }
TankItem::TankItem(QObject *parent) : QObject(parent), QGraphicsRectItem(), dataModel(0), pInfoEntry(0), pInfoNr(0) { height = 3; QColor red(PERSIANRED1); QColor blue(AIR_BLUE); QColor yellow(NITROX_YELLOW); QColor green(NITROX_GREEN); QLinearGradient nitroxGradient(QPointF(0, 0), QPointF(0, height)); nitroxGradient.setColorAt(0.0, green); nitroxGradient.setColorAt(0.49, green); nitroxGradient.setColorAt(0.5, yellow); nitroxGradient.setColorAt(1.0, yellow); nitrox = nitroxGradient; oxygen = green; QLinearGradient trimixGradient(QPointF(0, 0), QPointF(0, height)); trimixGradient.setColorAt(0.0, green); trimixGradient.setColorAt(0.49, green); trimixGradient.setColorAt(0.5, red); trimixGradient.setColorAt(1.0, red); trimix = trimixGradient; air = blue; memset(&diveCylinderStore, 0, sizeof(diveCylinderStore)); }
//-------------------------------------------------------------- void miKim6::setup(){ serial.setup("/dev/tty.usbmodem1411", 9600); ofColor red(255, 0, 0); ofColor green(0, 255, 0); ofColor yellow(255, 255, 0); colors[0] = green; colors[1] = yellow; colors[2] = red; vLedStateBuffer[0] = '0'; vLedStateBuffer[1] = '0'; vLedStateBuffer[2] = '0'; ofBackground(0, 0, 0); //ofFill(); h = ofGetWindowHeight(); w = ofGetWindowWidth(); vButton[0].setFromCenter(w*1/4, h*3/4, 200, 200); vButton[1].setFromCenter(w*2/4, h*3/4, 200, 200); vButton[2].setFromCenter(w*3/4, h*3/4, 200, 200); isClicked[0] = false; isClicked[1] = false; isClicked[2] = false; }
void InitialState::doState() { if (m_provider->stateChanged() or m_firstrun) { // play a sound, and stop moving m_actions->add(NUActionatorsData::Sound, m_data->CurrentTime, NUSounds::INITIAL); m_jobs->addMotionJob(new MotionKillJob()); m_firstrun = false; } // In inital the chest led should be off m_actions->add(NUActionatorsData::ChestLed, m_data->CurrentTime, vector<float>(3,0)); // In initial if we have kick off the led should be on, and off when we don't have kick off if (m_game_info->haveKickoff()) { vector<float> yellow(3,1); yellow[2] = 0; m_actions->add(NUActionatorsData::RFootLed, m_data->CurrentTime, yellow); } else m_actions->add(NUActionatorsData::RFootLed, m_data->CurrentTime, vector<float>(3,0)); // In initial if the left foot is pressed then we should swap teams if (m_provider->singleLeftBumperClick() or m_provider->longLeftBumperClick()) m_game_info->doManualTeamChange(); }
void Component::showEllipse(Mat nbrhd, float radius_ir, Point2f ctr_ir) { if (size()<=5) return; Scalar cyan(255,255,0); Scalar black(0,0,0); Scalar yellow(0,255,255); Scalar white(255,255,255); float f_diff=0; stringstream ss; ss << id%100; Point2f ctr_tmp=ctr; ctr_tmp.x=ctr_tmp.x*radius_ir; ctr_tmp.y=ctr_tmp.y*radius_ir; ctr_tmp=ctr_tmp+ctr_ir; Size2f a_b(a,b); a_b=a_b*radius_ir; ellipse(nbrhd,ctr_tmp,a_b,(phi+f_diff)*(180/M_PI),0,360,black, 3,2); ellipse(nbrhd,ctr_tmp,a_b,(phi+f_diff)*(180/M_PI),0,360,white ,1,2); RNG rng( 0xFFFFFFFF ); putText( nbrhd, ss.str().c_str(), ctr_tmp, 0, // font face 0.3, // font scale white, // font color 2); putText( nbrhd, ss.str().c_str(), ctr_tmp, 0, // font face 0.3, // font scale black, // font color 1); }
void RGBLed::next() { mode++; if (ANIMATE < mode) mode = OFF; switch(mode) { case RED: red(); break; case GREEN: green(); break; case BLUE: blue(); break; case YELLOW: yellow(); break; case PURPLE: purple(); break; case TURQUOISE: turquoise(); break; case OFF: off(); break; } }
void LineSegment2I::TestDraw( ) { Color3B gray( 100, 100, 100 ); Color3B yellow( 255, 255, 0 ); Color3B magenta( 255, 0, 255 ); Color3B cyan( 0, 255, 255 ); int x = 60; int y = 20; int dx = 100; int dy = 80; LineSegment2I ln1( x, y, dx, dy ); int x1 = 160; int y1 = 20; int x2 = 60; int y2 = 100; LineSegment2I ln2( Point2I( x1, y1 ), Point2I( x2, y2 ) ); Rectangle oldClip = Surface::Current()->ClippingRect(); ln1.Draw( gray ); ln2.Draw( gray ); Surface::Current()->SetClippingRect( Rectangle( 100, 50, 20, 20 ) ); ln1.Draw( yellow ); ln2.Draw( yellow ); Surface::Current()->SetClippingRect( Rectangle( 60, 10, 20, 200 ) ); ln1.Draw( cyan ); ln2.Draw( cyan ); Surface::Current()->SetClippingRect( Rectangle( 140, 10, 20, 200 ) ); ln1.Draw( magenta ); ln2.Draw( magenta ); Surface::Current()->SetClippingRect( oldClip ); }
bool TriangleGame::loadContent() { vertexShader.reset(device->createVertexShader("TriangleShader.fx", "VS_Main", "vs_4_0")); vector<InputElementDescriptor> inputElements; inputElements.push_back(InputElementDescriptor("POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, true, 0)); inputElements.push_back(InputElementDescriptor("COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, true, 0)); inputLayout.reset(device->createInputLayout(inputElements, vertexShader.get())); pixelShader.reset(device->createPixelShader("TriangleShader.fx", "PS_Main", "ps_4_0")); float minX = -0.5f; float maxX = 0.5f; float minY = -1.0f; float maxY = 1.0f; XMFLOAT4 red(1.0f, 0.0f, 0.0f, 1.0f); XMFLOAT4 green(0.0f, 1.0f, 0.0f, 1.0f); XMFLOAT4 blue(0.0f, 0.0f, 1.0f, 1.0f); XMFLOAT4 yellow(1.0f, 1.0f, 0.0f, 1.0f); XMFLOAT4 cyan(0.0f, 1.0f, 1.0f, 1.0f); XMFLOAT4 magenta(1.0f, 0.0f, 1.0f, 1.0f); XMFLOAT4 white(1.0f, 1.0f, 1.0f, 1.0f); vector<Vertex> vertices; vertices.push_back(Vertex(XMFLOAT3(minX, maxY, 0.5f), red)); vertices.push_back(Vertex(XMFLOAT3(maxX, maxY, 0.5f), green)); vertices.push_back(Vertex(XMFLOAT3(minX, 0.0f, 0.5f), blue)); vertices.push_back(Vertex(XMFLOAT3(maxX, 0.0f, 0.5f), yellow)); vertices.push_back(Vertex(XMFLOAT3(minX, minY, 0.5f), cyan)); vertices.push_back(Vertex(XMFLOAT3(maxX, minY, 0.5f), magenta)); vertexBuffer.reset(device->createVertexBuffer(vertices.size() * sizeof(Vertex), &vertices[0])); return true; }
void show_build_progress(int current_step, int exit_code) { if(exit_code != 0) { int len = strlen(step[current_step-1]); int i; for(i = 0; i < len; i++) { printf("\b"); } printf("%s%s\n", yellow(), step[current_step-1]); } else if(current_step == step_count) { int len = strlen(step[current_step-1]); int i; for(i = 0; i < len; i++) { printf("\b"); } printf("%s%s%s\n", green(), step[current_step-1], color_reset()); } else if(current_step > 0) { int len = strlen(step[current_step-1]); int i; for(i = 0; i < len; i++) { printf("\b"); } printf("%s%s\n", green(), step[current_step-1]), printf("%s%s", color_reset(), step[current_step]); fflush(stdout); } else { printf("%s%s", color_reset(), step[current_step]); fflush(stdout); } }
void CornellBox(Scene& scene) { // Scene scene; Color white(1,1,1); Color red(1,0,0); Color green(0,1,0); Color blue(0,0,1); Color yellow(0,1,1); Color lila(1,0,1); scene.AddPlane(Vector(5,0,0), Vector(-1,0,0), false, Texture(green,0,0.6)); // right scene.AddPlane(Vector(-5,0,0), Vector( 1,0,0), false, Texture(red,0,0.6)); // left scene.AddPlane(Vector(0,0,5), Vector( 0,0,-1), false, Texture(lila,0,0.6)); // back scene.AddPlane(Vector(0,0,-5), Vector(0,0,1), false, Texture(white,0,0.6)); // front (behind camera) // scene.AddBox(Vector(5,5,5), Vector(-5,6,-5), false, Texture(white,1,0.0)); // top scene.AddPlane(Vector(0,5,0), Vector(0,-1,0), false, Texture(blue,0,0.6)); // top scene.AddPlane(Vector(0,0,0), Vector(0,1,0), false, Texture(white,0,0.6)); // bottom // scene.AddBox(Vector(-4,-5,4.5), Vector(-2,-1,2.5), false, Texture(blue,0,0.6)); // scene.AddBox(Vector( 0,-5,3.5), Vector( 2,-3,4.5), false, Texture(white,0,0.6)); scene.AddBox(Vector( -4,0,4.5), Vector( -2,2,2.5), false, Texture(white,0,0,0,0.7)); //reflection scene.AddBox(Vector( 4,0,4.5), Vector( 2,2,2.5), false, Texture(white,0,0,0,0,1)); //transmit/refraction scene.AddSphere(Vector(3.5,3.5,3), 1, false, Texture(white,1,0)); //the lamp scene.AddCamera(Vector(0,2.5,-4.9), Vector(0,2.5,-3.9)); // Sphere sphere(Vector(0.1,0,0), 0.3, false, Texture()); // Sphere sphere2(Vector(-0.1,0,0), 0.2, false, Texture()); // // scene.AddIntersection(&sphere, &sphere2); // return (Scene&)scene; }
void mps_redraw(void) { Rect* mps = &scr.mappoint_stats; draw_small_bezel (mps->x, mps->y, mps->w, mps->h, yellow(0)); mps_refresh(); }
void idSplineList::addToRenderer() { if (controlPoints.Num() == 0) { return; } idVec3_t mins, maxs; idVec3_t yellow(1.0, 1.0, 0); idVec3_t white(1.0, 1.0, 1.0); int i; for(i = 0; i < controlPoints.Num(); i++) { VectorCopy(*controlPoints[i], mins); VectorCopy(mins, maxs); mins[0] -= 8; mins[1] += 8; mins[2] -= 8; maxs[0] += 8; maxs[1] -= 8; maxs[2] += 8; debugLine( yellow, mins[0], mins[1], mins[2], maxs[0], mins[1], mins[2]); debugLine( yellow, maxs[0], mins[1], mins[2], maxs[0], maxs[1], mins[2]); debugLine( yellow, maxs[0], maxs[1], mins[2], mins[0], maxs[1], mins[2]); debugLine( yellow, mins[0], maxs[1], mins[2], mins[0], mins[1], mins[2]); debugLine( yellow, mins[0], mins[1], maxs[2], maxs[0], mins[1], maxs[2]); debugLine( yellow, maxs[0], mins[1], maxs[2], maxs[0], maxs[1], maxs[2]); debugLine( yellow, maxs[0], maxs[1], maxs[2], mins[0], maxs[1], maxs[2]); debugLine( yellow, mins[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2]); } int step = 0; idVec3_t step1; for(i = 3; i < controlPoints.Num(); i++) { for (float tension = 0.0f; tension < 1.001f; tension += 0.1f) { float x = 0; float y = 0; float z = 0; for (int j = 0; j < 4; j++) { x += controlPoints[i - (3 - j)]->x * calcSpline(j, tension); y += controlPoints[i - (3 - j)]->y * calcSpline(j, tension); z += controlPoints[i - (3 - j)]->z * calcSpline(j, tension); } if (step == 0) { step1[0] = x; step1[1] = y; step1[2] = z; step = 1; } else { debugLine( white, step1[0], step1[1], step1[2], x, y, z); step = 0; } } } }
void idSplineList::draw(bool editMode) { int i; vec4_t yellow(1, 1, 0, 1); if (controlPoints.Num() == 0) { return; } if (dirty) { buildSpline(); } qglColor3fv(controlColor); qglPointSize(5); qglBegin(GL_POINTS); for (i = 0; i < controlPoints.Num(); i++) { qglVertex3fv(*controlPoints[i]); } qglEnd(); if (editMode) { for(i = 0; i < controlPoints.Num(); i++) { glBox(activeColor, *controlPoints[i], 4); } } //Draw the curve qglColor3fv(pathColor); qglBegin(GL_LINE_STRIP); int count = splinePoints.Num(); for (i = 0; i < count; i++) { qglVertex3fv(*splinePoints[i]); } qglEnd(); if (editMode) { qglColor3fv(segmentColor); qglPointSize(3); qglBegin(GL_POINTS); for (i = 0; i < count; i++) { qglVertex3fv(*splinePoints[i]); } qglEnd(); } if (count > 0) { //assert(activeSegment >=0 && activeSegment < count); if (activeSegment >=0 && activeSegment < count) { glBox(activeColor, *splinePoints[activeSegment], 6); glBox(yellow, *splinePoints[activeSegment], 8); } } }
void decode_ip6(const u_char * packet) { char str_sip[INET6_ADDRSTRLEN]; char str_dip[INET6_ADDRSTRLEN]; char buffer[128]; char * yellow_plen, *yellow_nxt, *b_sip, *b_dip; const struct ip6_hdr * ip_t; ip_t = (struct ip6_hdr *)(packet); inet_ntop(AF_INET6, &(ip_t->ip6_src), str_sip, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &(ip_t->ip6_dst), str_dip, INET6_ADDRSTRLEN); b_sip = bold(str_sip); b_dip = bold(str_dip); sprintf(buffer, "%d", htons(ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen)); yellow_plen = yellow(buffer); sprintf(buffer, "%x", ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen); yellow_nxt = yellow(buffer); V(1, "IPv6 - %s --> %s\n", b_sip, b_dip); uint32_t flow = htonl(ip_t->ip6_ctlun.ip6_un1.ip6_un1_flow); VV(1, "Payload Length : %s - Next Header : %s\n", yellow_plen, yellow_nxt); /* htons(ip_t->ip6_ctlun.ip6_un1.ip6_un1_plen), ip_t->ip6_ctlun.ip6_un1.ip6_un1_nxt); */ VVV(1,"Version : %d - Traffic Class : %x - Flow Label : %x - Hop Limit : %d\n", flow >> 28, (flow & 0x0ff00000) >> 20, flow & 0x000fffff, ip_t->ip6_ctlun.ip6_un1.ip6_un1_hlim); int offset = sizeof(struct ip6_hdr); switch(ip_t->ip6_ctlun.ip6_un1.ip6_un1_nxt) { case 0x06: decode_tcp(packet + offset); break; case 0x11: decode_udp(packet + offset); break; } free(yellow_plen); free(yellow_nxt); free(b_sip); free(b_dip); }
void Canvas::DrawSnakeHead(QPainter &painter, const QPoint &pos) { QColor yellow(qRgb(254, 231, 0)); QColor black(qRgb(0, 0, 0)); painter.setBrush(yellow); painter.drawEllipse((pos.x() * MAP_UNIT) - (MAP_UNIT * 2), (pos.y() * MAP_UNIT) - (MAP_UNIT * 2), (MAP_UNIT * 3), (MAP_UNIT * 3)); painter.setBrush(QBrush(black)); painter.drawEllipse((pos.x() * MAP_UNIT) - (MAP_UNIT / 4), (pos.y() * MAP_UNIT) - MAP_UNIT - (MAP_UNIT / 4), (MAP_UNIT / 2), (MAP_UNIT / 2)); painter.drawEllipse((pos.x() * MAP_UNIT) - (MAP_UNIT / 4), (pos.y() * MAP_UNIT) - (MAP_UNIT / 4), (MAP_UNIT / 2), (MAP_UNIT / 2)); }
void ResponsibilityArea::drawArea(cv::Mat & frame, bool isMotionOccurred) { cv::Scalar red(0, 0, 255); cv::Scalar yellow(0, 255, 255); if (isMotionOccurred) { rectangle(frame, cv::Rect(xStart_, yStart_, width_, height_), red, 2); } else { rectangle(frame, cv::Rect(xStart_, yStart_, width_, height_), yellow, 2); } }
void UnitTest::skip (const std::string& text) { ++_counter; ++_skipped; std::cout << yellow ("skip") << " " << _counter << " - " << text << "\n"; }
void PieceAppearanceWidget::setupDefaultTemplates() { typedef QList<QColor> QCL; QCL cl; QColor red( Qt::red ); QColor green(Qt::green); QColor blue(Qt::blue); QColor yellow(Qt::yellow); QColor white(Qt::white); cl << white << red << green << blue << yellow ; int step = 24; int space = 4; int x = space; int y = space; int at = 0; for( QCL::iterator it = cl.begin(); cl.end() != it; ++it ) { QColor color = *it; QColor darker = color.darker(); QColor lighter = color.lighter(); if( 0 == at++ ) { // the obligatory special case for White: lighter = color.darker(); darker = lighter.darker(); } for( int i = 0; i < 3; ++i ) { if( i == 1 ) color = lighter; else if( i == 2 ) color = darker; QGIPiece * pc = new QGIPiece; if( ! this->impl->pc ) this->impl->pc = pc; this->impl->gs.addItem( pc ); pc->setProperty("size",QSize(step,step)); pc->setProperty("pos",QPoint(x,y)); pc->setProperty("dragDisabled",int(1)); const QRectF bounds( pc->boundingRect() ); x += int(bounds.width()) + space; pc->setProperty("color",color); pc->setProperty("borderSize",1); pc->setProperty("borderColor",QColor(0,0,0)); } y += step + space; x = space; } //impl->gs.scene()->setSceneRect( QRectF() ); }
void MainWindow::recalcLabels() { QString yellow("yellow zone starts at "); yellow.append(QString::number(ui->_yellowThreshold->value())); yellow.append(" sec"); ui->_yellowLabel->setText(yellow); QString red("red zone starts at "); red.append(QString::number(ui->_redThreshold->value())); red.append(" sec"); ui->_redLabel->setText(red); }
void Highlight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QColor pen_color = pen.color(); painter->setPen(pen); if(time < total_time ){ //don't want to keep adding them past animation length int expected_num_rings = (int)ceil(frequency * time); if( expected_num_rings > rings.length()){ rings.append(time); } //velocity= 200.0 - (time*total_time*2.0);//pretty cool //velocity= 200.0*(1.0-done_ratio);//pretty cool, about the same //frequency = 3.0*(1.0-done_ratio);//pretty cool for(int i=0; i<rings.length(); i++){ //qreal dist = diameter + ( velocity * (time - rings.at(i))); qreal t = (time - rings.at(i)); qreal dist = diameter + ( velocity * t ) + (0.5 * -5.0 * t*t); //qDebug() << "dist:" << dist << " outerDiameter:" << outerDiameter; QRectF s(x()-dist/2.0, y()-dist/2.0,dist,dist); QRectF r = mapRectFromScene(x()-dist/2.0, y()-dist/2.0,dist,dist); pen.setWidth(20.0+50.0* dist/outerDiameter); QRadialGradient radialGrad; radialGrad.setCenter(r.center()); radialGrad.setFocalPoint(r.center()); radialGrad.setCenterRadius(r.width()/2.0+pen.widthF()/2.0); radialGrad.setFocalRadius(r.width()/2.0-pen.widthF()/2.0); /* not entirely sure I get it, but I think focal radius * needs to be either the center of the pen or its inner edge * while center radius is the outer edge. */ QColor green(0,255,0,255); QColor yellow(255,255,0,255); /* pen_color.setAlphaF(1.0-(dist/outerDiameter)); //surface waves don't inverse square */ green.setAlphaF(1.0-(dist/outerDiameter)); yellow.setAlphaF((1.0-(dist/outerDiameter))); radialGrad.setColorAt(.0, yellow ); radialGrad.setColorAt( .5, green ); radialGrad.setColorAt(1, yellow ); brush = QBrush(radialGrad); pen.setBrush(brush); painter->setPen(pen); painter->drawEllipse(r); } } }
void flashing_yellow(void const *args) { bool on = false; while (!connected && connack_rc != MQTT_NOT_AUTHORIZED && connack_rc != MQTT_BAD_USERNAME_OR_PASSWORD) // flashing yellow only while connecting { on = !on; if (on) yellow(); else off(); wait(0.5); } }
speedometer::speedometer() : m_last(0,0,0), m_caution(440.0f, 1), m_warning(440.0f, 2) { const float compen = -0.5f * 3.1415f; color white((unsigned char)0xff, 0xff, 0xff, 0xff); color green((unsigned char)0x00, 0xff, 0x00, 0xff); color yellow((unsigned char)0xdd, 0xff, 0x00, 0xff); color red((unsigned char)0xff, 0x00, 0x00, 0xff); const float radius = 20.0f; m_fb.setcolor(white); m_fb.clear(); m_fb.setcolor(red); m_fb.line(100,10, 200, 10); m_fb.line(100,10, 200, 110); m_fb.line(100,10, 100, 110); m_fb.setcolor(green); struct timeval tv0, tv1; printf("triangle bench start\n"); gettimeofday(&tv0, 0); matrix3f a,b; for(int i=0; i<100000; i++) { a = a * b; } gettimeofday(&tv1, 0); printf("triangle bench done\n"); printf("tv0: sec=%d usec=%d\n", tv0.tv_sec, tv0.tv_usec); printf("tv1: sec=%d usec=%d\n", tv1.tv_sec, tv1.tv_usec); for(int a = 0; a<360; a++) { int as = a; float rad = (((float)a)/360.0f) * 6.283f; if(as > 200) m_fb.setcolor(yellow); if(as > 270) m_fb.setcolor(red); for(float rad2 = radius; rad2<radius+5; rad2+=0.5) { float x = 120.0f + (rad2 * cosf(rad)); float y = 160.0f + (rad2 * sinf(rad)); // m_fb.pixel((unsigned int)x,(unsigned int)y); } } m_fb.blit(); m_sc.play(m_caution); m_sc.play(m_warning); }
void CTypetestDlg::OnPaint() { CPaintDC dc(this); // device context for painting // Switch to metric coordinates dc.SetMapMode(MM_LOMETRIC); // Fill the square with colour CBrush yellow(RGB(0xFF,0xFF, 0xC0)); // Light yellow dc.FillRect(CRect(100, -100, 600, -600), &yellow); int x = 100; for (int i=0; i <= 10; i++) { dc.MoveTo(x, -600); dc.LineTo(700-x, -100); // Now x is used in the y direction dc.MoveTo(100, -x); dc.LineTo(600, -(700-x)); x += 50; } CPen fat(PS_SOLID, 30, RGB(255, 0, 0)); // Fat red pen CPen* oldPen = dc.SelectObject(&fat); dc.MoveTo(100, -100); dc.LineTo(100, -600); dc.LineTo(600, -600); dc.LineTo(600, -100); dc.LineTo(100, -100); dc.SelectObject(&oldPen); char* szFading = "Fading..."; x = 700; int y = -600; float size = 500; dc.SetTextAlign(TA_BASELINE); dc.SetBkMode(TRANSPARENT); for (int j=0; j < 9; j++) { CFont arial; arial.CreateFont((int)-size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "Arial"); CFont* oldFont = dc.SelectObject(&arial); dc.TextOut(x, y, szFading+j, 1); CSize szExtent = dc.GetTextExtent(szFading+j, 1); x += szExtent.cx; dc.SelectObject(&oldFont); size *= 0.8f; // Next char only 80% as large } }
void GUIBusStop::drawGL(const GUIVisualizationSettings& s) const { glPushName(getGlID()); glPushMatrix(); RGBColor green(76, 170, 50, 255); RGBColor yellow(255, 235, 0, 255); // draw the area glTranslated(0, 0, getType()); GLHelper::setColor(green); const SUMOReal exaggeration = s.addSize.getExaggeration(s); GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, exaggeration); // draw details unless zoomed out to far if (s.scale * exaggeration >= 10) { // draw the lines const SUMOReal rotSign = MSNet::getInstance()->lefthand() ? -1 : 1; for (int i = 0; i != (int)myLines.size(); ++i) { glPushMatrix(); glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); glRotated(180, 1, 0, 0); glRotated(rotSign * myFGSignRot, 0, 0, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); pfSetPosition(0, 0); pfSetScale(1.f); glTranslated(1.2, -(double)i, 0); pfDrawString(myLines[i].c_str()); glPopMatrix(); } for (std::vector<Position>::const_iterator i = myAccessCoords.begin(); i != myAccessCoords.end(); ++i) { GLHelper::drawBoxLine(*i, RAD2DEG(myFGSignPos.angleTo2D(*i)) - 90, myFGSignPos.distanceTo2D(*i), .05); } // draw the sign glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0); int noPoints = 9; if (s.scale * exaggeration > 25) { noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36); } glScaled(exaggeration, exaggeration, 1); GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints); glTranslated(0, 0, .1); GLHelper::setColor(yellow); GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints); if (s.scale * exaggeration >= 4.5) { GLHelper::drawText("H", Position(), .1, 1.6, green, myFGSignRot); } } glPopMatrix(); glPopName(); drawName(getCenteringBoundary().getCenter(), s.scale, s.addName); }
void condition_abbrev( char* tmp, obj_data* obj, char_data* ch ) { const char* abbrev [] = { "wls", "dmg", "vwn", "wrn", "vsc", "scr", "rea", "goo", "vgo", "exc" }; int i; i = 1000*obj->condition/obj->pIndexData->durability; i = range( 0, i/100, 9 ); sprintf( tmp, "%s%s%s", i > 4 ? ( i > 7 ? blue( ch ) : green( ch ) ) : ( i > 2 ? yellow( ch ) : red( ch ) ), abbrev[i], normal( ch ) ); return; }
virtual bool Process(const Frame & input, Frame & output) { Simd::Motion::Metadata metadata; _detector.NextFrame(input, metadata, &output); Simd::Pixel::Bgr24 yellow(0, 255, 255); size_t width = 2; for (size_t i = 0; i < metadata.objects.size(); ++i) { const Simd::Motion::Object & object = metadata.objects[i]; Simd::DrawRectangle(output.planes[0], object.current.rect, yellow, width); } return true; }
int main() { try { // Vereinbarung einiger Farben RGB_Pixel red(255,0,0); RGB_Pixel green(0,255,0); RGB_Pixel blue(0,0,255); RGB_Pixel yellow(255,255,0); RGB_Pixel transparent; // Vereinbarung eines AVI-Objekts #if 1 const int height=240, width=320, frames=200; // (Erzeugt Video von ca. 45 MB) #else const int height=180, width=120, frames=60; // (Erzeugt Video von ca. 3,8 MB) #endif AviWrite video("P7.avi",width,height); // Erstes Fifo für Grafikelemente vereinbaren und füllen GrafikKiste f1; f1 << TextZeile(10,height/2,"OOP ist sch\x94n!",yellow,transparent); f1 << Rechteck(8,height/2-2,130,height/2+15,yellow); for (int k=0;k<frames;k++) { // Generierung der Frames cout << '.' << flush; // Zweites Fifo für Grafikelemente vereinbaren und füllen GrafikKiste f; int i=int(100.0*sin(3.0*k*2.0*M_PI/frames))+height/2; int j=int(10.0*sin(10.0*k*2.0*M_PI/frames))+width/2; f << Linie(2*i/3,4*i/3,width-i,height-3*i,green); f << RechteckGefuellt(3,i-2, width-3, i/2+15,green, blue); f << TextZeile(+j-30,i,"Testbild",red,transparent); f << Rechteck(0,0,width-1,height-1,green); // Bei erstem Fifo den Bezugspunkt aller Grafikelemente verschieben // und Inhalt des ersten Fifos in das zweite Fifo kopieren f1.add_offset(static_cast<int>(10*sin(10.0*k*2.0*M_PI/frames)), static_cast<int>(10*cos(10.0*k*2.0*M_PI/frames))); f << f1; // Bild I vereinbaren und zweites Fifo in das Bild zeichnen Image I(width,height); f.draw(I); // Bild in AVI-Video schreiben video << I; } } catch(...) { cout << "Ausnahme gefangen" << endl; } }