bool ModelItem::appendModelData(OctreePacketData* packetData) const { bool success = packetData->appendValue(getID()); //qDebug("ModelItem::appendModelData()... getID()=%d", getID()); if (success) { success = packetData->appendValue(getLastUpdated()); } if (success) { success = packetData->appendValue(getLastEdited()); } if (success) { success = packetData->appendValue(getRadius()); } if (success) { success = packetData->appendPosition(getPosition()); } if (success) { success = packetData->appendColor(getColor()); } if (success) { success = packetData->appendValue(getShouldDie()); } // modelURL if (success) { uint16_t modelURLLength = _modelURL.size() + 1; // include NULL success = packetData->appendValue(modelURLLength); if (success) { success = packetData->appendRawData((const unsigned char*)qPrintable(_modelURL), modelURLLength); } } // modelRotation if (success) { success = packetData->appendValue(getModelRotation()); } // animationURL if (success) { uint16_t animationURLLength = _animationURL.size() + 1; // include NULL success = packetData->appendValue(animationURLLength); if (success) { success = packetData->appendRawData((const unsigned char*)qPrintable(_animationURL), animationURLLength); } } // animationIsPlaying if (success) { success = packetData->appendValue(getAnimationIsPlaying()); } // animationFrameIndex if (success) { success = packetData->appendValue(getAnimationFrameIndex()); } // animationFPS if (success) { success = packetData->appendValue(getAnimationFPS()); } return success; }
void LineUIDrawObject::draw(const GraphicsWeakPtr Graphics, Real32 Opacity) const { Graphics->drawLine(getTopLeft(), getBottomRight(), getWidth(), getColor(), getOpacity()*Opacity); }
bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets) { GLubyte opacity = getOpacity(); ccColor3B color = getColor(); // Release old sprites this->removeAllChildrenWithCleanup(true); CC_SAFE_RELEASE(this->_centre); CC_SAFE_RELEASE(this->_top); CC_SAFE_RELEASE(this->_topLeft); CC_SAFE_RELEASE(this->_topRight); CC_SAFE_RELEASE(this->_left); CC_SAFE_RELEASE(this->_right); CC_SAFE_RELEASE(this->_bottomLeft); CC_SAFE_RELEASE(this->_bottom); CC_SAFE_RELEASE(this->_bottomRight); if(this->_scale9Image != batchnode) { CC_SAFE_RELEASE(this->_scale9Image); _scale9Image = batchnode; CC_SAFE_RETAIN(_scale9Image); } _scale9Image->removeAllChildrenWithCleanup(true); m_capInsets = capInsets; // If there is no given rect if ( rect.equals(CCRectZero) ) { // Get the texture size as original CCSize textureSize = _scale9Image->getTextureAtlas()->getTexture()->getContentSize(); rect = CCRectMake(0, 0, textureSize.width, textureSize.height); } // Set the given rect's size as original size m_spriteRect = rect; m_originalSize = rect.size; m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; float w = rect.size.width; float h = rect.size.height; // If there is no specified center region if ( m_capInsetsInternal.equals(CCRectZero) ) { // CCLog("... cap insets not specified : using default cap insets ..."); m_capInsetsInternal = CCRectMake(w/3, h/3, w/3, h/3); } float left_w = m_capInsetsInternal.origin.x; float center_w = m_capInsetsInternal.size.width; float right_w = rect.size.width - (left_w + center_w); float top_h = m_capInsetsInternal.origin.y; float center_h = m_capInsetsInternal.size.height; float bottom_h = rect.size.height - (top_h + center_h); // calculate rects // ... top row float x = 0.0; float y = 0.0; // top left CCRect lefttopbounds = CCRectMake(x, y, left_w, top_h); // top center TRANSLATE_X(x, y, left_w); CCRect centertopbounds = CCRectMake(x, y, center_w, top_h); // top right TRANSLATE_X(x, y, center_w); CCRect righttopbounds = CCRectMake(x, y, right_w, top_h); // ... center row x = 0.0; y = 0.0; TRANSLATE_Y(x, y, top_h); // center left CCRect leftcenterbounds = CCRectMake(x, y, left_w, center_h); // center center TRANSLATE_X(x, y, left_w); CCRect centerbounds = CCRectMake(x, y, center_w, center_h); // center right TRANSLATE_X(x, y, center_w); CCRect rightcenterbounds = CCRectMake(x, y, right_w, center_h); // ... bottom row x = 0.0; y = 0.0; TRANSLATE_Y(x, y, top_h); TRANSLATE_Y(x, y, center_h); // bottom left CCRect leftbottombounds = CCRectMake(x, y, left_w, bottom_h); // bottom center TRANSLATE_X(x, y, left_w); CCRect centerbottombounds = CCRectMake(x, y, center_w, bottom_h); // bottom right TRANSLATE_X(x, y, center_w); CCRect rightbottombounds = CCRectMake(x, y, right_w, bottom_h); if (!rotated) { // CCLog("!rotated"); CCAffineTransform t = CCAffineTransformMakeIdentity(); t = CCAffineTransformTranslate(t, rect.origin.x, rect.origin.y); centerbounds = CCRectApplyAffineTransform(centerbounds, t); rightbottombounds = CCRectApplyAffineTransform(rightbottombounds, t); leftbottombounds = CCRectApplyAffineTransform(leftbottombounds, t); righttopbounds = CCRectApplyAffineTransform(righttopbounds, t); lefttopbounds = CCRectApplyAffineTransform(lefttopbounds, t); rightcenterbounds = CCRectApplyAffineTransform(rightcenterbounds, t); leftcenterbounds = CCRectApplyAffineTransform(leftcenterbounds, t); centerbottombounds = CCRectApplyAffineTransform(centerbottombounds, t); centertopbounds = CCRectApplyAffineTransform(centertopbounds, t); // Centre _centre = new CCSprite(); _centre->initWithTexture(_scale9Image->getTexture(), centerbounds); _scale9Image->addChild(_centre, 0, pCentre); // Top _top = new CCSprite(); _top->initWithTexture(_scale9Image->getTexture(), centertopbounds); _scale9Image->addChild(_top, 1, pTop); // Bottom _bottom = new CCSprite(); _bottom->initWithTexture(_scale9Image->getTexture(), centerbottombounds); _scale9Image->addChild(_bottom, 1, pBottom); // Left _left = new CCSprite(); _left->initWithTexture(_scale9Image->getTexture(), leftcenterbounds); _scale9Image->addChild(_left, 1, pLeft); // Right _right = new CCSprite(); _right->initWithTexture(_scale9Image->getTexture(), rightcenterbounds); _scale9Image->addChild(_right, 1, pRight); // Top left _topLeft = new CCSprite(); _topLeft->initWithTexture(_scale9Image->getTexture(), lefttopbounds); _scale9Image->addChild(_topLeft, 2, pTopLeft); // Top right _topRight = new CCSprite(); _topRight->initWithTexture(_scale9Image->getTexture(), righttopbounds); _scale9Image->addChild(_topRight, 2, pTopRight); // Bottom left _bottomLeft = new CCSprite(); _bottomLeft->initWithTexture(_scale9Image->getTexture(), leftbottombounds); _scale9Image->addChild(_bottomLeft, 2, pBottomLeft); // Bottom right _bottomRight = new CCSprite(); _bottomRight->initWithTexture(_scale9Image->getTexture(), rightbottombounds); _scale9Image->addChild(_bottomRight, 2, pBottomRight); } else { // set up transformation of coordinates // to handle the case where the sprite is stored rotated // in the spritesheet // CCLog("rotated"); CCAffineTransform t = CCAffineTransformMakeIdentity(); CCRect rotatedcenterbounds = centerbounds; CCRect rotatedrightbottombounds = rightbottombounds; CCRect rotatedleftbottombounds = leftbottombounds; CCRect rotatedrighttopbounds = righttopbounds; CCRect rotatedlefttopbounds = lefttopbounds; CCRect rotatedrightcenterbounds = rightcenterbounds; CCRect rotatedleftcenterbounds = leftcenterbounds; CCRect rotatedcenterbottombounds = centerbottombounds; CCRect rotatedcentertopbounds = centertopbounds; t = CCAffineTransformTranslate(t, rect.size.height+rect.origin.x, rect.origin.y); t = CCAffineTransformRotate(t, 1.57079633f); centerbounds = CCRectApplyAffineTransform(centerbounds, t); rightbottombounds = CCRectApplyAffineTransform(rightbottombounds, t); leftbottombounds = CCRectApplyAffineTransform(leftbottombounds, t); righttopbounds = CCRectApplyAffineTransform(righttopbounds, t); lefttopbounds = CCRectApplyAffineTransform(lefttopbounds, t); rightcenterbounds = CCRectApplyAffineTransform(rightcenterbounds, t); leftcenterbounds = CCRectApplyAffineTransform(leftcenterbounds, t); centerbottombounds = CCRectApplyAffineTransform(centerbottombounds, t); centertopbounds = CCRectApplyAffineTransform(centertopbounds, t); rotatedcenterbounds.origin = centerbounds.origin; rotatedrightbottombounds.origin = rightbottombounds.origin; rotatedleftbottombounds.origin = leftbottombounds.origin; rotatedrighttopbounds.origin = righttopbounds.origin; rotatedlefttopbounds.origin = lefttopbounds.origin; rotatedrightcenterbounds.origin = rightcenterbounds.origin; rotatedleftcenterbounds.origin = leftcenterbounds.origin; rotatedcenterbottombounds.origin = centerbottombounds.origin; rotatedcentertopbounds.origin = centertopbounds.origin; // Centre _centre = new CCSprite(); _centre->initWithTexture(_scale9Image->getTexture(), rotatedcenterbounds, true); _scale9Image->addChild(_centre, 0, pCentre); // Top _top = new CCSprite(); _top->initWithTexture(_scale9Image->getTexture(), rotatedcentertopbounds, true); _scale9Image->addChild(_top, 1, pTop); // Bottom _bottom = new CCSprite(); _bottom->initWithTexture(_scale9Image->getTexture(), rotatedcenterbottombounds, true); _scale9Image->addChild(_bottom, 1, pBottom); // Left _left = new CCSprite(); _left->initWithTexture(_scale9Image->getTexture(), rotatedleftcenterbounds, true); _scale9Image->addChild(_left, 1, pLeft); // Right _right = new CCSprite(); _right->initWithTexture(_scale9Image->getTexture(), rotatedrightcenterbounds, true); _scale9Image->addChild(_right, 1, pRight); // Top left _topLeft = new CCSprite(); _topLeft->initWithTexture(_scale9Image->getTexture(), rotatedlefttopbounds, true); _scale9Image->addChild(_topLeft, 2, pTopLeft); // Top right _topRight = new CCSprite(); _topRight->initWithTexture(_scale9Image->getTexture(), rotatedrighttopbounds, true); _scale9Image->addChild(_topRight, 2, pTopRight); // Bottom left _bottomLeft = new CCSprite(); _bottomLeft->initWithTexture(_scale9Image->getTexture(), rotatedleftbottombounds, true); _scale9Image->addChild(_bottomLeft, 2, pBottomLeft); // Bottom right _bottomRight = new CCSprite(); _bottomRight->initWithTexture(_scale9Image->getTexture(), rotatedrightbottombounds, true); _scale9Image->addChild(_bottomRight, 2, pBottomRight); } this->setContentSize(rect.size); this->addChild(_scale9Image); if (m_bSpritesGenerated) { // Restore color and opacity this->setOpacity(opacity); this->setColor(color); } m_bSpritesGenerated = true; return true; }
void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { bool eventAdded = false; if (!shouldCalculateStuff(topLeft, bottomRight)) return; AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight); if (polygon().isEmpty()) return; show_reported_ceiling = prefs.dcceiling; reported_ceiling_in_red = prefs.redceiling; profileColor = getColor(DEPTH_BOTTOM); int currState = qobject_cast<ProfileWidget2 *>(scene()->views().first())->currentState; if (currState == ProfileWidget2::PLAN) { plot_data *entry = dataModel->data().entry; for (int i = 0; i < dataModel->rowCount(); i++, entry++) { int max = maxCeiling(i); // Don't scream if we violate the ceiling by a few cm if (entry->depth < max - 100 && entry->sec > 0) { profileColor = QColor(Qt::red); if (!eventAdded) { add_event(&displayed_dive.dc, entry->sec, SAMPLE_EVENT_CEILING, -1, max / 1000, "planned waypoint above ceiling"); eventAdded = true; } } } } /* Show any ceiling we may have encountered */ if (prefs.dcceiling && !prefs.redceiling) { QPolygonF p = polygon(); plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1; for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) { if (!entry->in_deco) { /* not in deco implies this is a safety stop, no ceiling */ p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(0))); } else { p.append(QPointF(hAxis->posAtValue(entry->sec), vAxis->posAtValue(qMin(entry->stopdepth, entry->depth)))); } } setPolygon(p); } // This is the blueish gradient that the Depth Profile should have. // It's a simple QLinearGradient with 2 stops, starting from top to bottom. QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom()); pat.setColorAt(1, profileColor); pat.setColorAt(0, getColor(DEPTH_TOP)); setBrush(QBrush(pat)); int last = -1; for (int i = 0, count = dataModel->rowCount(); i < count; i++) { struct plot_data *entry = dataModel->data().entry + i; if (entry->depth < 2000) continue; if ((entry == entry->max[2]) && entry->depth / 100 != last) { plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_DEEP)); last = entry->depth / 100; } if ((entry == entry->min[2]) && entry->depth / 100 != last) { plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_SHALLOW)); last = entry->depth / 100; } if (entry->depth != last) last = -1; } }
void ToolItem::renderInventory(Screen * screen, int x, int y) { screen->render(x, y, getSprite(), getColor(), 0); Font::draw(getName(), screen, x + 8, y, Color::get(-1, 555, 555, 555)); }
void Trails::updateMeshes() { for (int dir = 0; dir < Direction::NUM_DIRECTIONS; dir++) { std::vector<Segment> mesh; for(std::map<int, std::map<float, Color> >::iterator it = segments[dir].begin(); it != segments[dir].end(); it++) { Color last = Color::WHITE; float lastx = 0; for(std::map<float, Color>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) { if(last != Color::WHITE) { if(dir == HORIZONTAL) mesh.push_back(Segment(vec3f(lastx, it->first, 0.5f), vec3f(it2->first, it->first, 0.5f), getColor(last))); else mesh.push_back(Segment(vec3f(it->first, lastx, 0.5f), vec3f(it->first, it2->first, 0.5f), getColor(last))); } last = it2->second; lastx = it2->first; } } models[dir].mesh->setVertexData(&mesh[0], mesh.size()*2); } }
/**************************************** * main * * sets up the communication between the main mbed * inits the leds to check if the leds are working properly * continuously checks for a command from the main mbed * if new command received, then executes the appropriate function * ****************************************/ int main() { uint8_t R,G,B; pc.baud(9600); strip.begin(); init_grid(); /*Shutting down the leds*/ clear_strip(); getColor(&R,&G,&B,"G"); wait_ms(10); //clear_strip(); // show_pixel(&pixel_grid[0][0], R, G, B, 500); // wait_ms(1000); pixel_grid[0][0].selected = 1; pixel_grid[1][1].selected = 1; pixel_grid[2][2].selected = 1; pixel_grid[2][0].selected = 1; pixel_grid[0][2].selected = 1; //pixel_grid[0][0].selected = 1; // pixel_grid[1][1].selected = 1; // pixel_grid[2][2].selected = 1; // pixel_grid[3][3].selected = 1; // pixel_grid[4][2].selected = 1; // pixel_grid[5][1].selected = 1; // pixel_grid[6][0].selected = 1; // select_all_pixels(); create_pattern(P_WAVE_FLOW, DIR_RIGHT, R, G, B, 50, 5000); // pixel_grid[10][0].selected = 1; // pixel_grid[10][1].selected = 1; // pixel_grid[10][2].selected = 1; // pixel_grid[10][3].selected = 1; // pixel_grid[9][1].selected = 1; // pixel_grid[9][2].selected = 1; // pixel_grid[9][3].selected = 1; // pixel_grid[8][2].selected = 1; // pixel_grid[8][3].selected = 1; // pixel_grid[7][3].selected = 1; // // create_pattern(P_CUSTOM, DIR_UP, 150, 80, 200, 50, 1000); // //pixel_grid[0][0].selected = 1; // pixel_grid[1][1].selected = 1; // pixel_grid[2][2].selected = 1; // pixel_grid[2][0].selected = 1; // pixel_grid[0][2].selected = 1; // // getColor(&R,&G,&B,"G"); // // create_pattern(P_CUSTOM, DIR_UP, R, G, B, 25, 1000); // // pixel_grid[2][0].selected = 1; // pixel_grid[2][1].selected = 1; // pixel_grid[2][2].selected = 1; // pixel_grid[2][3].selected = 1; // // getColor(&R,&G,&B,"B"); // // create_pattern(P_CUSTOM, DIR_UP, R, G, B, 50, 1000); // wait(0.1); clear_strip(); while(1) { //wait for messages rxLen = rf_receive(rxBuffer, 128); if(rxLen > 0) { if(rxBuffer[0] == ID) { char* rxBuffer1 = &rxBuffer[1]; pc.printf("Received string %s \r\n",rxBuffer); parser(rxBuffer1); } } } }
void TButton::drawState(Boolean down) { ushort cButton, cShadow; char ch; int i; TDrawBuffer b; if( (state & sfDisabled) != 0 ) cButton = getColor(0x0404); else { cButton = getColor(0x0501); if( (state & sfActive) != 0 ) if( (state & sfSelected) != 0 ) cButton = getColor(0x0703); else if( amDefault ) cButton = getColor(0x0602); } cShadow = getColor(8); int s = size.x-1; int T = size.y / 2 - 1; for( int y = 0; y <= size.y-2; y++ ) { b.moveChar( 0, ' ', cButton, size.x ); b.putAttribute( 0, cShadow ); if( down ) { b.putAttribute( 1, cShadow ); ch = ' '; i = 2; } else { b.putAttribute( s, cShadow ); if( showMarkers == True ) ch = ' '; else { if( y == 0 ) b.putChar( s, shadows[0] ); else b.putChar( s, shadows[1] ); ch = shadows[2]; } i = 1; } if( y == T && title != 0 ) drawTitle( b, s, i, cButton, down ); if( showMarkers && !down ) { b.putChar( 1, markers[0] ); b.putChar( s-1, markers[1] ); } writeLine( 0, y, size.x, 1, b ); } b.moveChar( 0, ' ', cShadow, 2 ); b.moveChar( 2, ch, cShadow, s-1 ); writeLine( 0, size.y-1, size.x, 1, b ); }
void CCSkeleton::draw () { CC_NODE_DRAW_SETUP(); ccGLBlendFunc(blendFunc.src, blendFunc.dst); ccColor3B color = getColor(); skeleton->r = color.r / (float)255; skeleton->g = color.g / (float)255; skeleton->b = color.b / (float)255; skeleton->a = getOpacity() / (float)255; if (premultipliedAlpha) { skeleton->r *= skeleton->a; skeleton->g *= skeleton->a; skeleton->b *= skeleton->a; } CCTextureAtlas* textureAtlas = 0; ccV3F_C4B_T2F_Quad quad; quad.tl.vertices.z = 0; quad.tr.vertices.z = 0; quad.bl.vertices.z = 0; quad.br.vertices.z = 0; for (int i = 0, n = skeleton->slotCount; i < n; i++) { Slot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; RegionAttachment* attachment = (RegionAttachment*)slot->attachment; CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment); if (regionTextureAtlas != textureAtlas) { if (textureAtlas) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); } } textureAtlas = regionTextureAtlas; if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() && !textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return; RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha); textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads()); } if (textureAtlas) { textureAtlas->drawQuads(); textureAtlas->removeAllQuads(); } if (debugSlots) { // Slots. ccDrawColor4B(0, 0, 255, 255); glLineWidth(1); CCPoint points[4]; ccV3F_C4B_T2F_Quad quad; for (int i = 0, n = skeleton->slotCount; i < n; i++) { Slot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; RegionAttachment* attachment = (RegionAttachment*)slot->attachment; RegionAttachment_updateQuad(attachment, slot, &quad); points[0] = ccp(quad.bl.vertices.x, quad.bl.vertices.y); points[1] = ccp(quad.br.vertices.x, quad.br.vertices.y); points[2] = ccp(quad.tr.vertices.x, quad.tr.vertices.y); points[3] = ccp(quad.tl.vertices.x, quad.tl.vertices.y); ccDrawPoly(points, 4, true); } } if (debugBones) { // Bone lengths. glLineWidth(2); ccDrawColor4B(255, 0, 0, 255); for (int i = 0, n = skeleton->boneCount; i < n; i++) { Bone *bone = skeleton->bones[i]; float x = bone->data->length * bone->m00 + bone->worldX; float y = bone->data->length * bone->m10 + bone->worldY; ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y)); } // Bone origins. ccPointSize(4); ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. for (int i = 0, n = skeleton->boneCount; i < n; i++) { Bone *bone = skeleton->bones[i]; ccDrawPoint(ccp(bone->worldX, bone->worldY)); if (i == 0) ccDrawColor4B(0, 255, 0, 255); } } }
uint32_t RNGradient::getColor(int32_t position) { uint8_t r, g, b; getColor(position, r, g, b); return (r << 16) | (g << 8) | b; }
void RectObstacle::draw() { glColor3f(getColor().red, getColor().green, getColor().blue); Position pos = getPosition(); glRectf(pos.x, pos.y, pos.x + width, pos.y - height); }
Rectangle Rectangle::normalizeTo1x1(Rectangle display) { return Rectangle(getX() / display.getW(), getY() / display.getH(), getW() / display.getW(), getH() / display.getH(), getColor()); }
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0) { fill_profile_color(); setBackgroundBrush(profile_color[BACKGROUND].at(0)); setMouseTracking(true); setScene(new QGraphicsScene()); scene()->setSceneRect(0,0,1920,1080); verticalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical) ); verticalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(verticalLine); horizontalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical) ); horizontalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(horizontalLine); timeLine = new Ruler(); timeLine->setMinimum(0); timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); timeLine->setColor(getColor(TIME_GRID)); timeLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical), fromPercent(90, Qt::Horizontal), fromPercent(90, Qt::Vertical) ); timeLine->setOrientation(Qt::Horizontal); timeLine->setTickSize(fromPercent(1, Qt::Vertical)); timeLine->setTextColor(getColor(TIME_TEXT)); timeLine->updateTicks(); scene()->addItem(timeLine); depthLine = new Ruler(); depthLine->setMinimum(0); depthLine->setMaximum(M_OR_FT(40,120)); depthLine->setTickInterval(M_OR_FT(10,30)); depthLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(10, Qt::Vertical), fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical) ); depthLine->setOrientation(Qt::Vertical); depthLine->setTickSize(fromPercent(1, Qt::Horizontal)); depthLine->setColor(getColor(DEPTH_GRID)); depthLine->setTextColor(getColor(SAMPLE_DEEP)); depthLine->updateTicks(); scene()->addItem(depthLine); timeString = new QGraphicsSimpleTextItem(); timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); timeString->setBrush(profile_color[TIME_TEXT].at(0)); scene()->addItem(timeString); depthString = new QGraphicsSimpleTextItem(); depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); scene()->addItem(depthString); diveBg = new QGraphicsPolygonItem(); diveBg->setPen(QPen(QBrush(),0)); scene()->addItem(diveBg); #define ADDBTN(obj, icon, text, horizontal, vertical, tooltip, value, slot) \ obj = new Button(); \ obj->setPixmap(QPixmap(icon)); \ obj->setPos(fromPercent(horizontal, Qt::Horizontal), fromPercent(vertical, Qt::Vertical)); \ obj->setToolTip(QString(tooltip.arg(value))); \ scene()->addItem(obj); \ connect(obj, SIGNAL(clicked()), this, SLOT(slot)); QString incrText; if (prefs.units.length == units::METERS) incrText = tr("10m"); else incrText = tr("30ft"); ADDBTN(plusDepth, ":plus", "" , 5, 5, tr("Increase maximum depth by %1"), incrText, increaseDepth()); ADDBTN(lessDepth, ":minimum","" , 2, 5, tr("Decreases maximum depth by %1"), incrText, decreaseDepth()); ADDBTN(plusTime, ":plus", "" , 95, 95, tr("Increase minimum time by %1"), tr("10min"), increaseTime()); ADDBTN(lessTime, ":minimum","" , 92, 95, tr("Decreases minimum time by %1"), tr("10min"), decreaseTime()); #undef ADDBTN minMinutes = TIME_INITIAL_MAX; QAction *action = NULL; #define ADD_ACTION( SHORTCUT, Slot ) \ action = new QAction(this); \ action->setShortcut( SHORTCUT ); \ action->setShortcutContext(Qt::WindowShortcut); \ addAction(action); \ connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot )) ADD_ACTION(Qt::Key_Escape, keyEscAction()); ADD_ACTION(Qt::Key_Delete, keyDeleteAction()); ADD_ACTION(Qt::Key_Up, keyUpAction()); ADD_ACTION(Qt::Key_Down, keyDownAction()); ADD_ACTION(Qt::Key_Left, keyLeftAction()); ADD_ACTION(Qt::Key_Right, keyRightAction()); #undef ADD_ACTION // Prepare the stuff for the gas-choices. gasListView = new QListView(); gasListView->setWindowFlags(Qt::Popup); gasListView->setModel(airTypes()); gasListView->hide(); gasListView->installEventFilter(this); connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex))); connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile())); connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(pointInserted(const QModelIndex&, int, int))); connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(pointsRemoved(const QModelIndex&, int, int))); setRenderHint(QPainter::Antialiasing); }
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); if (d->points.size() < 2) return ; // draw the bounding rect if the arrow is selected if (isSelected() /* && !m_hoverBegin && !m_hoverEnd */) { painter->save(); painter->setPen(Qt::blue); painter->drawRect(boundingRect()); painter->restore(); } if (d->points.isEmpty()) return ; // prepare pen and brush painter->save(); QPen pen; pen.setWidthF(lineWidth()) ; pen.setCapStyle(Qt::RoundCap) ; pen.setJoinStyle(Qt::RoundJoin) ; pen.setColor(getColor()) ; painter->setPen(pen) ; QPainterPath path ; // draw the line path.moveTo(d->points.first()) ; if (d->spline && splinePossible(d->points.size())) { for (int i = 1 ; i+2 < d->points.size() ; i += 3) path.cubicTo(d->points[i], d->points[i+1], d->points[i+2]); if (isSelected()) // Draw help lines { painter->save(); painter->setPen(Qt::gray) ; QPointF previous(d->points.first()) ; for (int i = 1 ; i+2 < d->points.size() ; i += 3) { painter->drawLine(previous, d->points[i]) ; painter->drawLine(d->points[i+1], d->points[i+2]); previous = d->points[i+2] ; } painter->restore(); } } else foreach(const QPointF p, d->points.mid(1)) path.lineTo(p) ; path.translate(-pos()); painter->drawPath(path) ; // draw arrow tips painter->setBrush(pen.color()); qreal tipScaling = relativeWidth(); if (MolScene *sc = qobject_cast<MolScene*>(scene())) tipScaling *= sc->settings()->arrowTipWidth()->get(); if ((UpperBackward | LowerBackward) & d->arrowType) painter->drawPath(generateArrowTip(d->points.last(), d->points[d->points.size()-2], pos(), UpperBackward & d->arrowType, LowerBackward & d->arrowType, tipScaling )); if ((UpperForward | LowerForward) & d->arrowType) painter->drawPath(generateArrowTip(d->points.first(), d->points[1], pos(), LowerForward & d->arrowType, UpperForward & d->arrowType, tipScaling )) ; painter->restore(); graphicsItem::paint(painter, option, widget); }
void LightsaberCrystalComponentImplementation::fillAttributeList(AttributeListMessage* alm, CreatureObject* object) { PlayerObject* player = object->getPlayerObject(); if (player->getJediState() > 1 || player->isPrivileged()){ if (getColor() == 31){ if (owner == ""){ StringBuffer str; str << "\\#FF6600" << "UNTUNED" ; alm->insertAttribute("crystal_owner", str); } else { alm->insertAttribute("crystal_owner", owner); } } } if (player->getJediState() > 1 || player->isPrivileged()) { if (getColor() != 31){ StringBuffer str; str << "\\#FF6600" << "UNTUNED" ; if (owner == ""){ alm->insertAttribute("crystal_owner", str); } else { alm->insertAttribute("crystal_owner", owner); } } } if (getColor() != 31){ if (owner == ""){ StringBuffer str2; str2 << "@jedi_spam:saber_color_" << getColor(); alm->insertAttribute("color", str2); } else { StringBuffer str3; str3 << "@jedi_spam:saber_color_" << getColor(); alm->insertAttribute("color", str3); } } if (player->getJediState() > 1 || player->isPrivileged()){ if (getColor() == 31){ if (owner != ""){ alm->insertAttribute("mindamage", minimumDamage); alm->insertAttribute("maxdamage", maximumDamage); alm->insertAttribute("wpn_attack_speed", attackSpeed); alm->insertAttribute("wpn_wound_chance", woundChance); alm->insertAttribute("wpn_attack_cost_health", sacHealth); alm->insertAttribute("wpn_attack_cost_action", sacAction); alm->insertAttribute("wpn_attack_cost_mind", sacMind); alm->insertAttribute("forcecost", forceCost); } else { StringBuffer str; str << "@jedi_spam:crystal_quality_" << getQuality(); alm->insertAttribute("quality", str); } } } TangibleObjectImplementation::fillAttributeList(alm, object); }
/*Funcao importante usada internamente. Ela executa o update grafico do passageiro no jogo.*/ void drawPassageiro(Entity ent) { Vetor pos = getPosicao(ent); drawCircle(pos, getRaio(ent), getColor(ent)); }
/*! Draw the statistics lines. */ void SimpleStatisticsForeground::draw(DrawEnv *pEnv, Viewport *pPort) { if(getActive() == false) return; if(_face == 0) initText(getFamily(), getSize()); if ((getCollector() == NULL) || (!getCollector()->getNumOfElems() && !getMFElementIDs()->size())) return; // nothing to do Real32 pw = Real32(pPort->getPixelWidth ()); Real32 ph = Real32(pPort->getPixelHeight()); if(pw < 1 || ph < 1) return; glPushAttrib(GL_LIGHTING_BIT | GL_POLYGON_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_DEPTH_TEST); glDisable(GL_COLOR_MATERIAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Set viewport. We want to map one unit to one pixel on the // screen. Some sources in the internet say that we should // add an offset of -0.375 to prevent rounding errors. Don't // know if that is true, but it seems to work. glOrtho(0 - 0.375, pw - 0.375, 0 - 0.375, ph - 0.375, 0, 1); // retrieve text std::vector < std::string > stat; StatCollector *col = this->getCollector(); StatElem *el; if(getMFElementIDs()->size() != 0) { for(UInt32 i = 0; i < getMFElementIDs()->size(); ++i) { Int32 id(getElementIDs(i)); el = ((id >= 0) ? col->getElem(id) : 0); stat.resize(stat.size() + 1); std::vector < std::string >::iterator str = stat.end() - 1; const char *format = NULL; if(i < getMFFormats()->size() && getFormats(i).length()) { format = getFormats(i).c_str(); } if (el) el->putToString(*str, format); else *str = format; } } else // fallback, show all elements { for(UInt32 i = 0; i < col->getNumOfElems(); ++i) { el = col->getElem(i, false); if(el) { std::string desc(el->getDesc()->getName()), eltext; el->putToString(eltext); desc = desc + " : " + eltext; stat.resize(stat.size() + 1); std::vector < std::string >::iterator str = stat.end() - 1; *str = desc; } } } TextLayoutParam layoutParam; layoutParam.spacing = 1.1f; layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN; layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN; TextLayoutResult layoutResult; _face->layout(stat, layoutParam, layoutResult); Real32 scale = 1 / _face->getScale(); Real32 size = _face->getParam().size; Real32 textWidth = layoutResult.textBounds.x() * scale + size + getTextMargin().x() * 2.0f; Real32 textHeight = layoutResult.textBounds.y() * scale + size + getTextMargin().y() * 2.0f; // Let's do some simple form of layout management Real32 orthoX = 0, orthoY = ph; switch ( getHorizontalAlign() ) { case Right: orthoX = pw - textWidth; break; case Middle: orthoX = (pw - textWidth) * 0.5; break; case Left: default: break; } switch ( getVerticalAlign() ) { case Bottom: orthoY = textHeight; break; case Center: orthoY = (ph - textHeight) * 0.5 + textHeight; break; case Top: default: break; } glTranslatef(orthoX, orthoY, 0.0); // draw background glColor4fv(static_cast<const GLfloat *>(getBgColor().getValuesRGBA())); glBegin(GL_QUADS); glVertex2f(0, -textHeight); glVertex2f(textWidth, -textHeight); glVertex2f(textWidth, 0); glVertex2f(0, 0); glEnd(); // draw border if(getBorderColor().alpha() >= 0.0f) { glColor4fv( static_cast<const GLfloat *>(getBorderColor().getValuesRGBA())); glBegin(GL_LINE_LOOP); glVertex2f(getBorderOffset().x(), -textHeight + 1 + getBorderOffset().y()); glVertex2f(textWidth - 1 - getBorderOffset().x(), -textHeight + 1 + getBorderOffset().y()); glVertex2f(textWidth - 1 - getBorderOffset().x(), -1 - getBorderOffset().y()); glVertex2f(getBorderOffset().x(), -1 - getBorderOffset().y()); glEnd(); } glTranslatef( 0.5 * size + getTextMargin().x(), -0.5 * size - getTextMargin().y(), 0.0); _texchunk ->activate(pEnv); _texenvchunk->activate(pEnv); // draw text shadow glColor4fv(static_cast<const GLfloat *>(getShadowColor().getValuesRGBA())); glPushMatrix(); glTranslatef(getShadowOffset().x(), getShadowOffset().y(), 0); glScalef(scale, scale, 1); _face->drawCharacters(layoutResult); // draw text glColor4fv(static_cast<const GLfloat *>(getColor().getValuesRGBA())); glPopMatrix(); glScalef(scale, scale, 1); _face->drawCharacters(layoutResult); _texchunk ->deactivate(pEnv); _texenvchunk->deactivate(pEnv); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); }
ofColor_<PixelType> ofPixels_<PixelType>::getColor(int x, int y) const { return getColor(getPixelIndex(x, y)); }
string Pawn::getType() { return getColor() + " Pawn"; }
glm::vec3 Sphere::collisionColor( const Ray& ray ) const { return getColor(); }
void BuildGeometry (unsigned int surface, unsigned int colorScheme, unsigned int subdivisions, unsigned int xyRatio, GLuint * polyList, GLuint * lineList, GLuint * pointList) { long i,j, index; long maxI = subdivisions * xyRatio, maxJ = subdivisions; double u, v, delta=0.001; recVec p1,p2; recVec *vertexPos = NULL,*vertexNormal = NULL; recColor *vertexColor = NULL; recTexCoord *vertexTexCoord = NULL; // set valid surface and color scheme surface %= kSurfaces; colorScheme %= kColorSchemes; // delete existing list if (*polyList) glDeleteLists (*polyList, 1); if (*lineList) glDeleteLists (*lineList, 1); if (*pointList) glDeleteLists (*pointList, 1); *polyList = *lineList = *pointList = 0; if (surface == kCube) // build the standard color cube (disregard color, subdivisions, and xyRatio) BuildCube (polyList, lineList, pointList, colorScheme); else { // build buffers vertexPos = (recVec*) malloc ((maxI) * (maxJ) * sizeof (recVec)); if (vertexNormal) free (vertexNormal); vertexNormal = (recVec*) malloc ((maxI) * (maxJ) * sizeof (recVec)); if (vertexColor) free (vertexColor); vertexColor = (recColor*) malloc ((maxI) * (maxJ) * sizeof (recColor)); if (vertexTexCoord) free (vertexTexCoord); vertexTexCoord = (recTexCoord*) malloc ((maxI) * (maxJ) * sizeof (recTexCoord)); if (!vertexPos || !vertexNormal || !vertexColor || !vertexTexCoord) return; // build surface for (i = 0; i < maxI; i++) { for (j = 0; j < maxJ; j++) { index = i * maxJ + j; u = -PI + (i % maxI) * TWOPI / maxI; v = -PI + (j % maxJ) * TWOPI / maxJ; vertexPos[index] = Eval(u,v, surface); p1 = Eval(u + delta, v, surface); p2 = Eval(u, v + delta, surface); vertexNormal[index] = CalcNormal(vertexPos[index],p1,p2); vertexColor[index] = getColor(u, -PI, PI, colorScheme); vertexTexCoord[index].s = (float) i * 5.0f / (float) maxI; vertexTexCoord[index].t = (float) j * 1.0f/ (float) maxJ; } } *polyList = glGenLists (1); glNewList(*polyList, GL_COMPILE); for (i=0; i< maxI; i++) { glBegin(GL_TRIANGLE_STRIP); for (j = 0; j <= maxJ; j++) { index = (i % maxI) * maxJ + (j % maxJ); glColor3fv (&vertexColor[index].r); glNormal3fv (&vertexNormal[index].x); glTexCoord2fv (&vertexTexCoord[index].s); glVertex3fv (&vertexPos[index].x); index = ((i + 1) % maxI) * maxJ + (j % maxJ); glColor3fv (&vertexColor[index].r); glNormal3fv (&vertexNormal[index].x); glTexCoord2fv (&vertexTexCoord[index].s); glVertex3fv (&vertexPos[index].x); // index = ((i - 1) % maxI) * maxJ + (j % maxJ); } glEnd (); } glEndList (); *lineList = glGenLists (1); glNewList(*lineList, GL_COMPILE); for (i=0; i< maxI; i++) { glBegin(GL_LINE_STRIP); for (j = 0; j < maxJ; j++) { index = i * maxJ + j; glColor3fv (&vertexColor[index].r); glVertex3fv (&vertexPos[index].x); } index = i * maxJ + 0; glColor3fv (&vertexColor[index].r); glVertex3fv (&vertexPos[index].x); glEnd (); } for (j=0; j< maxJ; j++) { glBegin(GL_LINE_STRIP); for (i = 0; i < maxI; i++) { index = i * maxJ + j; glColor3fv (&vertexColor[index].r); glVertex3fv (&vertexPos[index].x); } index = 0 + j; glColor3fv (&vertexColor[index].r); glVertex3fv (&vertexPos[index].x); glEnd (); } glEndList (); *pointList = glGenLists (1); glNewList(*pointList, GL_COMPILE); glBegin(GL_POINTS); for (i=0; i< maxI; i++) { for (j = 0; j < maxJ; j++) { index = i * maxJ + j; glColor3fv (&vertexColor[index].r); glVertex3fv (&vertexPos[index].x); } } glEnd (); glEndList (); free (vertexPos); free (vertexNormal); free (vertexColor); } }
QColor ShapeEntityItem::getQColor() const { auto& color = getColor(); return QColor(color[0], color[1], color[2], (int)(getAlpha() * 255)); }
void ToolItem::renderIcon(Screen * screen, int x, int y) { screen->render(x, y, getSprite(), getColor(), 0); }
/** * @return OrthographicLight's data structured for GPU use. **/ inline GPUData getGPUData() const { return GPUData{glm::vec4(getDirection(), 0.0), glm::vec4(glm::vec3(getColor()), 0.0), getBiasedMatrix()}; }
bool ThemeManager::startElement(const QString& , const QString& , const QString& qname, const QXmlAttributes& atts) { m_qname = qname; if (m_root.isNull()) { m_root = qname; } else if (m_root == "Theme") { if (qname == "Text") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor( QPalette::Text, c); } else if (qname == "Base") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Base, c); } else if (qname == "Foreground") { QColor c = getColor(atts); if (! c.isValid()) c = 0xd7d7ef; m_palette.setColor(QPalette::Foreground, c); } else if (qname == "Background") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Background, c); } else if (qname == "Button") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Button, c); } else if (qname == "ButtonText") { QColor c = getColor(atts); if (!c.isValid()) c = 0xd7d7ef; m_palette.setColor(QPalette::ButtonText, c); } else if (qname == "Light") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Light, c); } else if (qname == "Midlight") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Midlight, c); } else if (qname == "Dark") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Dark, c); } else if (qname == "Mid") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Mid, c); } else if (qname == "Highlight") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Highlight, c); } else if (qname == "HighlightedText") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::HighlightedText, c); } else if (qname == "BrightText") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::HighlightedText, c); } else if (qname == "Link") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::Link, c); } else if (qname == "LinkVisited") { QColor c = getColor(atts); if (c.isValid()) m_palette.setColor(QPalette::LinkVisited, c); } } return true; }
bool Card::isRed() const{ return getColor() == Red; }
bool Repeat9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& originalRect, bool rotated, const Rect& capInsets) { GLubyte opacity = getOpacity(); Color3B color = getColor(); Rect rect(originalRect); // Release old sprites this->removeAllChildrenWithCleanup(true); CC_SAFE_RELEASE(this->_centre); CC_SAFE_RELEASE(this->_top); CC_SAFE_RELEASE(this->_topLeft); CC_SAFE_RELEASE(this->_topRight); CC_SAFE_RELEASE(this->_left); CC_SAFE_RELEASE(this->_right); CC_SAFE_RELEASE(this->_bottomLeft); CC_SAFE_RELEASE(this->_bottom); CC_SAFE_RELEASE(this->_bottomRight); if(this->_scale9Image != batchnode) { CC_SAFE_RELEASE(this->_scale9Image); _scale9Image = batchnode; CC_SAFE_RETAIN(_scale9Image); } if (!_scale9Image) { return false; } _scale9Image->removeAllChildrenWithCleanup(true); _capInsets = capInsets; _spriteFrameRotated = rotated; // If there is no given rect if ( rect.equals(Rect::ZERO) ) { // Get the texture size as original Size textureSize = _scale9Image->getTextureAtlas()->getTexture()->getContentSize(); rect = Rect(0, 0, textureSize.width, textureSize.height); } // Set the given rect's size as original size _spriteRect = rect; _originalSize = rect.size; _preferredSize = _originalSize; _capInsetsInternal = capInsets; float w = rect.size.width; float h = rect.size.height; // If there is no specified center region if ( _capInsetsInternal.equals(Rect::ZERO) ) { // log("... cap insets not specified : using default cap insets ..."); _capInsetsInternal = Rect( w - floorf(w/3) * 2, h - floorf(h/3) * 2, floorf(w/3), floorf(h/3) ); } float left_w = _capInsetsInternal.origin.x; float center_w = _capInsetsInternal.size.width; float right_w = rect.size.width - (left_w + center_w); float top_h = _capInsetsInternal.origin.y; float center_h = _capInsetsInternal.size.height; float bottom_h = rect.size.height - (top_h + center_h); // calculate rects // ... top row float x = 0.0; float y = 0.0; // top left Rect lefttopbounds = Rect(x, y, left_w, top_h); // top center TRANSLATE_X(x, y, left_w); Rect centertopbounds = Rect(x, y, center_w, top_h); // top right TRANSLATE_X(x, y, center_w); Rect righttopbounds = Rect(x, y, right_w, top_h); // ... center row x = 0.0; y = 0.0; TRANSLATE_Y(x, y, top_h); // center left Rect leftcenterbounds = Rect(x, y, left_w, center_h); // center center TRANSLATE_X(x, y, left_w); Rect centerbounds = Rect(x, y, center_w, center_h); // center right TRANSLATE_X(x, y, center_w); Rect rightcenterbounds = Rect(x, y, right_w, center_h); // ... bottom row x = 0.0; y = 0.0; TRANSLATE_Y(x, y, top_h); TRANSLATE_Y(x, y, center_h); // bottom left Rect leftbottombounds = Rect(x, y, left_w, bottom_h); // bottom center TRANSLATE_X(x, y, left_w); Rect centerbottombounds = Rect(x, y, center_w, bottom_h); // bottom right TRANSLATE_X(x, y, center_w); Rect rightbottombounds = Rect(x, y, right_w, bottom_h); if (!rotated) { // log("!rotated"); AffineTransform t = AffineTransform::IDENTITY; t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y); centerbounds = RectApplyAffineTransform(centerbounds, t); rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); righttopbounds = RectApplyAffineTransform(righttopbounds, t); lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); centertopbounds = RectApplyAffineTransform(centertopbounds, t); // Centre _centre = Sprite::createWithTexture(_scale9Image->getTexture(), centerbounds); _centre->retain(); this->addChild(_centre, 0); // Top _top = RepeatNode::create(_leftMode, _scale9Image->getTexture(), centertopbounds); _top->retain(); this->addChild(_top, 1); // Bottom _bottom = RepeatNode::create(_bottomMode, _scale9Image->getTexture(), centerbottombounds); _bottom->retain(); this->addChild(_bottom, 1); // Left _left = RepeatNode::create(_leftMode, _scale9Image->getTexture(), leftcenterbounds); _left->retain(); this->addChild(_left, 1); // Right _right = RepeatNode::create(_rightMode, _scale9Image->getTexture(), rightcenterbounds); _right->retain(); this->addChild(_right, 1); // Top left _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), lefttopbounds); _topLeft->retain(); this->addChild(_topLeft, 2); // Top right _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), righttopbounds); _topRight->retain(); this->addChild(_topRight, 2); // Bottom left _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), leftbottombounds); _bottomLeft->retain(); this->addChild(_bottomLeft, 2); // Bottom right _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rightbottombounds); _bottomRight->retain(); this->addChild(_bottomRight, 2); } else { // set up transformation of coordinates // to handle the case where the sprite is stored rotated // in the spritesheet // log("rotated"); AffineTransform t = AffineTransform::IDENTITY; Rect rotatedcenterbounds = centerbounds; Rect rotatedrightbottombounds = rightbottombounds; Rect rotatedleftbottombounds = leftbottombounds; Rect rotatedrighttopbounds = righttopbounds; Rect rotatedlefttopbounds = lefttopbounds; Rect rotatedrightcenterbounds = rightcenterbounds; Rect rotatedleftcenterbounds = leftcenterbounds; Rect rotatedcenterbottombounds = centerbottombounds; Rect rotatedcentertopbounds = centertopbounds; t = AffineTransformTranslate(t, rect.size.height+rect.origin.x, rect.origin.y); t = AffineTransformRotate(t, 1.57079633f); centerbounds = RectApplyAffineTransform(centerbounds, t); rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); righttopbounds = RectApplyAffineTransform(righttopbounds, t); lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); centertopbounds = RectApplyAffineTransform(centertopbounds, t); rotatedcenterbounds.origin = centerbounds.origin; rotatedrightbottombounds.origin = rightbottombounds.origin; rotatedleftbottombounds.origin = leftbottombounds.origin; rotatedrighttopbounds.origin = righttopbounds.origin; rotatedlefttopbounds.origin = lefttopbounds.origin; rotatedrightcenterbounds.origin = rightcenterbounds.origin; rotatedleftcenterbounds.origin = leftcenterbounds.origin; rotatedcenterbottombounds.origin = centerbottombounds.origin; rotatedcentertopbounds.origin = centertopbounds.origin; // Centre _centre = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbounds, true); _centre->retain(); this->addChild(_centre, 0); // Top _top = RepeatNode::create(_topMode, _scale9Image->getTexture(), rotatedcentertopbounds,true); _top->retain(); this->addChild(_top, 1); // Bottom _bottom = RepeatNode::create(_bottomMode, _scale9Image->getTexture(), rotatedcenterbottombounds,true); _bottom->retain(); this->addChild(_bottom, 1); // Left _left = RepeatNode::create(_leftMode, _scale9Image->getTexture(), rotatedleftcenterbounds,true); _left->retain(); this->addChild(_left, 1); // Right _right = RepeatNode::create(_rightMode, _scale9Image->getTexture(), rotatedrightcenterbounds,true); _right->retain(); this->addChild(_right, 1); // Top left _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedlefttopbounds, true); _topLeft->retain(); this->addChild(_topLeft, 2); // Top right _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrighttopbounds, true); _topRight->retain(); this->addChild(_topRight, 2); // Bottom left _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftbottombounds, true); _bottomLeft->retain(); this->addChild(_bottomLeft, 2); // Bottom right _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightbottombounds, true); _bottomRight->retain(); this->addChild(_bottomRight, 2); } this->setContentSize(rect.size); this->addChild(_scale9Image); if (_spritesGenerated) { // Restore color and opacity this->setOpacity(opacity); this->setColor(color); } _spritesGenerated = true; return true; }
bool Card::isBlack() const{ return getColor() == Black; }
void printCar(Car *car) { printf("%s %s %s %d %c %s %s %d %d", car->brand, car->type, getColor(car->color), car->year, car->fuel, getDate(car->evidDate), car->licansePlate, car->performance, car->driven); }
void PulseAnalysisDisplay::loopRefresh () { if (!window->visible()) return; // some pointers double *x=NULL; double *y=NULL; unsigned int n = 0; int id; // loop through all traces for (unsigned int i=0; i<INDEPENDENT_TRACES; i++) { // remember that '0" is the '-' channel int channel = channelSelector[i]->value() - 1; // this is where you pick what gets splashed on the plot canvas if (channel != -1) { switch (plotSelector->value()) { case 0: // pulse height vs time { // request a copy of the data xdaq::StreamChannel *SD = client->streamData[channel]; if (SD != NULL) { // request some data SD->requestPulseHeightCopy(&x,&y,&n); // test for no data if (n==0) break; // pass that to the plotter and tell it to keep it id = plot->ingestAndKeepData(x,y,n); if (id == -1) break; // add the color Fl_Color color = getColor (traceColorSelector[i]->value()); plot->color(id,color); } // release the lock client->latestTriggeredPulseLock[channel].releaseLock(); break; } case 1: // baseline vs time { xdaq::StreamChannel *SD = client->streamData[channel]; if (SD != NULL) { // request some data SD->requestBaselineCopy(&x,&y,&n); // test for no data if (n==0) break; // pass that to the plotter and tell it to keep it id = plot->ingestAndKeepData(x,y,n); if (id == -1) break; // add the color Fl_Color color = getColor (traceColorSelector[i]->value()); plot->color(id,color); } client->latestTriggeredPulseLock[channel].releaseLock(); break; } default: { std::cout << "Plot error... no plot type selected" << std::endl; break; } } } } // now that you have sent all the data to the plots, stick it to the screen plot->loopRefresh(); }