// Make patch face - neighbour cell distances
void Foam::cyclicGgiFvPatch::makeDeltaCoeffs(scalarField& dc) const
{
    if (cyclicGgiPolyPatch_.master())
    {
        // Stabilised form for bad meshes.  HJ, 24/Aug/2011
        vectorField d = delta();

        dc = 1.0/max(nf() & d, 0.05*mag(d));

        if (bridgeOverlap())
        {
            scalarField bridgeDeltas = nf() & fvPatch::delta();

            bridge(bridgeDeltas, dc);
        }
    }
    else
    {
        scalarField masterDeltas(shadow().size());
        shadow().makeDeltaCoeffs(masterDeltas);
        dc = interpolate(masterDeltas);

        if (bridgeOverlap())
        {
            scalarField bridgeDeltas = nf() & fvPatch::delta();

            bridge(bridgeDeltas, dc);
        }
    }
}
示例#2
0
QRect Toplevel::visibleRect() const
{
    QRect r = decorationRect();
    if (hasShadow() && !shadow()->shadowRegion().isEmpty()) {
        r |= shadow()->shadowRegion().boundingRect();
    }
    return r.translated(geometry().topLeft());
}
bool Foam::overlapGgiPolyPatch::master() const
{
    // The first overlapggi interface is master,second one is slave
    if (angle() == shadow().angle())
    {
        return index() < shadowIndex();
    }

    // Master is the one with the larger angle
    return angle() > shadow().angle();
}
示例#4
0
void BoxStyle::unoptimizedPaint(QPainter* painter, int xOffset, int yOffset, int contentBoxWidth,
				int contentBoxHeight) const
{
	qreal x = xOffset;
	qreal y = yOffset;

	int outlineWidth = outline_.style()!=Qt::NoPen ? outline_.width() : 0;
	// Move the figure when using antialiasing. The outline will start at a pixel boundary. This makes it sharper.
	if ( painter->testRenderHint(QPainter::Antialiasing) || painter->testRenderHint(QPainter::HighQualityAntialiasing) )
		if ( outline().style() != Qt::NoPen)
		{
			x = xOffset + outlineWidth/2.0;
			y = yOffset + outlineWidth/2.0;
		}

	// Draw shadow
	if ( shadow() != Qt::NoBrush )
	{
		painter->setPen(Qt::NoPen);
		painter->setBrush(shadow());
		painter->drawPath(getRectanglePath(xOffset + xShadowOffset(), yOffset + yShadowOffset(),
				contentBoxWidth, contentBoxHeight));
	}

	// Draw box.
	painter->setPen(outline());

	// Set the brush and fix the gradient if needed.
	if ( background().style() == Qt::LinearGradientPattern
			&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
	{
		QLinearGradient g = *(static_cast<const QLinearGradient*> (background().gradient()));
		g.setStart(x + g.start().x(), y + g.start().y());
		g.setFinalStop(x + g.finalStop().x(), y + g.finalStop().y());
		painter->setBrush(g);

	}
	else if ( background().style()  == Qt::RadialGradientPattern
			&& background().gradient()->coordinateMode() == QGradient::LogicalMode )
	{
		QRadialGradient g = *(static_cast<const QRadialGradient*> (background().gradient()));
		g.setCenter(x + g.center().x(), y + g.center().y());
		g.setFocalPoint(x + g.focalPoint().x(), y + g.focalPoint().y());
		painter->setBrush(g);
	}
	else
	{
		painter->setBrush(background());
	}

	painter->drawPath(getRectanglePath(x, y, contentBoxWidth - outlineWidth, contentBoxHeight - outlineWidth));
}
示例#5
0
void SVGTRefElement::updateReferencedText()
{
    String textContent;
    if (Element* target = SVGURIReference::targetElementFromIRIString(href(), document()))
        textContent = target->textContent();

    ASSERT(shadow());
    ShadowRoot* root = shadow()->oldestShadowRoot();
    if (!root->firstChild())
        root->appendChild(SVGShadowText::create(document(), textContent), ASSERT_NO_EXCEPTION);
    else
        root->firstChild()->setTextContent(textContent, ASSERT_NO_EXCEPTION);
}
void Foam::overlapGgiPolyPatch::calcLocalParallel() const
{
    // Calculate patch-to-zone addressing
    if (localParallelPtr_)
    {
        FatalErrorIn("void overlapGgiPolyPatch::calcLocalParallel() const")
            << "Local parallel switch already calculated"
            << abort(FatalError);
    }

    // If running in serial, all GGIs are local parallel
    // HJ, 1/Jun/2011
    localParallelPtr_ = new bool(false);
    bool& emptyOrComplete = *localParallelPtr_;

    // If running in serial, all GGIs are expanded to zone size.
    // This happens on decomposition and reconstruction where
    // size and shadow size may be zero, but zone size may not
    // HJ, 1/Jun/2011
    if (!Pstream::parRun())
    {
        emptyOrComplete = false;
    }
    else
    {
        // Calculate localisation on master and shadow
        emptyOrComplete =
            (
                zone().size() == size()
             && shadow().zone().size() == shadow().size()
            )
         || (size() == 0 && shadow().size() == 0);

        reduce(emptyOrComplete, andOp<bool>());
    }

    if (debug && Pstream::parRun())
    {
        Info<< "Overlap GGI patch Master: " << name()
            << " Slave: " << shadowName() << " is ";

        if (emptyOrComplete)
        {
           Info<< "local parallel" << endl;
        }
        else
        {
            Info<< "split between multiple processors" << endl;
        }
    }
}
// Make patch weighting factors
void Foam::regionCoupleFvPatch::makeWeights(scalarField& w) const
{
    if (rcPolyPatch_.coupled())
    {
        if (rcPolyPatch_.master())
        {
            vectorField n = nf();

            // Note: mag in the dot-product.
            // For all valid meshes, the non-orthogonality will be less than
            // 90 deg and the dot-product will be positive.  For invalid
            // meshes (d & s <= 0), this will stabilise the calculation
            // but the result will be poor.  HJ, 24/Aug/2011
            scalarField nfc =
                mag(n & (rcPolyPatch_.reconFaceCellCentres() - Cf()));

            w = nfc/(mag(n & (Cf() - Cn())) + nfc);

            if (bridgeOverlap())
            {
                // Set overlap weights to 0.5 and use mirrored neighbour field
                // for interpolation.  HJ, 21/Jan/2009
                bridge(scalarField(size(), 0.5), w);
            }
        }
        else
        {
            // Pick up weights from the master side
            scalarField masterWeights(shadow().size());
            shadow().makeWeights(masterWeights);

            scalarField oneMinusW = 1 - masterWeights;

            w = interpolate(oneMinusW);

            if (bridgeOverlap())
            {
                // Set overlap weights to 0.5 and use mirrored neighbour field
                // for interpolation.  HJ, 21/Jan/2009
                bridge(scalarField(size(), 0.5), w);
            }
        }
    }
    else
    {
        fvPatch::makeWeights(w);
    }
}
// Return delta (P to N) vectors across coupled patch
Foam::tmp<Foam::vectorField> Foam::cyclicGgiFvPatch::delta() const
{
    if (cyclicGgiPolyPatch_.master())
    {
        tmp<vectorField> tDelta =
            cyclicGgiPolyPatch_.reconFaceCellCentres() - Cn();

        if (bridgeOverlap())
        {
            vectorField bridgeDeltas = Cf() - Cn();

            bridge(bridgeDeltas, tDelta());
        }

        return tDelta;
    }
    else
    {
        tmp<vectorField> tDelta = interpolate
        (
            shadow().Cn() - cyclicGgiPolyPatch_.shadow().reconFaceCellCentres()
        );

        if (bridgeOverlap())
        {
            vectorField bridgeDeltas = Cf() - Cn();

            bridge(bridgeDeltas, tDelta());
        }

        return tDelta;
    }
}
示例#9
0
文件: rshade.c 项目: mattjakob/s3d
Color ray_shade(int level, Real w, Ray v, RContext *rc, Object *ol)
{
  Inode *i = ray_intersect(ol, v);
  if (i != NULL) { Light *l; Real wf;
    Material *m = i->m;
    Vector3 p = ray_point(v, i->t); 
    Cone  recv = cone_make(p, i->n, PIOVER2);
    Color c = c_mult(m->c, c_scale(m->ka, ambient(rc)));
    rc->p = p;

    for (l = rc->l; l != NULL; l = l->next) 
      if ((*l->transport)(l, recv, rc) && (wf = shadow(l, p, ol)) > RAY_WF_MIN)
	c = c_add(c, c_mult(m->c,
		     c_scale(wf * m->kd * v3_dot(l->outdir,i->n), l->outcol)));

    if (level++ < MAX_RAY_LEVEL) {
      if ((wf = w * m->ks) > RAY_WF_MIN) {
	Ray r = ray_make(p, reflect_dir(v.d, i->n));
        c = c_add(c, c_mult(m->s,
		     c_scale(m->ks, ray_shade(level, wf, r, rc, ol))));
      }
      if ((wf = w * m->kt) > RAY_WF_MIN) {
	Ray t = ray_make(p, refract_dir(v.d, i->n, (i->enter)? 1/m->ir: m->ir));
	if (v3_sqrnorm(t.d) > 0) {
	  c = c_add(c, c_mult(m->s,
		       c_scale(m->kt, ray_shade(level, wf, t, rc, ol))));
	}
      }
    }
    inode_free(i); 
    return c;
  } else {
    return BG_COLOR;
  }
}
示例#10
0
void Graphic::drawCell (int y, int x, int val) {

    sf::Color borderColor(101, 123, 131);
    sf::Color bgColor(88, 110, 117);
    sf::Color textColor(238, 232, 213);

    sf::RectangleShape square(sf::Vector2f(100, 100));

    square.setOutlineColor(borderColor);
    square.setOutlineThickness(2);
    square.setFillColor(bgColor);
    square.setPosition(x * 110 + 100 + 10, y * 110 + 10);
    this->_win->draw(square);

    // text
    std::string valStr = std::to_string(val);
    sf::Text    text(valStr, this->_font);
    sf::Text    shadow(valStr, this->_font);
    int         textX = static_cast<int>(x * 110 + 100 + 10 + 50 - text.getLocalBounds().width / 2);
    int         textY = y * 110 + 10 + 30;

    text.setCharacterSize(30);
    shadow.setCharacterSize(30);
    text.setColor(textColor);
    shadow.setColor(sf::Color(7, 54, 66));
    text.setPosition(textX, textY);
    shadow.setPosition(textX, textY + 2);
    this->_win->draw(shadow);
    this->_win->draw(text);
}
示例#11
0
文件: grasp_set.cpp 项目: 2scholz/gpg
Eigen::Matrix3Xd GraspSet::shadowVoxelsToPoints(const std::vector<Eigen::Vector3i>& voxels, double voxel_grid_size) const
{
  // Convert voxels back to points.
  double t0_voxels = omp_get_wtime();
  boost::mt19937 *rng = new boost::mt19937();
  rng->seed(time(NULL));
  boost::normal_distribution<> distribution(0.0, 1.0);
  boost::variate_generator<boost::mt19937, boost::normal_distribution<> > generator(*rng, distribution);

  Eigen::Matrix3Xd shadow(3, voxels.size());

  for (int i = 0; i < voxels.size(); i++)
  {
    shadow.col(i) = voxels[i].cast<double>() * voxel_grid_size + Eigen::Vector3d::Ones() * generator()
        * voxel_grid_size * 0.3;
    //    shadow.col(i) = voxels[i].cast<double>() * voxel_grid_size;
    //    shadow.col(i)(0) += generator() * voxel_grid_size * 0.3;
    //    shadow.col(i)(1) += generator() * voxel_grid_size * 0.3;
    //    shadow.col(i)(2) += generator() * voxel_grid_size * 0.3;
  }
  if (MEASURE_TIME)
    std::cout << "voxels-to-points runtime: " << omp_get_wtime() - t0_voxels << "s\n";

  return shadow;
}
示例#12
0
//////////////////////////////
// Unterprogramm für Fensterdemo
void fenster(uint8_t art) {
    uint8_t x;
    uint8_t y;
    uint8_t color = art;

    winak(original);
    textbackground(WHITE);
    clrscr();

    for (y = 0; y < 4; y++) {
        for (x = 0; x < 4; x++) {
            wiinit(3 + x * 9, 1 + y * 8, 7, 6, demowin);
            textbackground(color);
            clrscr();
            if ((art & 0x01) == 0x01)
            rahm();
            if ((art & 0x02) == 0x02)
            shadow();
            /*
             //priat( 1 , 1, "Fenster 1");
             */
            color += 5;
        }
    }
    while (!kbhit())
    ;
    getch();
}
/* task that renders a single screen tile */
Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera, RayStats& stats)
{
  /* initialize ray */
  Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf);

  /* intersect ray with scene */
  RTCIntersectContext context;
  rtcInitIntersectContext(&context);
  rtcIntersect1(g_scene,&context,RTCRayHit_(ray));
  RayStats_addRay(stats);

  /* shade pixels */
  Vec3fa color = Vec3fa(0.0f);
  if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
  {
    Vec3fa diffuse = colors[ray.geomID];
    color = color + diffuse*0.1f;
    Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));

    /* initialize shadow ray */
    Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf);

    /* trace shadow ray */
    rtcOccluded1(g_scene,&context,RTCRay_(shadow));
    RayStats_addShadowRay(stats);

    /* add light contribution */
    if (shadow.tfar >= 0.0f)
      color = color + diffuse*clamp(-dot(lightDir,normalize(ray.Ng)),0.0f,1.0f);
  }
  return color;
}
示例#14
0
void TileMap::addObjectToMap(GameState &state, sp<Vehicle> vehicle)
{
	if (vehicle->tileObject)
	{
		LogError("Vehicle already has tile object");
	}
	if (vehicle->shadowObject)
	{
		LogError("Vehicle already has shadow object");
	}
	if (vehicle->crashed && vehicle->smokeDoodad)
	{
		LogError("Vehicle already has smoke object");
	}
	// FIXME: mksp<> doesn't work for private (but accessible due to friend)
	// constructors?
	sp<TileObjectVehicle> obj(new TileObjectVehicle(*this, vehicle));
	obj->setPosition(vehicle->getPosition());
	vehicle->tileObject = obj;

	if (vehicle->type->directional_shadow_sprites.size() > 0)
	{
		sp<TileObjectShadow> shadow(new TileObjectShadow(*this, vehicle));
		shadow->setPosition(vehicle->getPosition());
		vehicle->shadowObject = shadow;
	}
	if (vehicle->crashed)
	{
		sp<Doodad> smoke = mksp<Doodad>(vehicle->position + SMOKE_DOODAD_SHIFT,
		                                StateRef<DoodadType>{&state, "DOODAD_13_SMOKE_FUME"});
		addObjectToMap(smoke);
		vehicle->smokeDoodad = smoke;
	}
}
示例#15
0
rgb lighting(scene s, ray r, hit_test h)
{
  rgb result;
  if (h.miss)
    return s.bg;
  vec hit_position = ray_position(r, h.dist);
  if (shadow(hit_position, s.light, s.spheres)) {
    result = rgb_modulate(h.surf, s.amb);
  }
  else {  
    double dot = vec_dot(h.surf_norm, s.light.direction);
    double d = double_max(0, dot);
    rgb diffuse_light = rgb_scale(d, s.light.color);
    rgb lsum = rgb_add(s.amb, diffuse_light);
    result = rgb_modulate(h.surf, lsum);
  }
  /**** === implement specular reflection here === ****/
 
  if (rgb_nonzero(h.shine)) {
    rgb ss;
    vec N = h.surf_norm;
    vec L = s.light.direction;
    rgb S = h.shine;
    vec R = vec_sub( vec_scale(2* vec_dot(N,L),N),L);
    vec V = vec_neg(r.direction);
    if (vec_dot(N,L)>0){
      ss = rgb_scale( pow( double_max( vec_dot(R,V),0), 6), S);
      //rgb_print(k);
    }
    else
      ss = rgb_expr(0,0,0);
    return rgb_add(result,ss);
  }
  return result;
}
void Foam::mixingPlaneFvPatch::makeDeltaCoeffs(scalarField& dc) const
{
    if (mixingPlanePolyPatch_.master())
    {
        // Stabilised form for bad meshes.  HJ, 24/Aug/2011
        vectorField d = delta();

        dc = 1.0/max(nf() & d, 0.05*mag(d));
    }
    else
    {
        scalarField masterDeltas(shadow().size());
        shadow().makeDeltaCoeffs(masterDeltas);
        dc = interpolate(masterDeltas);
    }
}
示例#17
0
void EWASiteDrawer::drawShadowedPixmap(QPainter *p, const QPixmap &pix, int dx, int dy, bool onlyshdw )
{
  QImage msk = pix.toImage();
  QImage shadow(msk.width()+2*fsize, msk.height()+2*fsize, QImage::Format_ARGB32);
  double divisor=0.0;
  for(int i=0;i<2*fsize+1;i++)
    for(int j=0;j<2*fsize+1;j++)
      divisor+=filter[i][j];
  
  for(int y=0;y<shadow.height(); y++)
    for(int x=0;x<shadow.width(); x++){
      int l=0;
      for(int sy=-fsize;sy<=fsize;sy++)
        for(int sx=-fsize;sx<=fsize;sx++){
          int tx = x+sx-fsize;
          int ty = y+sy-fsize;
          if(tx<0 || ty<0 || tx>=msk.width() || ty>=msk.height())
            l+=(int)(filter[sx+fsize][sy+fsize]*255);
          else
            l+=(int)(filter[sx+fsize][sy+fsize]*(255-qAlpha(msk.pixel(tx, ty))));
        }
      l=(int)(l/divisor);
      l = 255 - l;
      l=qBound(0, l, 225);

      shadow.setPixel(x, y,qRgba(0, 0, 0, l));
    }
  
  p->drawImage(dx, dy, shadow);
  if(!onlyshdw)  p->drawPixmap(dx, dy, pix);
}
示例#18
0
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);

    LRESULT lr = CDRF_DODEFAULT;

    if (m_fSelfDrawn)
        switch (pNMCD->dwDrawStage) {
            case CDDS_PREPAINT:
                lr = CDRF_NOTIFYITEMDRAW;
                break;

            case CDDS_ITEMPREPAINT:
                if (pNMCD->dwItemSpec == TBCD_CHANNEL) {
                    CDC dc;
                    dc.Attach(pNMCD->hdc);

                    CRect r;
                    GetClientRect(r);
                    r.DeflateRect(8, 4, 10, 6);
                    CopyRect(&pNMCD->rc, &r);
                    CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
                    CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
                    CPen* old = dc.SelectObject(&light);
                    dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
                    dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
                    dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
                    dc.SelectObject(&shadow);
                    dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
                    dc.SelectObject(old);

                    dc.Detach();
                    lr = CDRF_SKIPDEFAULT;
                } else if (pNMCD->dwItemSpec == TBCD_THUMB) {
                    CDC dc;
                    dc.Attach(pNMCD->hdc);
                    pNMCD->rc.bottom--;
                    CRect r(pNMCD->rc);
                    r.DeflateRect(0, 0, 1, 0);

                    COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
                    COLORREF light = GetSysColor(COLOR_3DHILIGHT);
                    dc.Draw3dRect(&r, light, 0);
                    r.DeflateRect(0, 0, 1, 1);
                    dc.Draw3dRect(&r, light, shadow);
                    r.DeflateRect(1, 1, 1, 1);
                    dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
                    dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE));

                    dc.Detach();
                    lr = CDRF_SKIPDEFAULT;
                }

                break;
        };

    pNMCD->uItemState &= ~CDIS_FOCUS;

    *pResult = lr;
}
示例#19
0
sh_init( object user )
{
    me = user;
    shadow( me, 1 );
    string *names = ({ "Wild", "Doc", "Loner", "Loco",
     "Lucky", "Bandit", "Bullet", "Rawhide", "Gravedigger",
     "Pecos" });
bool Foam::overlapGgiPolyPatch::active() const
{
    polyPatchID shadow(shadowName_, boundaryMesh());
    faceZoneID zone(zoneName_, boundaryMesh().mesh().faceZones());

    return shadow.active() && zone.active();
}
示例#21
0
文件: shotgun.c 项目: smokeless/eotl
void sh_init()
{
    shadow( THISP, 1 );  
    call_out( "blood", 3);
    call_out( "stumble", 5 );
    call_out( "dest_shad", 60 );
}
示例#22
0
bool SkipList::remove(int key) 
{
	Node* knot = shadow();
	for (int i = m_level - 1; i >= 0; i--) {
		while (knot->next[i] != NULL && knot->next[i]->key < key) {
			knot = knot->next[i];
		}
		m_knots[i] = knot;
	}
	Node* target = knot->next[0];
	if (target == NULL || target->key != key) return false;

	int lv = std::min(target->size, m_level);
	for (int i = 0; i < lv; i++) {
		m_knots[i]->next[i] = target->next[i];
	}
	delete target;

	if (m_cnt-- == m_floor) {
		m_ceil = m_floor;
		m_floor /= FACTOR;
		m_level--;
	}
	return true;
}
示例#23
0
void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
    const FloatRect& src, ColorSpace, CompositeOperator op, BlendMode blendMode)
{
    if (m_pixmap->isNull())
        return;

    FloatRect normalizedSrc = src.normalized();
    FloatRect normalizedDst = dst.normalized();

    CompositeOperator previousOperator = ctxt->compositeOperation();
    BlendMode previousBlendMode = ctxt->blendModeOperation();
    ctxt->setCompositeOperation(op, blendMode);

    if (ctxt->hasShadow()) {
        ShadowBlur shadow(ctxt->state());
        GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
        if (shadowContext) {
            QPainter* shadowPainter = shadowContext->platformContext();
            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
            shadow.endShadowLayer(ctxt);
        }
    }

    ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
    ctxt->setCompositeOperation(previousOperator, previousBlendMode);
}
示例#24
0
文件: textbutton.cpp 项目: BGmot/Qt
    QImage *createRoundButtonBackground(const QMatrix &matrix) const
    {
        QRect scaledRect;
        scaledRect = matrix.mapRect(QRect(0, 0, this->logicalSize.width(), this->logicalSize.height()));

        QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
        image->fill(QColor(0, 0, 0, 0).rgba());
        QPainter painter(image);
        painter.setRenderHint(QPainter::SmoothPixmapTransform);
        painter.setRenderHint(QPainter::Antialiasing);
        painter.setPen(Qt::NoPen);

        if (Colors::useEightBitPalette){
            painter.setPen(QColor(120, 120, 120));
            if (this->pressed)
                painter.setBrush(QColor(60, 60, 60));
            else if (this->highlighted)
                painter.setBrush(QColor(100, 100, 100));
            else
                painter.setBrush(QColor(80, 80, 80));
        }
        else {
            QLinearGradient outlinebrush(0, 0, 0, scaledRect.height());
            QLinearGradient brush(0, 0, 0, scaledRect.height());

            brush.setSpread(QLinearGradient::PadSpread);
            QColor highlight(255, 255, 255, 70);
            QColor shadow(0, 0, 0, 70);
            QColor sunken(220, 220, 220, 30);
            QColor normal1(255, 255, 245, 60);
            QColor normal2(255, 255, 235, 10);

            if (this->type == TextButton::PANEL){
                normal1 = QColor(200, 170, 160, 50);
                normal2 = QColor(50, 10, 0, 50);
            }

           if (pressed) {
               outlinebrush.setColorAt(0.0f, shadow);
               outlinebrush.setColorAt(1.0f, highlight);
               brush.setColorAt(0.0f, sunken);
               painter.setPen(Qt::NoPen);
           } else {
               outlinebrush.setColorAt(1.0f, shadow);
               outlinebrush.setColorAt(0.0f, highlight);
               brush.setColorAt(0.0f, normal1);
               if (!this->highlighted)
                   brush.setColorAt(1.0f, normal2);
               painter.setPen(QPen(outlinebrush, 1));
           }
           painter.setBrush(brush);
        }

        if (this->type == TextButton::PANEL)
            painter.drawRect(0, 0, scaledRect.width(), scaledRect.height());
        else
            painter.drawRoundedRect(0, 0, scaledRect.width(), scaledRect.height(), 10, 90, Qt::RelativeSize);
        return image;
    }
示例#25
0
文件: draw.c 项目: qstemper/42
void				draw_line(t_env *e, int x, int start, int end)
{
	int				i;
	unsigned int	color;

	color = get_color(e);
	color = shadow(color, e->ray.dist);
	i = -1;
	while (++i < start + e->player.z)
		put_pixel(e, x, i, e->col_sky);
	i--;
	while (++i <= end + e->player.z && i < e->height)
		put_pixel(e, x, i, color);
	i--;
	while (++i < e->height)
		put_pixel(e, x, i, shadow(e->col_ground, abs(i - e->height) * 0.040));
}
Foam::tmp<Foam::labelField> Foam::mixingPlaneFvPatch::internalFieldTransfer
(
    const Pstream::commsTypes,
    const unallocLabelList& iF
) const
{
    return shadow().labelTransferBuffer();
}
Foam::tmp<Foam::labelField> Foam::regionCoupleFvPatch::internalFieldTransfer
(
    const Pstream::commsTypes commsType,
    const unallocLabelList& iF
) const
{
    return shadow().labelTransferBuffer();
}
Foam::tmp<Foam::labelField> Foam::overlapGgiFvPatch::internalFieldTransfer
(
    const Pstream::commsTypes,
    const unallocLabelList& iF
) const
{
    return shadow().patchInternalField(iF);
}
示例#29
0
void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
{
    FS_STATE* iType = font->platformData().scaledFont(context->getCTM().yScale());
    if (!iType)
        return;

    FloatPoint adjustedPoint = point;

    if (font->platformData().orientation() == Vertical)
        adjustedPoint.move(-(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()), 0);

    bool softwareBlurRequired = context->state().shadowBlur / font->fontMetrics().xHeight() > 0.5;

    FloatSize currentShadowOffset;
    float currentShadowBlur;
    Color currentShadowColor;
    ColorSpace currentColorSpace;

    // If we have a shadow blur, and it is too big to apply at text-render time, we must render it now.
    if (context->hasShadow() && softwareBlurRequired) {
        context->getShadow(currentShadowOffset, currentShadowBlur, currentShadowColor, currentColorSpace);

        const GraphicsContextState state = context->state();
        FloatSize offset = state.shadowOffset;
        if (state.shadowsIgnoreTransforms)
            offset.setHeight(-offset.height());
        ShadowBlur shadow(FloatSize(state.shadowBlur, state.shadowBlur), offset, state.shadowColor, state.shadowColorSpace);
        FloatPoint minPoint(adjustedPoint.x(), adjustedPoint.y() - fontMetrics().ascent());
        FloatPoint maxPoint(adjustedPoint.x(), adjustedPoint.y() + fontMetrics().descent());
        FloatPoint currentPoint = adjustedPoint;
        for (int i = 0; i < numGlyphs; ++i) {
            currentPoint += *glyphBuffer.advances(from + i);
            minPoint.setX(std::min(minPoint.x(), currentPoint.x()));
            minPoint.setY(std::min(minPoint.y(), currentPoint.y()));
            maxPoint = maxPoint.expandedTo(currentPoint);
        }
        const FloatRect boundingRect(minPoint.x(), minPoint.y(), maxPoint.x() - minPoint.x(), maxPoint.y() - minPoint.y());
        GraphicsContext* shadowContext = shadow.beginShadowLayer(context, boundingRect);
        if (shadowContext) {
            iType = font->platformData().scaledFont(shadowContext->getCTM().yScale());
            shadowContext->platformContext()->addGlyphs(glyphBuffer.glyphs(from),
                    reinterpret_cast<const BlackBerry::Platform::FloatSize*>(glyphBuffer.advances(from)),
                    numGlyphs, adjustedPoint, iType, 0, 0);
            iType = font->platformData().scaledFont(context->getCTM().yScale());
            shadow.endShadowLayer(context);
        }
        context->platformContext()->clearShadow();
    }

    context->platformContext()->addGlyphs(glyphBuffer.glyphs(from),
                                          reinterpret_cast<const BlackBerry::Platform::FloatSize*>(glyphBuffer.advances(from)),
                                          numGlyphs, adjustedPoint, iType,
                                          context->fillGradient() ? context->fillGradient()->platformGradient() : (context->fillPattern() ? context->fillPattern()->platformPattern(AffineTransform()) : static_cast<BlackBerry::Platform::Graphics::Paint*>(0)),
                                          context->strokeGradient() ? context->strokeGradient()->platformGradient() : (context->strokePattern() ? context->strokePattern()->platformPattern(AffineTransform()) : static_cast<BlackBerry::Platform::Graphics::Paint*>(0)));

    if (softwareBlurRequired)
        context->platformContext()->setShadow(currentShadowOffset, currentShadowBlur, currentShadowColor.isValid() ? currentShadowColor.rgb() : makeRGBA(0, 0, 0, 0xFF / 3), context->state().shadowsIgnoreTransforms);
}
/* task that renders a single screen tile */
Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera, RayStats& stats)
{
  RTCIntersectContext context;
  rtcInitIntersectContext(&context);
  
  /* initialize ray */
  Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf);

  /* intersect ray with scene */
  rtcIntersect1(g_scene,&context,RTCRayHit_(ray));
  RayStats_addRay(stats);

  /* shade pixels */
  Vec3fa color = Vec3fa(0.0f);
  if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
  {
    /* interpolate diffuse color */
    Vec3fa diffuse = Vec3fa(1.0f,0.0f,0.0f);
    if (ray.geomID > 0)
    {
      unsigned int geomID = ray.geomID; {
        rtcInterpolate0(rtcGetGeometry(g_scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,0,&diffuse.x,3);
      }
      //return diffuse;
      diffuse = 0.5f*diffuse;
    }

    /* calculate smooth shading normal */
    Vec3fa Ng = ray.Ng;
    if (ray.geomID == 2 || ray.geomID == 3) {
      Vec3fa dPdu,dPdv;
      unsigned int geomID = ray.geomID; {
        rtcInterpolate1(rtcGetGeometry(g_scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX,0,nullptr,&dPdu.x,&dPdv.x,3);
      }
      //return dPdu;
      Ng = cross(dPdu,dPdv);
    }
    Ng = normalize(Ng);
    color = color + diffuse*0.5f;
    Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));

    /* initialize shadow ray */
    Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf);

    /* trace shadow ray */
    rtcOccluded1(g_scene,&context,RTCRay_(shadow));
    RayStats_addShadowRay(stats);

    /* add light contribution */
    if (shadow.tfar >= 0.0f) {
      Vec3fa r = normalize(reflect(ray.dir,Ng));
      float s = pow(clamp(dot(r,lightDir),0.0f,1.0f),10.0f);
      float d = clamp(-dot(lightDir,Ng),0.0f,1.0f);
      color = color + diffuse*d + 0.5f*Vec3fa(s);
    }
  }
  return color;
}