void PaintingItemPainter::paint(QNanoPainter *painter) { // Background QNanoRadialGradient grad; grad.setStartColor("#808080"); grad.setEndColor("#606060"); grad.setCenterPosition(width()/2, height()/2); grad.setOuterRadius(qMax(width(), height())*0.6); painter->setFillStyle(grad); painter->setStrokeStyle("#F0F0F0"); painter->setLineWidth(1); painter->beginPath(); painter->rect(0, 0, width(), height()); painter->fill(); painter->stroke(); // Draw painting line if (m_paths.size() > 0) { painter->setLineCap(QNanoPainter::CAP_ROUND); painter->setLineJoin(QNanoPainter::JOIN_ROUND); float lineWidth = QNanoPainter::mmToPx(2); painter->setLineWidth(lineWidth); for (int i=0; i<m_paths.count(); ++i) { auto item = m_paths.at(i).data(); auto points = item->m_points; if (points.count() > 0) { QNanoColor shadowColor("#202020"); shadowColor.setAlpha(item->opacity() * 200); painter->setStrokeStyle(shadowColor); painter->setAntialias(10.0); drawPathLine(points, QPoint(lineWidth*0.2, lineWidth*0.2)); QNanoColor lineColor("#F0D060"); lineColor.setAlpha(item->opacity() * 255); painter->setStrokeStyle(lineColor); painter->setAntialias(2.0); drawPathLine(points, QPoint(0,0)); // If animation is still running, update if (item->m_hideAnimation.state() == QAbstractAnimation::Running) { emit update(); } } } } }
void ImageItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget) { ppainter->save(); if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY); else ppainter->setOpacity(qreal(opacity())/100); QPointF point = rect().topLeft(); QImage img; if (m_scale && !image().isNull()){ img = image().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } else { img = image(); } qreal shiftHeight = rect().height() - img.height(); qreal shiftWidth = rect().width() - img.width(); if (m_center){ if (shiftHeight<0 || shiftWidth<0){ qreal cutX = 0; qreal cutY = 0; qreal cutWidth = img.width(); qreal cutHeigth = img.height(); if (shiftWidth > 0){ point.setX(point.x()+shiftWidth/2); } else { cutX = abs(shiftWidth/2); cutWidth += shiftWidth; } if (shiftHeight > 0){ point.setY(point.x()+shiftHeight/2); } else { cutY = abs(shiftHeight/2); cutHeigth += shiftHeight; } img = img.copy(cutX,cutY,cutWidth,cutHeigth); } else { point.setX(point.x()+shiftWidth/2); point.setY(point.y()+shiftHeight/2); } } if (img.isNull() && itemMode()==DesignMode){ QString text; ppainter->setFont(transformToSceneFont(QFont("Arial",10))); if (!datasource().isEmpty() && !field().isEmpty()) text = datasource()+"."+field(); else text = tr("Image"); ppainter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text ); } else { ppainter->drawImage(point,img); } ItemDesignIntf::paint(ppainter,option,widget); ppainter->restore(); }
IntRect CCDrawQuad::opaqueRect() const { if (opacity() != 1) return IntRect(); if (m_sharedQuadState->isOpaque() && m_quadOpaque) return m_quadRect; return m_opaqueRect; }
bool QtCurveHandler::supports(Ability ability) const { switch (ability) { // announce case AbilityAnnounceButtons: case AbilityAnnounceColors: // buttons case AbilityButtonMenu: case AbilityButtonOnAllDesktops: case AbilityButtonSpacer: case AbilityButtonHelp: case AbilityButtonMinimize: case AbilityButtonMaximize: case AbilityButtonClose: case AbilityButtonAboveOthers: case AbilityButtonBelowOthers: case AbilityButtonShade: // TODO // case AbilityButtonResize: #if KDE_IS_VERSION(4, 9, 85) case AbilityButtonApplicationMenu: #endif // colors case AbilityColorTitleBack: case AbilityColorTitleFore: case AbilityColorFrame: return true; #if KDE_IS_VERSION(4, 3, 0) case AbilityUsesAlphaChannel: return true; // !Handler()->outerBorder(); ??? case AbilityProvidesShadow: return customShadows(); #endif #if KDE_IS_VERSION(4, 3, 85) && !KDE_IS_VERSION(4, 8, 80) case AbilityClientGrouping: return grouping(); #endif #if KDE_IS_VERSION(4, 5, 85) case AbilityUsesBlurBehind: return opacity(true)<100 || opacity(false)<100 || wStyle()->pixelMetric((QStyle::PixelMetric)QtC_CustomBgnd, 0L, 0L); #endif // TODO's default: return false; } }
void BubbleChatBox::setText(const QString &text) { chatLabel->setHtml(text); QString plainText = chatLabel->toPlainText(); if (plainText.isEmpty()) { return; } QFontMetrics fontMetrics(chatLabel->font()); int imageCount = text.count("</img>"); int width = qAbs(fontMetrics.width(plainText)) + imageCount * ChatFaceWidth; int lineCount = 1; if (width > PixelsPerLine) { lineCount = width / PixelsPerLine; if (lineCount >= MaxLineCount) { lineCount = MaxLineCount; } else if (width % PixelsPerLine != 0) { ++lineCount; } width = PixelsPerLine; } int boxWidth = width + fontMetrics.maxWidth(); if (boxWidth <= BoxMinWidth) { boxWidth = BoxMinWidth; chatLabel->setAlignment(Qt::AlignHCenter); } else { chatLabel->setAlignment(Qt::AlignLeft); } chatLabel->setTextWidth(boxWidth); QRectF oldRect = rect; int height = fontMetrics.lineSpacing() + fontMetrics.xHeight(); rect.setSize(QSize(boxWidth + BoxRightFrameWidth, height * lineCount + BoxFrameHeight)); chatLabel->setPos(QPointF(BoxLeftFrameWidth, rect.center().y() - (height * lineCount) + (lineCount - 1) * (height / 2) - (imageCount > 0 ? 1 : 0))); chatLabel->setBoundingRect(QRectF(0, 0, boxWidth, height * lineCount + (MaxLineCount - lineCount) * 1)); updatePos(); if (opacity() != 1) { appearAndDisappear->setDirection(QAbstractAnimation::Forward); appearAndDisappear->start(); } if (oldRect.width() > rect.width()) { QRectF sceneRect = mapRectToScene(oldRect); scene()->update(sceneRect); } else { update(); } timer.start(Config.BubbleChatBoxKeepSeconds * 1000 - AnimationDuration); }
int main( int argc, char** argv ) { kvs::glut::Application app( argc, argv ); PaintEvent paint_event; kvs::glut::Screen screen( &app ); screen.addEvent( &paint_event ); screen.setTitle( "Slider" ); screen.setGeometry( 0, 0, 512, 512 ); screen.show(); RedSlider red( &screen ); red.setSliderColor( kvs::RGBColor( 255, 0, 0 ) ); red.setX( 0 ); red.setY( 0 ); red.setWidth( 150 ); red.setValue( 0 ); red.setRange( 0, 255 ); red.setMargin( 10 ); red.setCaption("Red"); red.show(); GreenSlider green( &screen ); green.setSliderColor( kvs::RGBColor( 0, 255, 0 ) ); green.setX( red.x() ); green.setY( red.y() + red.height() ); green.setWidth( 150 ); green.setValue( 0 ); green.setRange( 0, 255 ); green.setMargin( 10 ); green.setCaption("Green"); green.show(); BlueSlider blue( &screen ); blue.setSliderColor( kvs::RGBColor( 0, 0, 255 ) ); blue.setX( green.x() ); blue.setY( green.y() + green.height() ); blue.setWidth( 150 ); blue.setValue( 0 ); blue.setRange( 0, 255 ); blue.setMargin( 10 ); blue.setCaption("Blue"); blue.show(); OpacitySlider opacity( &screen ); opacity.setX( blue.x() ); opacity.setY( blue.y() + blue.height() ); opacity.setWidth( 150 ); opacity.setValue( 1 ); opacity.setRange( 0, 1 ); opacity.setMargin( 10 ); opacity.setCaption("Opacity"); opacity.show(); return app.run(); }
void ThumbnailLabel::setOpacityAnimated(qreal amount, int speed) { if(amount != opacity()) { QPropertyAnimation *anim = new QPropertyAnimation(this, "currentOpacity"); anim->setEasingCurve(QEasingCurve::InQuad); anim->setDuration(speed); anim->setStartValue(this->opacity()); anim->setEndValue(amount); anim->start(QAbstractAnimation::DeleteWhenStopped); } }
void PictureShape::loadStyle(const KoXmlElement& element, KoShapeLoadingContext& context) { // Load the common parts of the style. KoTosContainer::loadStyle(element, context); KoStyleStack &styleStack = context.odfLoadingContext().styleStack(); styleStack.setTypeProperties("graphic"); // Mirroring if (styleStack.hasProperty(KoXmlNS::style, "mirror")) { QString mirrorMode = styleStack.property(KoXmlNS::style, "mirror"); QFlags<PictureShape::MirrorMode> mode = 0; // Only one of the horizontal modes if (mirrorMode.contains("horizontal-on-even")) { mode |= MirrorHorizontalOnEven; } else if (mirrorMode.contains("horizontal-on-odd")) { mode |= MirrorHorizontalOnOdd; } else if (mirrorMode.contains("horizontal")) { mode |= MirrorHorizontal; } if (mirrorMode.contains("vertical")) { mode |= MirrorVertical; } m_mirrorMode = mode; } // Color-mode (effects) if (styleStack.hasProperty(KoXmlNS::draw, "color-mode")) { QString colorMode = styleStack.property(KoXmlNS::draw, "color-mode"); if (colorMode == "greyscale") { setColorMode(Greyscale); } else if (colorMode == "mono") { setColorMode(Mono); } else if (colorMode == "watermark") { setColorMode(Watermark); } } // image opacity QString opacity(styleStack.property(KoXmlNS::draw, "image-opacity")); if (! opacity.isEmpty() && opacity.right(1) == "%") { setTransparency(1.0 - (opacity.left(opacity.length() - 1).toFloat() / 100.0)); } // clip rect m_clippingRect = parseClippingRectString(styleStack.property(KoXmlNS::fo, "clip")); }
void UIPopupPane::paintBackground(const QRect &rect, QPainter &painter) { /* Paint background: */ QColor currentColor(palette().color(QPalette::Window)); QColor newColor1(currentColor.red(), currentColor.green(), currentColor.blue(), opacity()); QColor newColor2 = newColor1.darker(115); QLinearGradient headerGradient(rect.topLeft(), rect.bottomLeft()); headerGradient.setColorAt(0, newColor1); headerGradient.setColorAt(1, newColor2); painter.fillRect(rect, headerGradient); }
KisLayerSP KisCloneLayer::reincarnateAsPaintLayer() const { KisPaintDeviceSP newOriginal = new KisPaintDevice(*original()); KisPaintLayerSP newLayer = new KisPaintLayer(image(), name(), opacity(), newOriginal); newLayer->setX(newLayer->x() + x()); newLayer->setY(newLayer->y() + y()); newLayer->setCompositeOp(compositeOpId()); newLayer->mergeNodeProperties(nodeProperties()); return newLayer; }
void Toplevel::setOpacity(double new_opacity) { double old_opacity = opacity(); new_opacity = qBound(0.0, new_opacity, 1.0); if (old_opacity == new_opacity) return; info->setOpacity(static_cast< unsigned long >(new_opacity * 0xffffffff)); if (compositing()) { addRepaintFull(); emit opacityChanged(this, old_opacity); } }
/*--------------------------------------------------------------------------*/ void iterate_surface_temp(planets_record &planet) { double surface_temp, effective_temp = eff_temp(r_ecosphere,planet.a,EARTH_ALBEDO), greenhouse_rise, previous_temp, optical_depth = opacity(planet.molecule_weight,planet.surface_pressure), albedo, water, clouds, ice; // optical_depth = opacity((*planet)->molecule_weight,(*planet)->surface_pressure); // effective_temp = eff_temp(r_ecosphere,(*planet)->a,EARTH_ALBEDO); greenhouse_rise = green_rise(optical_depth,effective_temp,planet.surface_pressure); surface_temp = effective_temp + greenhouse_rise; // previous_temp = surface_temp - 5.0; /* force the while loop the first time */ // while ((fabs(surface_temp - previous_temp) > 1.0)) do { previous_temp = surface_temp; water = hydrosphere_fraction(planet.volatile_gas_inventory,planet.radius); clouds = cloud_fraction(surface_temp,planet.molecule_weight,planet.radius,water); ice = ice_fraction(water,surface_temp); if ((surface_temp >= planet.boil_point) || (surface_temp <= FREEZING_POINT_OF_WATER)) water = 0.0; albedo = planet_albedo(water,clouds,ice,planet.surface_pressure); optical_depth = opacity(planet.molecule_weight,planet.surface_pressure); effective_temp = eff_temp(r_ecosphere,planet.a,albedo); greenhouse_rise = green_rise(optical_depth,effective_temp,planet.surface_pressure); surface_temp = effective_temp + greenhouse_rise; }while ((fabs(surface_temp - previous_temp) > 1.0)); planet.hydrosphere = water; planet.cloud_cover = clouds; planet.ice_cover = ice; planet.albedo = albedo; planet.surface_temp = surface_temp; }
void STStripeAnimationView::visibilityChanged(){ if(isVisible() && opacity()>=.01f && !(m_value>=0.f && m_value<=1.f)){ if(!m_timer){ m_timer=startTimer(32); timerEvent(NULL); } }else{ if(m_timer){ killTimer(m_timer); m_timer=0; } } }
void AbstractClient::setActive(bool act) { if (m_active == act) { return; } m_active = act; const int ruledOpacity = m_active ? rules()->checkOpacityActive(qRound(opacity() * 100.0)) : rules()->checkOpacityInactive(qRound(opacity() * 100.0)); setOpacity(ruledOpacity / 100.0); workspace()->setActiveClient(act ? this : NULL); if (!m_active) cancelAutoRaise(); if (!m_active && shadeMode() == ShadeActivated) setShade(ShadeNormal); doSetActive(); emit activeChanged(); updateMouseGrab(); }
void DockModeWindow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { painter->setRenderHint(QPainter::SmoothPixmapTransform, !m_maximized); QPainter::CompositionMode previous = painter->compositionMode(); painter->setCompositionMode(m_compMode); paintBase(painter, m_maximized); if (m_loadingOverlayEnabled) { bool maximized = qFuzzyCompare(scale(), (qreal)1.0) && qFuzzyCompare(x(), (qreal)0.0); painter->setRenderHint(QPainter::SmoothPixmapTransform, true); QPainter::CompositionMode previous = painter->compositionMode(); painter->setCompositionMode(QPainter::CompositionMode_SourceOver); painter->fillRect(boundingRect(), QColor (0, 0, 0, 0xff)); painter->setCompositionMode(QPainter::CompositionMode_SourceOver); // Draw the glow pulse painter->setBrushOrigin(boundingRect().x(), boundingRect().y()); if (s_dockGlow) { painter->setOpacity(opacity() * pulseOpacity()); painter->drawPixmap (boundingRect(), *s_dockGlow, (*s_dockGlow).rect()); painter->setOpacity(opacity()); } painter->setBrushOrigin(0, 0); // Draw the icon in front of the glow painter->drawPixmap(-m_icon.width()/2, -m_icon.height()/2, m_icon); painter->setCompositionMode(previous); painter->setRenderHint(QPainter::SmoothPixmapTransform, false); } paintOverlay(painter, m_maximized); painter->setCompositionMode(previous); painter->setRenderHint(QPainter::SmoothPixmapTransform, false); }
void Layer::addDefaultKeyAccessors() { key2setter["opacity"] = [this](const Variant& v) { ASSERT(v.type==VT_float, "opacity must be float"); opacity(v.f); }; key2getter["opacity"] = [this]() { return Variant(_opacity); }; key2setter["size"] = [this](const Variant& v) { ASSERT(v.type==VT_vec2, "size must be Vec2"); size(v.vec2); }; key2getter["size"] = [this]() { return Variant(size()); }; key2setter["pos"] = [this](const Variant& v) { ASSERT(v.type==VT_vec2, "pos must be Vec2"); pos(v.vec2); }; key2getter["pos"] = [this]() { return Variant(pos()); }; key2setter["x"] = [this](const Variant& v) { ASSERT(v.type==VT_float, "x must be f32"); x(v.f); }; key2getter["x"] = [this]() { return Variant(x()); }; key2setter["y"] = [this](const Variant& v) { ASSERT(v.type==VT_float, "y must be f32"); y(v.f); }; key2getter["y"] = [this]() { return Variant(y()); }; key2setter["width"] = [this](const Variant& v) { ASSERT(v.type==VT_float, "width must be f32"); width(v.f); }; key2getter["width"] = [this]() { return Variant(width()); }; key2setter["height"] = [this](const Variant& v) { ASSERT(v.type==VT_float, "height must be f32"); height(v.f); }; key2getter["height"] = [this]() { return Variant(height()); }; }
Material::Material(Material_t tag) : tag(tag), vertexShader(this), fragmentShader(this), index0AttributeName(this) { mId = Material::MaterialIdCount++; mUuid = Math::generateUUID(); mName = ""; side() = kFrontSide; opacity() = 1.0f; transparent() = false; blending() = kNormalBlending; blendSrc() = kSrcAlphaFactor; blendDst() = kOneMinusSrcAlphaFactor; blendEquation() = kAddEquation; depthTest() = true; depthWrite() = true; polygonOffset() = false; polygonOffsetFactor() = 0; polygonOffsetUnits() = 0; // mAlphaTest = 0; overdraw() = 0; // Overdrawn pixels (typically between 0 and 1) for fixing antialiasing gaps in CanvasRenderer visible() = true; needsUpdate() = true; // By default, bind position to attribute index 0. In WebGL, attribute 0 // should always be used to avoid potentially expensive emulation. index0AttributeName("position"); linewidth() = 1.0f; metal() = false; perPixel() = true; shading() = kNoShading; vertexColors() = kNoColors; wireframe() = false; wireframeLinewidth() = 1.0f; }
void SyberGraphRect::paint(QPainter *painter) { painter->save(); m_pen.setWidth(lineWidth()); painter->setOpacity(opacity()); painter->setPen(m_pen); painter->setBrush(m_color); painter->setRenderHint(QPainter::Antialiasing); if(m_bRound) painter->drawRoundedRect(m_box,20,20); else painter->drawRect(m_box); painter->restore(); }
bool ElasticItem::checkCollision(MoveableItem *item) { if (opacity() == 0) return false; QPoint ballCenter = item->centerPoint(); QPoint mappedCenter = mapFromItem(item->parentItem(), ballCenter).toPoint(); ballCenter = mappedCenter; if (topSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedY(-fabs(item->speedY())); return true; } if (bottomSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedY(fabs(item->speedY())); return true; } if (leftSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(-fabs(item->speedX())); return true; } if (rightSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(fabs(item->speedX())); return true; } if (topLeftSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(-fabs(item->speedX())); item->setSpeedY(-fabs(item->speedY())); return true; } if (topRightSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(fabs(item->speedX())); item->setSpeedY(-fabs(item->speedY())); return true; } if (bottomLeftSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(-fabs(item->speedX())); item->setSpeedY(fabs(item->speedY())); return true; } if (bottomRightSensor(item->width()/2).contains(ballCenter, true)) { item->setSpeedX(fabs(item->speedX())); item->setSpeedY(fabs(item->speedY())); return true; } return false; }
// --- Drawing ------------------------------------------------------------- // void GraphicsIsosurfaceItem::paint(GraphicsPainter *painter) { if(!d->scalarField) { return; } if(!d->buffer) { d->buffer = marchCubes(d->scalarField, d->isovalue); } QColor color = d->color; color.setAlphaF(opacity()); painter->setColor(color); painter->draw(d->buffer); }
//______________________________________________ qreal ScrollBarData::opacity( QStyle::SubControl subcontrol ) const { switch( subcontrol ) { default: case QStyle::SC_ScrollBarSlider: return opacity(); case QStyle::SC_ScrollBarAddLine: return addLineOpacity(); case QStyle::SC_ScrollBarSubLine: return subLineOpacity(); } }
int PushButtonBase::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QPushButton::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = opacity(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setOpacity(*reinterpret_cast< qreal*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 1) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
//_______________________________________________ QColor Button::buttonDetailColor(const QPalette &palette) const { auto d( qobject_cast<Decoration*>( decoration().data() ) ); if( d->isAnimated() ) { return KColorUtils::mix( buttonDetailColor( palette, false ), buttonDetailColor( palette, true ), d->opacity() ); } else { return buttonDetailColor( palette, isActive()); } }
void WebGraphicsLayer::syncCompositingStateForThisLayerOnly() { if (!m_layerTreeTileClient) m_layerTreeTileClient = layerTreeTileClient(); updateContentBuffers(); if (!m_modified) return; m_layerInfo.name = name(); m_layerInfo.anchorPoint = anchorPoint(); m_layerInfo.backfaceVisible = backfaceVisibility(); m_layerInfo.childrenTransform = childrenTransform(); m_layerInfo.contentsOpaque = contentsOpaque(); m_layerInfo.contentsRect = contentsRect(); m_layerInfo.drawsContent = drawsContent(); m_layerInfo.mask = toWebLayerID(maskLayer()); m_layerInfo.masksToBounds = masksToBounds(); m_layerInfo.opacity = opacity(); m_layerInfo.parent = toWebLayerID(parent()); m_layerInfo.pos = position(); m_layerInfo.preserves3D = preserves3D(); m_layerInfo.replica = toWebLayerID(replicaLayer()); m_layerInfo.size = size(); m_layerInfo.transform = transform(); m_contentNeedsDisplay = false; m_layerInfo.children.clear(); for (size_t i = 0; i < children().size(); ++i) m_layerInfo.children.append(toWebLayerID(children()[i])); ASSERT(m_layerTreeTileClient); if (m_layerInfo.imageIsUpdated && m_image && !m_layerInfo.imageBackingStoreID) m_layerInfo.imageBackingStoreID = m_layerTreeTileClient->adoptImageBackingStore(m_image.get()); m_layerTreeTileClient->didSyncCompositingStateForLayer(m_layerInfo); m_modified = false; m_layerInfo.imageIsUpdated = false; if (m_hasPendingAnimations) notifyAnimationStarted(WTF::currentTime()); m_layerInfo.animations.clear(); m_hasPendingAnimations = false; }
float ambient_occlusion_lightmap::recurse (const ray_bundle& r, float ray_power, const world_coordinates& blk, world_lightmap_access& data, bool first) const { float temp (0.0f); bool should_recurse (true); for (auto& voxel : r.trunk) { auto type (data[blk + voxel].type); // If the very first block we traverse is a custom block, we // skip it. if (first) { first = false; if (material_prop[type].is_custom_block()) continue; } temp += opacity(type); if (temp >= 1.0f) { should_recurse = false; break; } } ray_power -= std::min(temp, 1.0f) * r.weight; if (ray_power <= 0.01) return 0.0; if (should_recurse) { for (auto& s : r.branches) ray_power = recurse(s, ray_power, blk, data, first); } return ray_power; }
QAbstractAnimation* CardItem::getGoBackAnimation(bool doFade, bool smoothTransition) { m_animationMutex.lock(); if (m_currentAnimation != NULL) { m_currentAnimation->stop(); delete m_currentAnimation; m_currentAnimation = NULL; } QPropertyAnimation *goback = new QPropertyAnimation(this, "pos"); goback->setEndValue(home_pos); goback->setEasingCurve(QEasingCurve::OutQuad); goback->setDuration(Config.S_MOVE_CARD_ANIMATION_DURAION); if(doFade){ QParallelAnimationGroup *group = new QParallelAnimationGroup; QPropertyAnimation *disappear = new QPropertyAnimation(this, "opacity"); double middleOpacity = qMax(opacity(), m_opacityAtHome); if (middleOpacity == 0) middleOpacity = 1.0; disappear->setEndValue(m_opacityAtHome); if (!smoothTransition) { disappear->setKeyValueAt(0.2, middleOpacity); disappear->setKeyValueAt(0.8, middleOpacity); disappear->setDuration(Config.S_MOVE_CARD_ANIMATION_DURAION); } group->addAnimation(goback); group->addAnimation(disappear); // card is disabled while moving // setEnabled(false); m_currentAnimation = group; } else { m_currentAnimation = goback; } m_animationMutex.unlock(); connect(m_currentAnimation, SIGNAL(finished()), this, SIGNAL(movement_animation_finished())); return m_currentAnimation; }
double StdMaterial::lightFreePathLength(const Raycast& ray) const { double opa = opacity(ray.origin); if(opa <= 0.0) { return Raycast::BACKDROP_LIMIT; } else if(opa >= 1.0) { return 0.0; } else { double scatterRate = 1 / (1 / (opa) - 1); std::exponential_distribution<> distrib(scatterRate); return distrib(_randomEngine); } }
void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { QTransform x = painter->worldTransform(); QLineF unit = x.map(QLineF(0, 0, 1, 1)); if (unit.p1().x() > unit.p2().x() || unit.p1().y() > unit.p2().y()) { if (proxyWidget && proxyWidget->isVisible()) { proxyWidget->hide(); proxyWidget->setGeometry(rect()); } return; } if (proxyWidget && !proxyWidget->isVisible()) { proxyWidget->show(); proxyWidget->setFocus(); } if (proxyWidget && proxyWidget->pos() != QPoint()) proxyWidget->setGeometry(boundingRect().adjusted(25, 25, -25, -25)); painter->setOpacity(opacity()); painter->setPen(Qt::NoPen); painter->setBrush(QColor(0, 0, 0, 64)); painter->drawRoundRect(rect().translated(2, 2)); if (!proxyWidget) { QLinearGradient gradient(rect().topLeft(), rect().bottomRight()); const QColor col = brush.color(); gradient.setColorAt(0, col); gradient.setColorAt(1, col.dark(int(200 + lastVal * 50))); painter->setBrush(gradient); } else { painter->setBrush(brush); } painter->setPen(QPen(Qt::black, 1)); painter->drawRoundRect(rect()); if (!pix.isNull()) { painter->scale(1.95, 1.95); painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix);; } }
bool CoordinatedGraphicsLayer::hasPendingVisibleChanges() { if (opacity() < 0.01 && !m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity)) return false; for (size_t i = 0; i < children().size(); ++i) { if (toCoordinatedGraphicsLayer(children()[i])->hasPendingVisibleChanges()) return true; } bool shouldSyncCanvas = false; #if USE(GRAPHICS_SURFACE) shouldSyncCanvas = m_pendingCanvasOperation & SyncCanvas; #endif if (!m_shouldSyncLayerState && !m_shouldSyncChildren && !m_shouldSyncFilters && !m_shouldSyncImageBacking && !m_shouldSyncAnimations && !shouldSyncCanvas) return false; return tiledBackingStoreVisibleRect().intersects(tiledBackingStoreContentsRect()); }
bool Surface::drawGL(bool layerTilesDisabled) { bool tilesDisabled = layerTilesDisabled && !isBase(); // SAMSUNG CHANGE ++ : google handwriting 'g' icon display issue, Youtube.com 356x2 height line display issue // This patch should be applied with DEV CL 56175 // WAS:if (singleLayer() && !getFirstLayer()->visible()) if (singleLayer() && (!getFirstLayer()->visible() || getFirstLayer()->drawOpacity() <= 0.0f)) return false; //SAMSUNG CHANGE -- if (!isBase()) { FloatRect drawClip = getFirstLayer()->drawClip(); if (!singleLayer()) { for (unsigned int i = 1; i < m_layers.size(); i++) drawClip.unite(m_layers[i]->drawClip()); } FloatRect clippingRect = TilesManager::instance()->shader()->rectInInvViewCoord(drawClip); TilesManager::instance()->shader()->clip(clippingRect); } bool askRedraw = false; if (m_surfaceBacking && !tilesDisabled) { ALOGV("drawGL on Surf %p with SurfBack %p, first layer %s (%d)", this, m_surfaceBacking, getFirstLayer()->subclassName().ascii().data(), getFirstLayer()->uniqueId()); bool force3dContentVisible = true; IntRect drawArea = visibleContentArea(force3dContentVisible); m_surfaceBacking->drawGL(drawArea, opacity(), drawTransform(), useAggressiveRendering(), background()); } // draw member layers (draws image textures, glextras) for (unsigned int i = 0; i < m_layers.size(); i++) { if (m_layers[i]->drawGL(tilesDisabled)) { m_layers[i]->addDirtyArea(); askRedraw = true; } } return askRedraw; }