Ejemplo n.º 1
0
/*!
 * Обработка нажатий мыши.
 */
void ColorWidget::mouseReleaseEvent(QMouseEvent *event)
{
  if (event->button() == Qt::LeftButton && m_image.valid(event->pos())) {
    if (event->pos().x() <= BlockWidth && event->pos().y() <= BlockHeight)
      emit newColor(m_color);
    else
      emit newColor(QColor(m_image.pixel(event->pos())));
  }

  QWidget::mouseReleaseEvent(event);
}
Ejemplo n.º 2
0
void Font::ParseSpecial(const char * text, uint32& pos, bool active) const
{
	switch (text[pos+1])
	{
		case 'c':
		{
			for (uint8 i = 1; i <= 8; i++)
			{
				char c = text[pos+i+1];
				if (!((c >= '0') && (c <= '9')) && !((c >= 'a') && (c <= 'f')) && !((c >= 'A') && (c <= 'F')))
				{
					pos += i;
					break;
				}
				else if (i == 8)
				{
					if (active == true)
					{
						uint32 colorValues = StringToHex32(text, pos + 2);
						ColorARGB newColor(colorValues);

						glColor(newColor);
					}
					pos += 9;
				}
			}
			break;
		}
		default:
		{
			pos++;
			break;
		}
	}
}
Ejemplo n.º 3
0
Color PngImageExt::GetDitheredColorForPoint(int32 x, int32 y)
{
    int32 count = 0;
    Color newColor(0, 0, 0, 0);
    
    int32 startY = Max(y - 1, 0);
    int32 endY = Min(y + 1, (int32)GetHeight());
    int32 startX = Max(x - 1, 0);
    int32 endX = Min(x + 1, (int32)GetWidth());
    
    for (int32 alphaY = startY; alphaY < endY; ++alphaY)
    {
        for (int32 alphaX = startX; alphaX < endX; ++alphaX)
        {
            int32 offset = (y * GetWidth() + x)*4;
            if(GetData()[offset + 3])
            {
                ++count;
                newColor.r += (float32)(GetData()[offset]);
                newColor.g += (float32)(GetData()[offset + 1]);
                newColor.b += (float32)(GetData()[offset + 2]);
            }
        }
    }
    
    if(count)
    {
        newColor /= (float32)count;
    }
    
    return newColor;
}
Ejemplo n.º 4
0
void MainWindow::changeBackgroundColorSlot(QAction * action)
{
   //TPDP this could be unified by m_BackgroundPicture, "" - default, filename = picture, QColor::isValidColor  - color
    QColor newColor(Qt::white);
    if (action == d->m_BgColorWhiteAction )
        canvasWidget()->changeBackgroundColor(Qt::white);
    else if (action == d->m_BgColorGrayAction)
        canvasWidget()->changeBackgroundColor(Qt::gray);
    else if (action == d->m_BgColorCyanAction)
        canvasWidget()->changeBackgroundColor(newColor = Qt::cyan);
    else if (action == d->m_BgDefaultImage1Action)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_DEFAULT_1);
    else if (action == d->m_BgDefaultImage2Action)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_DEFAULT_2);
    else if (action == d->m_BgImageKanban1Action)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_1);
    else if (action == d->m_BgImageKanban1HAction)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_1H);
    else if (action == d->m_BgImageKanban2Action)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_2);
   else if (action == d->m_BgImageKanban2HAction)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_2H);
    else if (action == d->m_BgImageKanban3Action)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_3);
   else if (action == d->m_BgImageKanban3HAction)
        canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_KANBAN_3H);
    else if (action == d->m_BgImageReview1Action)
         canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_REVIEW_1);
    else if (action == d->m_BgImageReview2Action)
         canvasWidget()->changeBackgroundImage(DragWidget::BG_IMAGE_REVIEW_2);
    else if (action == d->m_BgUserImageAction) {
        canvasWidget()->loadUserBackgroundImage();
   }
}
void ColorEditorImpl::onPickerColorChanged(const QColor &color)
{
    QColor newColor(color);
    newColor.setAlpha(opacitySlider->value());

    updateColorWidgets(newColor, ColorEditorImpl::UpdateFromColorPicker);
    setCurrentColor(newColor);
}
Ejemplo n.º 6
0
///// selectColor /////////////////////////////////////////////////////////////
void ColorButton::selectColor()
/// Allows the selection of a new color.
{  
  QColor tempColor = QColorDialog::getColor(fillColor, this);
  if(tempColor.isValid())
  {
    setColor(tempColor);
    emit newColor(&fillColor);
  }
}
Ejemplo n.º 7
0
void Prefs_UserInterface::changeStoryEditorFontColor()
{
	QColor newColor(QColorDialog::getColor(seFontColor, this));
	if (!newColor.isValid())
		return;
	QPixmap pm(100, 30);
	pm.fill(newColor);
	seFontColor = newColor;
	storyEditorFontColorPushButton->setIcon(pm);
}
Ejemplo n.º 8
0
// Act on a new color
void ColorSelector::imposeColor(bool setSliders, bool emitSignal)
{
  if (setSliders)
    for (int i = 0; i < 3; i++)
      mSliders->setValue(i, mCurrentRGB[i]);

  mGLw->updateGL();
  if (emitSignal)
    emit newColor(mCurrentRGB[0], mCurrentRGB[1], mCurrentRGB[2]);
}
Ejemplo n.º 9
0
void ColorButton::changeButtonColor(void )
{
    const QColor new_color = QColorDialog::getColor(color);
    if (new_color.isValid())
    {
        setButtonColor(new_color);
        color = new_color;
        emit newColor(color);
    }
}
Ejemplo n.º 10
0
void Prefs_Display::changeControlCharsColor()
{
	QColor newColor(QColorDialog::getColor(colorControlChars, this));
	if (newColor.isValid())
	{
		QPixmap pm(100, 30);
		pm.fill(newColor);
		colorControlChars = newColor;
		textControlCharsButton->setIcon(pm);
	}
}
Ejemplo n.º 11
0
void Prefs_Display::changePageBorderColor()
{
	QColor newColor(QColorDialog::getColor(colorPageBorder, this));
	if (newColor.isValid())
	{
		QPixmap pm(100, 30);
		pm.fill(newColor);
		colorPageBorder = newColor;
		selectedPageBorderButton->setIcon(pm);
	}
}
Ejemplo n.º 12
0
void Prefs_Display::changeAnnotFrameColor()
{
	QColor newColor(QColorDialog::getColor(colorFrameAnnotation, this));
	if (newColor.isValid())
	{
		QPixmap pm(100, 30);
		pm.fill(newColor);
		colorFrameAnnotation = newColor;
		frameAnnotationColorButton->setIcon(pm);
	}
}
Ejemplo n.º 13
0
void Prefs_Display::changeChainFrameColor()
{
	QColor newColor(QColorDialog::getColor(colorFrameLinked, this));
	if (newColor.isValid())
	{
		QPixmap pm(100, 30);
		pm.fill(newColor);
		colorFrameLinked = newColor;
		frameLinkedColorButton->setIcon(pm);
	}
}
Ejemplo n.º 14
0
void MarginDialog::changeMarkerColor()
{
	QColor newColor(QColorDialog::getColor(pageFillColor, this));
	if (newColor.isValid())
	{
		QPixmap pm(100, 30);
		pm.fill(newColor);
		pageFillColor = newColor;
		pageFillColorButton->setIcon(pm);
	}
}
Ejemplo n.º 15
0
Bullet* Ship::generateA(int specialA, int dir)
{
	double dx = (specialA-5.)/6;
	double dy = dir;
	double magnitude = 4/std::sqrt(std::abs(dx)*std::abs(dx)+std::abs(dy)*std::abs(dy));

	sf::Color newColor(curColor.r, curColor.g, curColor.b, sf::Int8(180));

	Bullet * mine = new Bullet(x+radius/2, y+radius/2, dx*magnitude,  dy*magnitude, mx, my, alignment, newColor);
	return mine;
}
Ejemplo n.º 16
0
void Configuration::load()
{
    QXmlQuery query;
    if(!query.setFocus(QUrl(filename_)))
        throw std::runtime_error("Invalid configuration file: " + filename_.toStdString());

    QString queryResult;

    // get screen / mullion dimensions
    query.setQuery("string(/configuration/dimensions/@numTilesWidth)");
    if(query.evaluateTo(&queryResult))
        totalScreenCountX_ = queryResult.toInt();

    query.setQuery("string(/configuration/dimensions/@numTilesHeight)");
    if(query.evaluateTo(&queryResult))
        totalScreenCountY_ = queryResult.toInt();

    query.setQuery("string(/configuration/dimensions/@screenWidth)");
    if(query.evaluateTo(&queryResult))
        screenWidth_ = queryResult.toInt();

    query.setQuery("string(/configuration/dimensions/@screenHeight)");
    if(query.evaluateTo(&queryResult))
        screenHeight_ = queryResult.toInt();

    query.setQuery("string(/configuration/dimensions/@mullionWidth)");
    if(query.evaluateTo(&queryResult))
        mullionWidth_ = queryResult.toInt();

    query.setQuery("string(/configuration/dimensions/@mullionHeight)");
    if(query.evaluateTo(&queryResult))
        mullionHeight_ = queryResult.toInt();

    // check for fullscreen mode flag
    query.setQuery("string(/configuration/dimensions/@fullscreen)");
    if(query.evaluateTo(&queryResult))
        fullscreen_ = queryResult.toInt() != 0;

    // Background content URI
    query.setQuery("string(/configuration/background/@uri)");
    if(query.evaluateTo(&queryResult))
        backgroundUri_ = queryResult.remove(QRegExp("[\\n\\t\\r]"));

    // Background color
    query.setQuery("string(/configuration/background/@color)");
    if (query.evaluateTo(&queryResult))
    {
        queryResult.remove(QRegExp("[\\n\\t\\r]"));

        QColor newColor( queryResult );
        if( newColor.isValid( ))
            backgroundColor_ = newColor;
    }
}
Ejemplo n.º 17
0
void SeExprEdColorSwatchWidget::setSwatchColor(int index, QColor color)
{
    if(index >=0 && index < _gridLayout->count()){
        SeVec3d newColor(color.redF(),color.greenF(),color.blueF());
        QLayoutItem *layoutItem = _gridLayout->itemAt(index);
        if (layoutItem && layoutItem->widget()){
            QWidget *widget = layoutItem->widget();
            SeExprEdColorFrame *cFrame = ((SeExprEdColorWidget *)widget)->getColorFrame();
            cFrame->setValue(newColor);
        }
    }
}
Ejemplo n.º 18
0
LRESULT CMainFrame::OnPenColor(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// allow users to choose an arbitrary pen color
	Gdiplus::Color currentColor;
	m_view.m_Pen.GetColor(&currentColor);
	COLORREF color = currentColor.ToCOLORREF();
	CColorDialog test(color);
	test.DoModal();
	color = test.GetColor();
	Gdiplus::Color newColor(GetRValue(color), GetGValue(color), GetBValue(color));
	m_view.m_Pen.SetColor(newColor);
	return 0;
}
Ejemplo n.º 19
0
/*!
 * Установка нового цвета.
 */
void ColorButton::setColor(const QColor &color)
{
  QPainter painter;
  QPixmap pix(":/images/color.png");
  painter.begin(&pix);
  painter.setRenderHint(QPainter::Antialiasing, true);
  painter.setPen(Qt::NoPen);
  painter.setBrush(QBrush(color));
  painter.drawEllipse(QPoint(8, 8), 4, 4);
  painter.end();
  setIcon(pix);
  m_color = color;
  emit newColor(color);
}
Ejemplo n.º 20
0
void NWcolorGradientWidget::changeColor( void )
{
    CFcolorGradient& colorGradient( m_gradientPlug->editableValue<CFcolorGradient>() );

    QColor newColor( QColorDialog::getColor( colorGradient[ m_selectedHandle ].value().asQColor(), this ) );

    if( newColor.isValid() )
    {
        colorGradient.setKeyValue( m_selectedHandle, newColor );

        m_gradientPlug->notifyChange();
        update();
    }
}
Ejemplo n.º 21
0
Bullet* Ship::generateB(int specialB, int dir, EventHandler e)
{
	int * tar = e.getTargetB(alignment);
	double dx = tar[0]+radius/2;
	double dy = tar[1]+radius/2;

	dx = dx-(x+radius/2+(specialB-5.)*10);
	dy = dy-(y+radius/2);
	double magnitude = 4/std::sqrt(std::abs(dx)*std::abs(dx)+std::abs(dy)*std::abs(dy));
	sf::Color newColor(curColor.r, curColor.g, curColor.b, sf::Int8(180));

	Bullet * mine = new Bullet(x+radius/2+(specialB-5.)*10, y+radius/2, dx*magnitude,  dy*magnitude, mx, my, alignment, newColor);
	return mine;
}
Ejemplo n.º 22
0
void AppGUI::Impl::newSSID(std::string SSID)
{
    sf::Color color(newColor());

    networks[SSID] = color;

    sf::plot::Curve& curve = plot.createCurve(SSID, color);
    curve.setFill(false);
    curve.setThickness(2);

    curve.setLimit(3600); // an hour's worth of data
    //should find a way to make this user-defined

    Legend.addSSIDToLegend(SSID, networks[SSID]);
}
Color ParticleColorManager::getNewColor(Particle* particle)
{

	Color newColor(calculateColor(redColorCalculation, particle), calculateColor(greenColorCalculation, particle),
			calculateColor(blueColorCalculation, particle), particle->color.getAlpha());
	if (trasitionRunnedSeconds < trasitionLength)
	{
		Color previousColor(calculateColor(previousRedColorCalculation, particle),
				calculateColor(previousGreenColorCalculation, particle),
				calculateColor(previousBlueColorCalculation, particle), particle->color.getAlpha());
		return Gradient::getColorBetween(previousColor, newColor, trasitionLength, trasitionRunnedSeconds);
	}
	else
		return newColor;

}
Ejemplo n.º 24
0
void ScreenWidget::createImage()
{
    newImage = originalImage.copy();

    // Create CMY components for the ink being used.
    float cyanInk = (255 - paintColor.red())/255.0;
    float magentaInk = (255 - paintColor.green())/255.0;
    float yellowInk = (255 - paintColor.blue())/255.0;

    int (*convert)(QRgb);

    switch (maskColor) {
        case Cyan:
            convert = qRed;
            break;
        case Magenta:
            convert = qGreen;
            break;
        case Yellow:
            convert = qBlue;
            break;
    }

    for (int y = 0; y < newImage.height(); ++y) {
        for (int x = 0; x < newImage.width(); ++x) {
            QRgb p(originalImage.pixel(x, y));

            // Separate the source pixel into its cyan component.
            int amount;

            if (inverted)
                amount = convert(p);
            else
                amount = 255 - convert(p);

            QColor newColor(
                255 - qMin(int(amount * cyanInk), 255),
                255 - qMin(int(amount * magentaInk), 255),
                255 - qMin(int(amount * yellowInk), 255));

            newImage.setPixel(x, y, newColor.rgb());
        }
    }

    imageLabel->setPixmap(QPixmap::fromImage(newImage));
}
Ejemplo n.º 25
0
void FrameBuffer::Convolve33(matrix kernel, FrameBuffer *&fb1) {

	for (int v = 1; v < h-1; v++) {
		for (int u = 1; u < w-1; u++) {
			vector newColor(0.0f, 0.0f, 0.0f);
			for (int vi = -1; vi <= 1; vi++) {
				for (int ui = -1; ui <= 1; ui++) {
					vector currColor;
					currColor.SetFromColor(fb1->Get(u+ui, v+vi));
					newColor = newColor + currColor * kernel[ui+1][vi+1];
				}
			}
			unsigned int newc = newColor.GetColor();
			this->Set(u, v, newc);
		}
	}

}
Ejemplo n.º 26
0
void FrameBuffer::Convolve33(M33 kernel, FrameBuffer *&fb1) {

  fb1 = new FrameBuffer(30 + w, 30, w, h);

  for (int v = 1; v < h-1; v++) {
    for (int u = 1; u < w-1; u++) {
      V3 newColor(0.0f, 0.0f, 0.0f);
      for (int vi = -1; vi <= 1; vi++) {
        for (int ui = -1; ui <= 1; ui++) {
          V3 currColor;
          currColor.setFromColor(Get(u+ui, v+vi));
          newColor = newColor + currColor * kernel[vi+1][ui+1];
        }
      }
      unsigned int newc = newColor.getColor();
      fb1->Set(u, v, newc);
    }
  }
}
Ejemplo n.º 27
0
/*!
 * Конструктор класса ColorButton.
 */
ColorButton::ColorButton(const QColor &color, QWidget *parent)
  : QToolButton(parent),
  m_colorWidget(new ColorWidget(color, this)),
  m_color(color)
{
  setColor(m_color);

  QMenu *menu = new QMenu(this);
  QWidgetAction *action = new QWidgetAction(this);
  action->setDefaultWidget(m_colorWidget);
  menu->addAction(action);

  setMenu(menu);
  setPopupMode(QToolButton::MenuButtonPopup);
  connect(m_colorWidget, SIGNAL(newColor(QColor)), SLOT(setColor(QColor)));
  connect(this, SIGNAL(clicked(bool)), SLOT(newColor()));

  retranslateUi();
}
Ejemplo n.º 28
0
void Viewer::createImage()
{
    QImage newImage = scaledImage.copy();

    QImage *image1 = cyanWidget->image();
    QImage *image2 = magentaWidget->image();
    QImage *image3 = yellowWidget->image();
    int darkness = 255 - brightness;

    for (int y = 0; y < newImage.height(); ++y) {
        for (int x = 0; x < newImage.width(); ++x) {

            // Create three screens, using the quantities of the source
            // CMY components to determine how much of each of the
            // inks are to be put on each screen.
            QRgb p1(image1->pixel(x, y));
            float cyan1 = 255 - qRed(p1);
            float magenta1 = 255 - qGreen(p1);
            float yellow1 = 255 - qBlue(p1);

            QRgb p2(image2->pixel(x, y));
            float cyan2 = 255 - qRed(p2);
            float magenta2 = 255 - qGreen(p2);
            float yellow2 = 255 - qBlue(p2);

            QRgb p3(image3->pixel(x, y));
            float cyan3 = 255 - qRed(p3);
            float magenta3 = 255 - qGreen(p3);
            float yellow3 = 255 - qBlue(p3);

            QColor newColor(
                qMax(255 - int(cyan1+cyan2+cyan3) - darkness, 0),
                qMax(255 - int(magenta1+magenta2+magenta3) - darkness, 0),
                qMax(255 - int(yellow1+yellow2+yellow3) - darkness, 0));

            newImage.setPixel(x, y, newColor.rgb());
        }
    }

    finalWidget->setPixmap(QPixmap::fromImage(newImage));
}
Ejemplo n.º 29
0
int Dither(const unsigned short& data, std::shared_ptr<Palette> palette, unsigned short transparent, int dither, float ditherlevel)
{
    static int ex = 0, ey = 0, ez = 0;
    if (data == transparent) return 0;

    Color color(data);
    Color newColor(CLAMP(color.x + ex), CLAMP(color.y + ey), CLAMP(color.z + ez));
    int index = palette->Search(newColor);
    newColor = palette->At(index);

    if (dither)
    {
        ex += color.x - newColor.x;
        ey += color.y - newColor.y;
        ez += color.z - newColor.z;
        ex *= ditherlevel;
        ey *= ditherlevel;
        ez *= ditherlevel;
    }

    return index;
}
Ejemplo n.º 30
0
ofxGifFrame * ofxGifEncoder::convertTo24BitsWithGreenScreen(ofxGifFrame * frame){
    ofColor otherColor(0,255,0);

    int width = frame->width;
    int height = frame->height;
    
    unsigned char * newPixels = new unsigned char [width * height * 3];
    
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            ofColor c(
                      frame->pixels[(j * width + i) * 4 + 0],
                      frame->pixels[(j * width + i) * 4 + 1],
                      frame->pixels[(j * width + i) * 4 + 2],
                      frame->pixels[(j * width + i) * 4 + 3]
                      );
            
            float normalAlpha = c.a / 255.f;
            float inverseAlpha = 1.f - normalAlpha ;

            ofColor newColor(
                             c.r * normalAlpha + (otherColor.r * inverseAlpha) ,
                             c.g * normalAlpha + (otherColor.g * inverseAlpha),
                             c.b * normalAlpha + (otherColor.b *inverseAlpha)
                             );
            
            newPixels[(j * width + i) * 3 + 0] = newColor.r;
            newPixels[(j * width + i) * 3 + 1] = newColor.g;
            newPixels[(j * width + i) * 3 + 2] = newColor.b;
        }
       
    }

    ofxGifFrame * newFrame = ofxGifEncoder::createGifFrame(newPixels, width, height, 24, frame->duration);
    return newFrame;
}