void StatusBarMessageLabel::paintEvent(QPaintEvent* /* event */)
{
    QPixmap buffer(size());
    QPainter painter(&buffer);

    // draw background
    QColor backgroundColor(colorGroup().background());
    QColor foregroundColor(KGlobalSettings::textColor());
    if (m_illumination > 0) {
        backgroundColor = mixColors(backgroundColor, QColor(255, 255, 64), m_illumination);
        foregroundColor = mixColors(foregroundColor, QColor(0, 0, 0), m_illumination);
    }
    painter.setBrush(backgroundColor);
    painter.setPen(backgroundColor);
    painter.drawRect(QRect(0, 0, width(), height()));

    // draw pixmap
    int x = pixmapGap();
    int y = (height() - m_pixmap.height()) / 2;

    if (!m_pixmap.isNull()) {
        painter.drawPixmap(x, y, m_pixmap);
        x += m_pixmap.width() + pixmapGap();
    }

    // draw text
    painter.setPen(foregroundColor);
    painter.drawText(QRect(x, 0, width() - x, height()), Qt::AlignVCenter | Qt::WordBreak, m_text);
    painter.end();

    bitBlt(this, 0, 0, &buffer);
}
Esempio n. 2
0
void Client::render(ui::Frame &f) {
  const Clamped &gameFocusFactor = uiState.gameFocusFactor,
      &pageFocusFactor = uiState.pageFocusFactor;

  if (uiState.gameFocused() && game) {
    renderGame(f);
  } else {
    if (!game) {
      f.drawSprite(resources.getTexture(ui::TextureID::MenuBackground),
                   {0, 0}, {0, 0, 1600, 900});
    } else {
      renderGame(f);
      f.drawRect(
          {0, 0, 1600, 900},
          mixColors(style.menu.gameOverlayColor, sf::Color(255, 255, 255, 0), gameFocusFactor));
    }

    f.withAlpha(
        linearTween(1, 0, gameFocusFactor) *
            (game ? linearTween(style.menu.menuInGameFade, 1,
                                pageFocusFactor)
                  : linearTween(style.menu.menuNormalFade, 1, pageFocusFactor)),
        [&]() { renderUI(f); });
  }
}
Esempio n. 3
0
/***********************************************************************
     * Map
     * addIntensity

***********************************************************************/
void Map::addIntensity(sf::Vector2i index, char intensity, sf::Color color) {
	if (index.x < 0 || index.x >= MAP_SIZE_X || index.y < 0 || index.y >= MAP_SIZE_X)
		return;

	color = applyIntensity(color, intensity);
	tiles[index.x][index.y].light = mixColors(tiles[index.x][index.y].light, color);

	if (tiles[index.x][index.y].intensity < intensity)
		tiles[index.x][index.y].intensity = intensity;
}
Esempio n. 4
0
MovingFaces::MovingFaces(RNInfo & info, AnimationInfo animationInfo)
: RNAnimation(info, animationInfo, sizeof (MovingFacesParameters),
&parameters), gradient3Colors(info.numLEDs) {
    pointA = edgePlatform1;
    pointB = edgePlatform2;
    pointC = edgePlatform4; // Top platform
    pointD = edgePlatform3;

    if (parameters.summitColorMode) {
        for (int i = 0; i < info.numLEDs; i++) {
            float xLED = getLEDXPosition(i) + info.x;
            float yLED = getLEDYPosition(i) + info.y;
            float zLED = info.z;
            float dist1 = distancePointFromPoint(xLED, yLED, zLED,
                    edgePlatform1);
            float dist2 = distancePointFromPoint(xLED, yLED, zLED,
                    edgePlatform2);
            float dist3 = distancePointFromPoint(xLED, yLED, zLED,
                    edgePlatform3);
            float totalDist = dist1 + dist2 + dist3;

            float normD1 = dist1 / totalDist;
            float normD2 = dist2 / totalDist;
            float normD3 = dist3 / totalDist;

            float ratio1;
            float ratio2;
            float ratio3;

            if (normD1 != 0 && normD2 != 0 && normD3 != 0) {
                ratio1 = 1 / normD1;
                ratio2 = 1 / normD2;
                ratio3 = 1 / normD3;
            } else {
                ratio1 = normD1 == 0 ? 1 : 0;
                ratio2 = normD2 == 0 ? 1 : 0;
                ratio3 = normD3 == 0 ? 1 : 0;
            }

            float totalRatios = ratio1 + ratio2 + ratio3;
            float normRatio1 = ratio1 / totalRatios;
            float normRatio2 = ratio2 / totalRatios;
            float normRatio3 = ratio3 / totalRatios;

            uint32_t color = mixColors(parameters.summit1Color, normRatio1,
                    parameters.summit2Color, normRatio2,
                    parameters.summit3Color, normRatio3);
            gradient3Colors.setPixelColor(i, color);
        }
    }
};
Esempio n. 5
0
/***********************************************************************
     * Map
     * setIntensity

***********************************************************************/
void Map::setIntensity(MapTile *tile, char intensity, sf::Color color) {
	if (intensity > tile->intensity || canMixColors(tile->light, color)) {
		tile->light = mixColors(tile->light, color);

		if (intensity != tile->intensity) {
			tile->intensity = intensity;

			int index = tile->intensity - 1;

			if (index < 0) return;
			if (index >= LIGHT_MAX_LIGHTLEVEL) return;

			lightTiles[index][lightCounts[index]] = tile;
			lightCounts[index]++;
		}
	}
}
Esempio n. 6
0
void MakeSubImage(u32* dest, u32* from, int fw, int fh, int algo, float scale){
	int x, y;
	int w = fw/scale;
	int h = fh/scale;
	for(y=0; y<h; y++){
		for(x=0; x<w; x++){
			if(algo == 10){
				dest[x+y*w] = mixColors(takePixelAt(from, x, y, w, h, scale), takePixelAt(from, x+1, y+1, w, h, scale));
				dest[x+y*w] = mixColors(dest[x+y*w], takePixelAt(from, x-1, y-1, w, h, scale));
			}
			if(algo == 2){
				dest[x+y*w] = mixColors(takePixelAt(from, x, y, w, h, scale), takePixelAt(from, x+1, y+1, w, h, scale));
				dest[x+y*w] = mixColors(dest[x+y*w], takePixelAt(from, x-1, y-1, w, h, scale));
			}
			if(algo == 1){
				u32 lr = mixColors(takePixelAt(from, x-1.0, y, w, h, scale), takePixelAt(from, x+1.0, y, w, h, scale));
				u32 tb = mixColors(takePixelAt(from, x, y-1.0, w, h, scale), takePixelAt(from, x, y+1.0, w, h, scale));
				u32 tl_br = mixColors(takePixelAt(from, x-1.0, y-1.0, w, h, scale), takePixelAt(from, x+1.0, y+1.0, w, h, scale));
				u32 tr_bl = mixColors(takePixelAt(from, x+1.0, y-1.0, w, h, scale), takePixelAt(from, x-1.0, y+1.0, w, h, scale));
				u32 c1 = mixColors(lr, tb);
				u32 c2 = mixColors(tl_br, tr_bl);
				dest[x+y*w] = mixColors(takePixelAt(from, x, y, w, h, scale), c1);
				dest[x+y*w] = mixColors(dest[x+y*w], c2);
			//	dest[x+y*w] = multColor(dest[x+y*w], 1.0);
			}
		}
	}
}
Esempio n. 7
0
void PixelBufferClass::GetMixedColor(int node, xlColor& c, const std::vector<bool> & validLayers)
{

    unsigned short &sparkle = layers[0]->Nodes[node]->sparkle;
    HSVValue hsv;
    int cnt = 0;
    xlColor color;
    c = xlBLACK;
    for (int layer = numLayers - 1; layer >= 0; layer--)
    {
        if (validLayers[layer])
        {
            int x = layers[layer]->Nodes[node]->Coords[0].bufX;
            int y = layers[layer]->Nodes[node]->Coords[0].bufY;

            if (layers[layer]->isMasked(x, y)) {
                color = xlBLACK;
                color.alpha = 0;
            } else {
                layers[layer]->buffer.GetPixel(x, y, color);
            }

            // add sparkles
            if (layers[layer]->sparkle_count > 0 && color != xlBLACK)
            {
                switch (sparkle % (208 - layers[layer]->sparkle_count))
                {
                case 1:
                case 7:
                    // too dim
                    //color.Set("#444444");
                    break;
                case 2:
                case 6:
                    color.Set(0x88, 0x88, 0x88);
                    break;
                case 3:
                case 5:
                    color.Set(0xbb, 0xbb, 0xbb);
                    break;
                case 4:
                    color.Set(255, 255, 255);
                    break;
                }
                sparkle++;
            }
            if (layers[layer]->brightness != 100 || layers[layer]->contrast != 0)
            {
                hsv = color.asHSV();
                hsv.value = hsv.value * ((double)layers[layer]->brightness/(double)100);

                // Apply Contrast
                if (hsv.value< 0.5)
                {
                    // reduce brightness when below 0.5 in the V value or increase if > 0.5
                    hsv.value = hsv.value - (hsv.value* ((double)layers[layer]->contrast/(double)100));
                }
                else
                {
                    hsv.value = hsv.value + (hsv.value* ((double)layers[layer]->contrast/(double)100));
                }

                if (hsv.value < 0.0) hsv.value=0.0;
                if (hsv.value > 1.0) hsv.value=1.0;
                unsigned char alpha = color.Alpha();
                color = hsv;
                color.alpha = alpha;
            }

            if (MixTypeHandlesAlpha(layers[layer]->mixType))
            {
                c = mixColors(x, y, color, c, layer);
            }
            else
            {
                if (cnt == 0 && layers[layer]->fadeFactor != 1.0)
                {
                    //need to fade the first here as we're not mixing anything
                    color.toHSV(hsv);
                    hsv.value *= layers[layer]->fadeFactor;
                    color = hsv;
                }
                if (cnt > 0)
                {
                    //mix with layer below
                    c = mixColors(x, y, color, c, layer);
                }
                else
                {
                    c = color;
                }
            }

            cnt++;
        }
    }
}