// This is only used to draw borders. void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) { if (paintingDisabled()) return; FloatPoint p1 = point1; FloatPoint p2 = point2; QPainter *p = m_data->p(); const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines); adjustLineToPixelBoundaries(p1, p2, strokeThickness(), strokeStyle()); IntSize shadowSize; int shadowBlur; Color shadowColor; if (textDrawingMode() == cTextFill && getShadow(shadowSize, shadowBlur, shadowColor)) { p->save(); p->translate(shadowSize.width(), shadowSize.height()); p->setPen(QColor(shadowColor)); p->drawLine(p1, p2); p->restore(); } p->drawLine(p1, p2); p->setRenderHint(QPainter::Antialiasing, antiAlias); }
/** * Calculate the light intensity with soft shadows * @param vec3 {x,y,z} p point on surface * @param vec3 {x,y,z} lightPos position of the light source * @param vec4 {r,g,b,a} lightColor the radiance of the light source * @return vec4 {r,g,b,a} the color of the point */ vec4 getShading(vec3 p, vec3 normal, vec3 lightPos, vec4 lightColor) { float lightIntensity = 0.0; float shadow = getShadow(p, lightPos, 32.0); if(shadow > 0.0) { // If we are at all visible vec3 lightDirection = normalize(lightPos - p); lightIntensity = shadow * clamp(dot(normal, lightDirection), 0.0, 1.0); } return lightColor * lightIntensity + u_ambient * (1.0 - lightIntensity); }
void CSObject::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) { out->addInt( "Id", getId()); out->addString( "Name", getName().c_str()); out->addBool( "Dead", getDead()); out->addBool( "DebugObject", getDebugObject()); out->addVector3d( "Position", getRelativePosition()); out->addVector3d( "PositionOffset", getPositionOffset()); out->addVector3d( "Rotation", getRelativeRotation()); out->addVector3d( "RotationOffset", getRotationOffset()); out->addVector3d( "Scale", getRelativeScale()); out->addVector3d( "ScaleOffset", getScaleOffset()); out->addVector3d( "BBOffset", getBBOffset()); out->addBool( "Shadow", getShadow()); out->addString( "ActorFileName", getActorFileName().c_str()); out->addString( "TextureFileName", getTextureFileName().c_str()); }
void MainWindow::addToGridView(Rom *currentRom, int count) { ClickableWidget *gameGridItem = new ClickableWidget(gridWidget); gameGridItem->setMinimumWidth(getGridSize("width")); gameGridItem->setMaximumWidth(getGridSize("width")); gameGridItem->setGraphicsEffect(getShadow(false)); //Assign ROM data to widget for use in click events gameGridItem->setProperty("fileName", currentRom->fileName); gameGridItem->setProperty("directory", currentRom->directory); if (currentRom->goodName == getTranslation("Unknown ROM") || currentRom->goodName == getTranslation("Requires catalog file")) gameGridItem->setProperty("search", currentRom->internalName); else gameGridItem->setProperty("search", currentRom->goodName); gameGridItem->setProperty("romMD5", currentRom->romMD5); gameGridItem->setProperty("zipFile", currentRom->zipFile); QGridLayout *gameGridLayout = new QGridLayout(gameGridItem); gameGridLayout->setColumnStretch(0, 1); gameGridLayout->setColumnStretch(3, 1); gameGridLayout->setRowMinimumHeight(1, getImageSize("Grid").height()); QLabel *gridImageLabel = new QLabel(gameGridItem); gridImageLabel->setMinimumHeight(getImageSize("Grid").height()); gridImageLabel->setMinimumWidth(getImageSize("Grid").width()); QPixmap image; if (currentRom->imageExists) { //Use uniform aspect ratio to account for fluctuations in TheGamesDB box art Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio; //Don't warp aspect ratio though if image is too far away from standard size (JP box art) float aspectRatio = float(currentRom->image.width()) / currentRom->image.height(); if (aspectRatio < 1.1 || aspectRatio > 1.8) aspectRatioMode = Qt::KeepAspectRatio; image = currentRom->image.scaled(getImageSize("Grid"), aspectRatioMode, Qt::SmoothTransformation); } else image = QPixmap(":/images/not-found.png").scaled(getImageSize("Grid"), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); gridImageLabel->setPixmap(image); gridImageLabel->setAlignment(Qt::AlignCenter); gameGridLayout->addWidget(gridImageLabel, 1, 1); if (SETTINGS.value("Grid/label","true") == "true") { QLabel *gridTextLabel = new QLabel(gameGridItem); //Don't allow label to be wider than image gridTextLabel->setMaximumWidth(getImageSize("Grid").width()); QString text = ""; QString labelText = SETTINGS.value("Grid/labeltext","Filename").toString(); text = getRomInfo(labelText, currentRom); gridTextLabel->setText(text); QString textHex = getColor(SETTINGS.value("Grid/labelcolor","White").toString()).name(); int fontSize = getGridSize("font"); gridTextLabel->setStyleSheet("QLabel { font-weight: bold; color: " + textHex + "; font-size: " + QString::number(fontSize) + "px; }"); gridTextLabel->setWordWrap(true); gridTextLabel->setAlignment(Qt::AlignHCenter | Qt::AlignTop); gameGridLayout->addWidget(gridTextLabel, 2, 1); } gameGridItem->setLayout(gameGridLayout); gameGridItem->setMinimumHeight(gameGridItem->sizeHint().height()); int columnCount = SETTINGS.value("Grid/columncount", "4").toInt(); gridLayout->addWidget(gameGridItem, count / columnCount + 1, count % columnCount + 1); gridWidget->adjustSize(); connect(gameGridItem, SIGNAL(singleClicked(QWidget*)), this, SLOT(highlightGridWidget(QWidget*))); connect(gameGridItem, SIGNAL(doubleClicked(QWidget*)), this, SLOT(launchRomFromWidget(QWidget*))); }