Пример #1
0
void ColorModelView::paintEvent(QPaintEvent *)
{
    QPainter p(this);

    auto mainBounds = mainAreaBounds();
    auto sideBounds = sideAreaBounds();

    if (mainImage_.isNull()) {
        // FIXME: support other color model?
        QImage img(256, 256, QImage::Format_RGB32);
        auto *pixels = reinterpret_cast<quint32 *>(img.bits());
        auto basecolor = QColor::fromHsv(value_.hsvHue(), 255, 255);
        auto basecolorMM = _mm_setr_epi32(basecolor.blue(), basecolor.green(), basecolor.red(), 0);
        basecolorMM = _mm_add_epi32(basecolorMM, _mm_srli_epi32(basecolorMM, 7)); // map [0, 255] to [0, 256]
        auto white = _mm_set1_epi32(256 * 255);
        auto dX = _mm_sub_epi32(basecolorMM, _mm_set1_epi32(256));
        for (int y = 0; y < 256; ++y) {
            auto brightness = _mm_set1_epi32(256 - y - (y >> 7));
            auto col = white; // [0, 256 * 255]
            for (int x = 0; x < 256; ++x) {
                auto c = _mm_mullo_epi16(_mm_srli_epi32(col, 8), brightness);
                c = _mm_srli_epi16(c, 8); // [0, 255]
                c = _mm_packs_epi32(c, c);
                c = _mm_packus_epi16(c, c);

                _mm_store_ss(reinterpret_cast<float *>(&pixels[x + y * 256]),
                        _mm_castsi128_ps(c));

                col = _mm_add_epi32(col, dX);
            }
        }
        mainImage_ = QPixmap::fromImage(img);
    }
Пример #2
0
imageCapture::imageCapture(Mat image, int& counter, int amountOfColors, int AmountOfProjectedPointsPerColor, int totalProjectedColumns, vector<vector<Point>>& twoDPointSpace) {
	colorObject redLower("redLower"), redUpper("redUpper"), green("green"), blue("blue"), white("white");

	// get blue points
	cvtColor(image, HSV, COLOR_BGR2HSV);
	inRange(HSV, blue.getHSVmin(), blue.getHSVmax(), threshold);
	morphOps(threshold);
	trackFilteredObject(blue, threshold, image, counter, twoDPointSpace);

	// get red points
	cvtColor(image, HSV, COLOR_BGR2HSV);
	inRange(HSV, redLower.getHSVmin(), redLower.getHSVmax(), lowerRedImage);
	inRange(HSV, redUpper.getHSVmin(), redUpper.getHSVmax(), upperRedImage);
	addWeighted(lowerRedImage, 1.0, upperRedImage, 1.0, 0.0, threshold);
	morphOps(threshold);
	trackFilteredObject(redUpper, threshold, image, counter, twoDPointSpace);

	//get green points
	cvtColor(image, HSV, COLOR_BGR2HSV);
	inRange(HSV, green.getHSVmin(), green.getHSVmax(), threshold);
	morphOps(threshold);
	trackFilteredObject(green, threshold, image, counter, twoDPointSpace);

	//get white points
	cvtColor(image, HSV, COLOR_BGR2HSV);
	inRange(HSV, white.getHSVmin(), white.getHSVmax(), threshold);
	morphOps(threshold);
	trackFilteredObject(white, threshold, image, counter, twoDPointSpace);

	counter++;
}
void RouteMapOverlay::RenderAlternateRoute(IsoRoute *r, bool each_parent,
                                           wrDC &dc, PlugIn_ViewPort &vp)
{
    Position *pos = r->skippoints->point;
    wxColor black = wxColour(0, 0, 0, 192), tblack = TransparentColor(black);
    do {
        wxColour *color = pos->data_mask & Position::DATA_DEFICIENT_WIND ? &tblack : &black;
        for(Position *p = pos; p && !p->drawn && p->parent; p = p->parent) {
//            wxColour &color = p->data_mask & Position::DATA_DEFICIENT_WIND ? tblack : black;
            wxColour &pcolor = p->parent->data_mask & Position::DATA_DEFICIENT_WIND ? tblack : black;
            if(!p->copied || each_parent)
                DrawLine(p, *color, p->parent, pcolor, dc, vp);
            p->drawn = true;
            if(!each_parent)
                break;
            color = &pcolor;
        }

        pos = pos->next;
    } while(pos != r->skippoints->point);

    wxColour blue(0, 0, 255);
    SetColor(dc, blue);
    for(IsoRouteList::iterator cit = r->children.begin(); cit != r->children.end(); cit++)
        RenderAlternateRoute(*cit, each_parent, dc, vp);
}
Пример #4
0
TankItem::TankItem(QObject *parent) :
	QGraphicsRectItem(),
	dataModel(0),
	pInfoEntry(0),
	pInfoNr(0)
{
	height = 3;
	QColor red(PERSIANRED1);
	QColor blue(AIR_BLUE);
	QColor yellow(NITROX_YELLOW);
	QColor green(NITROX_GREEN);
	QLinearGradient nitroxGradient(QPointF(0, 0), QPointF(0, height));
	nitroxGradient.setColorAt(0.0, green);
	nitroxGradient.setColorAt(0.49, green);
	nitroxGradient.setColorAt(0.5, yellow);
	nitroxGradient.setColorAt(1.0, yellow);
	nitrox = nitroxGradient;
	oxygen = green;
	QLinearGradient trimixGradient(QPointF(0, 0), QPointF(0, height));
	trimixGradient.setColorAt(0.0, green);
	trimixGradient.setColorAt(0.49, green);
	trimixGradient.setColorAt(0.5, red);
	trimixGradient.setColorAt(1.0, red);
	trimix = trimixGradient;
	air = blue;
	memset(&diveCylinderStore, 0, sizeof(diveCylinderStore));
}
Пример #5
0
void Color::getRGBA(double& r, double& g, double& b, double& a) const
{
    r = red() / 255.0;
    g = green() / 255.0;
    b = blue() / 255.0;
    a = alpha() / 255.0;
}
Пример #6
0
int main(void)
{
    canvas C;
    rgb blue(0, 0, 255);
    rgb green;
    green.GREEN();
    rgb violet;
    violet.MAGENTA();
    rgb yellow;
    yellow.YELLOW();
    rgb rouge;
    rouge.RED();

    C.fb_init();
    C.fb_reset();

    C.fb_putchar('A');
    C.background.apply(234,123,43);
    C.Px=40; 
    C.fb_putchar('B');
    C.background.red(0);
    C.fb_putchar('C');
    C.Py=50;
    C.fb_putchar('D');
    C.fb_printf("X - Y - Z"); 
    C.Py=60;
    C.background.RED(); 
    C.fb_printf("HELLO WORLD"); 
    C.Py=70;
    C.Px=40; 
    C.fb_printf("1234567890-+"); 
    C.fb_rectangle(100,200,200,300,1,blue);
    C.fb_close();
    return 0;
}
Пример #7
0
//----------------------------------------------------------------------------
void RoughPlaneThinRod2::OnDisplay ()
{
    ClearScreen();

    ColorRGB black(0, 0, 0);
    ColorRGB gray(128, 128, 128);
    ColorRGB blue(0, 0, 255);

    // Draw the rod.
    double x1, y1, x2, y2;
    mModule.Get(x1, y1, x2, y2);
    int iX1 = (int)(x1 + 0.5);
    int iY1 = (int)(y1 + 0.5);
    int iX2 = (int)(x2 + 0.5);
    int iY2 = (int)(y2 + 0.5);
    DrawLine(iX1, iY1, iX2, iY2, gray);

    // Draw the masses.
    SetThickPixel(iX1, iY1, 2, black);
    SetThickPixel(iX2, iY2, 2, black);

    // Draw the center of mass.
    int x = (int)(mModule.GetX() + 0.5);
    int y = (int)(mModule.GetY() + 0.5);
    SetThickPixel(x, y, 2, blue);

    WindowApplication2::OnDisplay();
}
/**
 * \brief Combine image, mask and center into a color image
 */
ImagePtr	VCurveFocusWork::combine(ImagePtr image, FWHMInfo& fwhminfo) {
	// first build the red channel from the mask
	Image<unsigned char>	*red
		= dynamic_cast<Image<unsigned char> *>(&*fwhminfo.mask);
	if (NULL == red) {
		throw std::logic_error("internal error, mask has not 8bit pixel type");
	}

	// then build the green channel from the original image
	Image<unsigned char>	*green = FocusWork::green(image);
	ImagePtr	greenptr(green);

	// create the blue image
	CrosshairAdapter<unsigned char>	crosshair(image->size(), fwhminfo.maxpoint, 20);
	CircleAdapter<unsigned char>	circle(image->size(), fwhminfo.center,
						fwhminfo.radius);
	MaxAdapter<unsigned char>	blue(crosshair, circle);

	// now use a combination adapter to put all these images together
	// into a single color image
	CombinationAdapter<unsigned char>	combinator(*red, *green, blue);
	Image<RGB<unsigned char> >	*result
		= new Image<RGB<unsigned char> >(combinator);

	return ImagePtr(result);
}
Пример #9
0
bool TriangleGame::loadContent()
{
	vertexShader.reset(device->createVertexShader("TriangleShader.fx", "VS_Main", "vs_4_0"));

	vector<InputElementDescriptor> inputElements;
	inputElements.push_back(InputElementDescriptor("POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, true, 0));
	inputElements.push_back(InputElementDescriptor("COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, true, 0));
	inputLayout.reset(device->createInputLayout(inputElements, vertexShader.get()));

	pixelShader.reset(device->createPixelShader("TriangleShader.fx", "PS_Main", "ps_4_0"));

	float minX = -0.5f;
	float maxX = 0.5f;
	float minY = -1.0f;
	float maxY = 1.0f;
	XMFLOAT4 red(1.0f, 0.0f, 0.0f, 1.0f);
	XMFLOAT4 green(0.0f, 1.0f, 0.0f, 1.0f);
	XMFLOAT4 blue(0.0f, 0.0f, 1.0f, 1.0f);
	XMFLOAT4 yellow(1.0f, 1.0f, 0.0f, 1.0f);
	XMFLOAT4 cyan(0.0f, 1.0f, 1.0f, 1.0f);
	XMFLOAT4 magenta(1.0f, 0.0f, 1.0f, 1.0f);
	XMFLOAT4 white(1.0f, 1.0f, 1.0f, 1.0f);

	vector<Vertex> vertices;
	vertices.push_back(Vertex(XMFLOAT3(minX, maxY, 0.5f), red));
	vertices.push_back(Vertex(XMFLOAT3(maxX, maxY, 0.5f), green));
	vertices.push_back(Vertex(XMFLOAT3(minX, 0.0f, 0.5f), blue));
	vertices.push_back(Vertex(XMFLOAT3(maxX, 0.0f, 0.5f), yellow));
	vertices.push_back(Vertex(XMFLOAT3(minX, minY, 0.5f), cyan));
	vertices.push_back(Vertex(XMFLOAT3(maxX, minY, 0.5f), magenta));
	vertexBuffer.reset(device->createVertexBuffer(vertices.size() * sizeof(Vertex), &vertices[0]));

	return true;
}
Пример #10
0
void MainWindow::on_buttonLoad_clicked()
{
    QString file = QFileDialog::getOpenFileName(this,"Choose Image...",QString(),"Images (*.png *.jpg *.tiff *.bmp)");

    if(!file.isNull())
    {
        if(this->image)
            delete this->image;

        this->image = new QImage(file);

        this->ui->labelFile->setText(file);
        this->ui->checkBoxBlue->setChecked(true);
        this->ui->checkBoxRed->setChecked(true);
        this->ui->checkBoxGreen->setChecked(true);

        if(this->data)
            this->data->deleteLater();

        this->data = new RGBHistogramData(this->image,this);
        this->ui->histogramView->setData(this->data);

        this->data->calculate(this->ui->comboBoxNoB->currentText().toUInt());

        QColor red(Qt::red),green(Qt::green),blue(Qt::blue);

        red.setAlpha(200);
        blue.setAlpha(200);
        green.setAlpha(200);

        this->ui->histogramView->setKeyPlotStyle(RGBHistogramData::RED,red);
        this->ui->histogramView->setKeyPlotStyle(RGBHistogramData::GREEN,green);
        this->ui->histogramView->setKeyPlotStyle(RGBHistogramData::BLUE,blue);
    }
}
Пример #11
0
//------------------------------------------------------------------------------
// serialize() -- print the value of this object to the output stream sout.
//------------------------------------------------------------------------------
std::ostream& Rgb::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{
    int j = 0;
    if ( !slotsOnly ) {
        sout << "( " << getFactoryName() << std::endl;
        j = 4;
    }

    BaseClass::serialize(sout,i+j,true);

    indent(sout,i+j);
    sout << "red:   " << red() << std::endl;

    indent(sout,i+j);
    sout << "green: " << green() << std::endl;

    indent(sout,i+j);
    sout << "blue:  " << blue() << std::endl;

    if ( !slotsOnly ) {
        indent(sout,i);
        sout << ")" << std::endl;
    }

    return sout;
}
Пример #12
0
void Color::getRGBA(float& r, float& g, float& b, float& a) const
{
    r = red() / 255.0f;
    g = green() / 255.0f;
    b = blue() / 255.0f;
    a = alpha() / 255.0f;
}
Пример #13
0
std::vector<gmtl::Point3f> cPoints(std::vector<gmtl::Point3f> verts, char col)
{
	std::vector<gmtl::Point3f> color;
	//std::cout << vertices.size() << std::endl;;
	for (unsigned int i = 0; i < verts.size(); i++)
	{
		gmtl::Point3f red(1, 0, 0);
		gmtl::Point3f blue(0, 0, 1);
		gmtl::Point3f green(0, 1, 0);
		gmtl::Point3f white(1, 1, 1);
		gmtl::Point3f grey(0.5f, 0.5f, 0.5f);
		gmtl::Point3f old(verts.at(i));
		switch (col)
		{
		case 'w':
			color.push_back(white);
			break;
		case 'o':
			color.push_back(old);
			break;
		case 'g':
			color.push_back(grey);
			break;
		case 'h':
			if (i < verts.size() / 2)
				color.push_back(blue);
			else
				color.push_back(green);
			break;
		}


	}
	return color;
}
Пример #14
0
void Color::getHSL(double& hue, double& saturation, double& lightness) const
{
    // http://en.wikipedia.org/wiki/HSL_color_space. This is a direct copy of
    // the algorithm therein, although it's 360^o based and we end up wanting
    // [0...1) based. It's clearer if we stick to 360^o until the end.
    double r = static_cast<double>(red()) / 255.0;
    double g = static_cast<double>(green()) / 255.0;
    double b = static_cast<double>(blue()) / 255.0;
    double max = std::max(std::max(r, g), b);
    double min = std::min(std::min(r, g), b);

    if (max == min)
        hue = 0.0;
    else if (max == r)
        hue = (60.0 * ((g - b) / (max - min))) + 360.0;
    else if (max == g)
        hue = (60.0 * ((b - r) / (max - min))) + 120.0;
    else
        hue = (60.0 * ((r - g) / (max - min))) + 240.0;

    if (hue >= 360.0)
        hue -= 360.0;

    // makeRGBAFromHSLA assumes that hue is in [0...1).
    hue /= 360.0;

    lightness = 0.5 * (max + min);
    if (max == min)
        saturation = 0.0;
    else if (lightness <= 0.5)
        saturation = ((max - min) / (max + min));
    else
        saturation = ((max - min) / (2.0 - (max + min)));
}
Пример #15
0
String Color::serializedAsCSSComponentValue() const
{
    StringBuilder result;
    result.reserveCapacity(32);
    bool colorHasAlpha = hasAlpha();
    if (colorHasAlpha)
        result.appendLiteral("rgba(");
    else
        result.appendLiteral("rgb(");

    result.appendNumber(static_cast<unsigned char>(red()));
    result.appendLiteral(", ");

    result.appendNumber(static_cast<unsigned char>(green()));
    result.appendLiteral(", ");

    result.appendNumber(static_cast<unsigned char>(blue()));
    if (colorHasAlpha) {
        result.appendLiteral(", ");

        NumberToStringBuffer buffer;
        const char* alphaString = numberToFixedPrecisionString(alpha() / 255.0f, 6, buffer, true);
        result.append(alphaString, strlen(alphaString));
    }

    result.append(')');
    return result.toString();
}
Пример #16
0
// =============================================================================
// Desenha as caixas de seleção ao redor dos widgets
// =============================================================================
void DesignerSurface::drawSelectionBoxes(QPainter& painter)
{
    QColor blue(0, 0, 255, 200);
    QPen pen(Qt::red, 1, Qt::DotLine);
    painter.setPen(blue);

    foreach (QWidget* widget, m_widgetSelection) {
        if (widget == m_lowerWidget)
            continue;

        if (m_mouseState == Moving) {
            painter.setPen(pen);
            painter.drawRect(mapToDesigner(widget));
        } else if (m_mouseState == Reparenting) {
            painter.setPen(QColor(255, 0, 200));
            painter.drawRect(mapToDesigner(widget).adjusted(m_selectionAdjust.x(),
                                                            m_selectionAdjust.y(),
                                                            m_selectionAdjust.width(),
                                                            m_selectionAdjust.height()));
        } else {
            painter.drawRect(mapToDesigner(widget).adjusted(m_selectionAdjust.x(),
                                                            m_selectionAdjust.y(),
                                                            m_selectionAdjust.width(),
                                                            m_selectionAdjust.height()));
            painter.fillRect(getSizerRect(widget), Qt::darkGreen);
            painter.drawRect(getSizerRect(widget));
        }

    }
}
void TrimmedSphereShape::draw() const
{
	const GLenum drawingFace = getDrawingFace() == swl::attrib::POLYGON_FACE_FRONT ? GL_FRONT :
		(getDrawingFace() == swl::attrib::POLYGON_FACE_BACK ? GL_BACK :
		(getDrawingFace() == swl::attrib::POLYGON_FACE_FRONT_AND_BACK ? GL_FRONT_AND_BACK :
		(getDrawingFace() == swl::attrib::POLYGON_FACE_NONE ? GL_NONE : GL_FRONT)));
	const GLenum polygonMode = getPolygonMode() == swl::attrib::POLYGON_FILL ? GL_FILL :
		(getPolygonMode() == swl::attrib::POLYGON_LINE ? GL_LINE :
		(getPolygonMode() == swl::attrib::POLYGON_POINT ? GL_POINT : GL_FILL));

	// save states
	GLint oldPolygonMode[2];
	glGetIntegerv(GL_POLYGON_MODE, oldPolygonMode);
	glPolygonMode(drawingFace, polygonMode);
	//glPolygonMode(GL_FRONT, polygonMode);  // not working !!!

	glPushMatrix();
		//glLoadIdentity();
		glTranslatef(-250.0f, 250.0f, -250.0f);

		const double clippingPlane0[] = { 1.0, 0.0, 0.0, 100.0 };
		const double clippingPlane1[] = { -1.0, 0.0, 0.0, 300.0 };

		// draw clipping areas
		drawClippingRegion(GL_CLIP_PLANE0, clippingPlane0);
		drawClippingRegion(GL_CLIP_PLANE1, clippingPlane1);

		// enables clipping planes
		glEnable(GL_CLIP_PLANE0);
		glClipPlane(GL_CLIP_PLANE0, clippingPlane0);
		glEnable(GL_CLIP_PLANE1);
		glClipPlane(GL_CLIP_PLANE1, clippingPlane1);

		const GLuint id = reinterpret_cast<GLuint>(this);
		glPushName(id);
			// draw a sphere
			if (swl::ObjectPickerMgr::getInstance().isPicking() && swl::ObjectPickerMgr::getInstance().isTemporarilyPickedObject(id))
			{
				const swl::ObjectPickerMgr::color_type &pickedColor = swl::ObjectPickerMgr::getInstance().getTemporarilyPickedColor();
				glColor4f(pickedColor.r, pickedColor.g, pickedColor.b, pickedColor.a);
			}
			else if (swl::ObjectPickerMgr::getInstance().isPickedObject(id))
			{
				const swl::ObjectPickerMgr::color_type &pickedColor = swl::ObjectPickerMgr::getInstance().getPickedColor();
				glColor4f(pickedColor.r, pickedColor.g, pickedColor.b, pickedColor.a);
			}
			else glColor4f(red(), green(), blue(), alpha());
			GL_LINE == polygonMode ? glutWireSphere(500.0, 20, 20) : glutSolidSphere(500.0, 20, 20);
		glPopName();

		// disables clipping planes
		glDisable(GL_CLIP_PLANE0);
		glDisable(GL_CLIP_PLANE1);
	glPopMatrix();

	// restore states
	//glPolygonMode(oldPolygonMode[0], oldPolygonMode[1]);  // not working. don't know why.
	glPolygonMode(drawingFace, oldPolygonMode[1]);
}
Пример #18
0
int exits_prompt( char* tmp, char_data* ch )
{
  exit_data*  exit;
  char*     string  = tmp;
  bool       water  = FALSE;
  int        exits  = 0;

  if( !ch->Can_See( ) ) {
    strcpy( tmp, "??" );
    return 2;
    }

  if( !ch->in_room->Seen( ch ) ) {
    strcpy( tmp, "-Dark-" );
    return 6;
    }

  for( int i = 0; i < ch->in_room->exits; i++ ) {
    exit = ch->in_room->exits[i];

    if( !exit->Seen( ch ) )
      continue;

    if( !is_set( &exit->exit_info, EX_CLOSED ) 
      && water_logged( exit->to_room ) ) {
      if( !water ) {
        strcpy( string, blue( ch ) );
        string += strlen( string );
        water = TRUE;
        }
      }
    else {
      if( water ) {
        strcpy( string, normal( ch ) );
        string += strlen( string );
        water = FALSE;
        }
      }

    *string = *dir_table[ exit->direction ].name;

    if( !is_set( &exit->exit_info, EX_CLOSED ) )
      *string = toupper( *string );

    exits++;
    string++;
    } 

  if( water ) 
    strcpy( string, normal( ch ) );
  else if( string == tmp ) {
    strcpy( tmp, "none" );
    return 4;
    }
  else 
    *string = '\0';

  return exits;
}  
Пример #19
0
// To keep the console open on shutdown, start the project with Ctrl+F5 instead of just F5.
int main(int argc, char** argv)
{
	// freeGlut and Window initialization ***********************

	// Pass any applicable command line arguments to GLUT. These arguments
	// are platform dependent.
	glutInit(&argc, argv);

	// Set the initial display mode.
	glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);

	// Set the initial window size
	glutInitWindowSize(winWidth, winHeight);

	// Create a window using a string and make it the current window.
	GLuint world_Window = glutCreateWindow("Viewing Transformations");

	// Indicate to GLUT that the flow of control should return to the program after
	// the window is closed and the GLUTmain loop is exited.
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	// Callback for window redisplay
	glutDisplayFunc(RenderSceneCB);
	glutReshapeFunc(ResizeCB);
	glutKeyboardFunc(KeyboardCB);
	glutSpecialFunc(SpecialKeysCB);
	glutIdleFunc(animate);

	// Create polygon submenu
	int menu1id = glutCreateMenu(viewMenu);
	// Specify menu items and integer identifiers
	glutAddMenuEntry("View 1", 1);
	glutAddMenuEntry("View 2", 2);
	glutAddMenuEntry("View 3", 3);
	glutAddMenuEntry("View 4", 4);
	glutAddMenuEntry("View 5", 5);
	glutAddMenuEntry("View 6", 6);
	glutAddMenuEntry("Quit", 0);

	// Attach menu to right mouse button
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// Request that the window be made full screen
	//glutFullScreenToggle();

	color blue(0.498f, 1.000f, 0.831f, 1.0f);

	// Set red, green, blue, and alpha to which the color buffer is cleared.
	colorBuffer.setClearColor(blue);
	
	// Set the initial viewing tranformation for the scene
	viewingTransformation = glm::translate( glm::vec3(0.0f, 0.0f, -12.0) );

	// Enter the GLUT main loop. Control will not return until the window is closed.
	glutMainLoop();

	return 0;

} // end main
Пример #20
0
 std::string color::to_string() const
 {
     std::stringstream ss;
     if (alpha() == 255) {
         ss << "rgb("
         << red()   << ","
         << green() << ","
         << blue()  << ")";
     } else {
         ss << "rgba("
         << red()   << ","
         << green() << ","
         << blue()  << ","
         << alpha()/255.0 << ")";
     }
     return ss.str();
 }
Пример #21
0
pixel24& PixelData_24_Bit::operator =(const pixel24 &rhs)
{
	blue(rhs.blue());
	green(rhs.green());
	red(rhs.red());

	return *this;
}
Пример #22
0
void PDFSelection::paint ( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
    QBrush blue(qApp->palette().highlight());
    painter->setPen(QPen(blue, 2));
    painter->setBrush(blue);
    painter->setOpacity(0.5);
    painter->drawRect(0, 0, geometry().width(), geometry().height());
}
Пример #23
0
Drawing::color Opacity::color_at(posn point) const
{
    auto base_color = Drawing_decorator::color_at(point);
    return color{base_color.red(),
                 base_color.green(),
                 base_color.blue(),
                 opacity_ * base_color.alpha()};
}
void KoRgbColorSpaceTester::testCompositeOps()
{
    // Just COMPOSITE_COPY for now

    QList<KoID> depthIDs = KoColorSpaceRegistry::instance()->colorDepthList(RGBAColorModelID.id(),
                           KoColorSpaceRegistry::AllColorSpaces);

    foreach(KoID depthId, depthIDs) {
        kDebug() << depthId.id();
        const KoColorSpace* cs = KoColorSpaceRegistry::instance()->colorSpace(
                                     RGBAColorModelID.id(), depthId.id(), "");

        const KoCompositeOp* copyOp = cs->compositeOp(COMPOSITE_COPY);
        KoColor src(cs), dst(cs);

        QColor red(255, 0, 0);
        QColor blue(0, 0, 255);
        QColor transparentRed(255, 0, 0, 0);

        // Copying a color over another color should replace the original color
        src.fromQColor(red);
        dst.fromQColor(blue);

        qDebug() << src.toQColor() << dst.toQColor();

        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) != 0);

        copyOp->composite(dst.data(), cs->pixelSize(), src.data(), cs->pixelSize(),
                          0, 0, 1, 1, OPACITY_OPAQUE_U8);

        src.fromQColor(red);
        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) == 0);

        // Copying something transparent over something non-transparent should, of course, make the dst transparent
        src.fromQColor(transparentRed);
        dst.fromQColor(blue);

        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) != 0);

        copyOp->composite(dst.data(), cs->pixelSize(), src.data(), cs->pixelSize(),
                          0, 0, 1, 1, OPACITY_OPAQUE_U8);

        src.fromQColor(transparentRed);
        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) == 0);

        // Copying something solid over something transparent
        src.fromQColor(blue);
        dst.fromQColor(transparentRed);

        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) != 0);

        copyOp->composite(dst.data(), cs->pixelSize(), src.data(), cs->pixelSize(),
                          0, 0, 1, 1, OPACITY_OPAQUE_U8);

        src.fromQColor(blue);
        QVERIFY(memcmp(dst.data(), src.data(), cs->pixelSize()) == 0);

    }
void CASW_VGUI_Computer_Menu::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	SetPaintBackgroundType(0);
	SetPaintBackgroundEnabled(false);
	SetBgColor( Color(0,0,0,0) );
	SetMouseInputEnabled(true);

	vgui::HFont LabelFont = pScheme->GetFont( "Default", IsProportional() );
	// hide the menu at first
	Color white(255,255,255,255);
	Color blue(19,20,40, 255);
	for (int i=0;i<ASW_COMPUTER_MAX_MENU_ITEMS;i++)
	{
		//if (!m_bSetAlpha)
		//{
			m_pMenuLabel[i]->SetAlpha(0);
			m_pMenuIcon[i]->SetAlpha(0);
			m_pMenuIconShadow[i]->SetAlpha(0);
		//}
		m_pMenuLabel[i]->SetFont(LabelFont);
		m_pMenuLabel[i]->SetPaintBackgroundEnabled(true);
		m_pMenuLabel[i]->SetContentAlignment(vgui::Label::a_center);
		m_pMenuLabel[i]->SetBgColor(Color(19,20,40,255));
		m_pMenuLabel[i]->SetColors(white, white, white, white, blue);
		m_pMenuLabel[i]->SetBorders("TitleButtonBorder", "TitleButtonBorder");
		m_pMenuLabel[i]->SetPaintBackgroundType(2);
	}
	

	vgui::HFont DefaultFont = pScheme->GetFont( "Default", IsProportional() );
	vgui::HFont XLargeFont = pScheme->GetFont( "DefaultExtraLarge", IsProportional() );

	m_pAccessDeniedLabel->SetFont(XLargeFont);
	m_pAccessDeniedLabel->SetFgColor(Color(255,0,0,255));	
	m_pInsufficientRightsLabel->SetFont(DefaultFont);	
	m_pInsufficientRightsLabel->SetFgColor(Color(255,255,255,255));		

	//if (!m_bSetAlpha)
	//{
		m_pBlackBar[0]->SetAlpha(0);
		m_pBlackBar[1]->SetAlpha(0);
		m_pAccessDeniedLabel->SetAlpha(0);
		m_pInsufficientRightsLabel->SetAlpha(0);		
	//}
	if (!m_bSetAlpha)
	{
		m_bSetAlpha = true;
	}
	else
	{
		if (m_hCurrentPage.Get())
			HideMenu(true);
		else
			ShowMenu();	// makes sure the right things are faded in
	}
}
Пример #26
0
void GameOfLife::control_Stroop ( int **nextLattice )
{
  if ( ++age <20 )
    {
      red ( nextLattice, 2, 5, 1 );
    }
  else if ( age <40 )
    {
      green ( nextLattice, 2, 5, 1 );
    }
  else if ( age <60 )
    {
      blue ( nextLattice, 2, 5, 1 );
    }
  else if ( age <80 )
    {
      red ( nextLattice, 2, 5, 2 );
    }
  else if ( age <100 )
    {
      green ( nextLattice, 2, 5, 2 );
    }
  else if ( age <120 )
    {
      blue ( nextLattice, 2, 5, 2 );
    }
  else if ( age <140 )
    {
      red ( nextLattice, 2, 5, 3 );
    }
  else if ( age <160 )
    {
      green ( nextLattice, 2, 5, 3 );
    }
  else if ( age <180 )
    {
      blue ( nextLattice, 2, 5, 3 );
    }
  else
    {
      age =0;
      red ( nextLattice, 2, 5, 2 );
    }

}
//----------------------------------------------------------------------------
void RoughPlaneParticle1::OnDisplay ()
{
    ClearScreen();

    ColorRGB black(0, 0, 0);
    ColorRGB gray(128, 128, 128);
    ColorRGB blue(0, 0, 128);
    ColorRGB lightBlue(0, 0, 255);
    int x0, w0, x1, w1, i;
    Vector2d position;

    const double xScale = 1.25;
    const double wScale = 0.75;
    const int wOffset = 96;

    // Draw viscous friction path of motion.
    const int numVFPositions = (int)mVFPositions.size();
    position = mVFPositions[0];
    x0 = (int)(xScale*position.X() + 0.5);
    w0 = (int)(wScale*position.Y() + 0.5) + wOffset;
    x1 = x0;
    w1 = w0;
    for (i = 1; i < numVFPositions; ++i)
    {
        position = mVFPositions[i];
        x1 = (int)(xScale*position.X() + 0.5);
        w1 = (int)(wScale*position.Y() + 0.5) + wOffset;
        DrawLine(x0, w0, x1, w1, lightBlue);
        x0 = x1;
        w0 = w1;
    }

    // Draw the mass.
    SetThickPixel(x1, w1, 2, blue);

    // Draw static friction path of motion.
    const int numSFPositions = (int)mSFPositions.size();
    position = mSFPositions[0];
    x0 = (int)(xScale*position.X() + 0.5);
    w0 = (int)(wScale*position.Y() + 0.5) + wOffset;
    x1 = x0;
    w1 = w0;
    for (i = 1; i < numSFPositions; ++i)
    {
        position = mSFPositions[i];
        x1 = (int)(xScale*position.X() + 0.5);
        w1 = (int)(wScale*position.Y() + 0.5) + wOffset;
        DrawLine(x0, w0, x1, w1, gray);
        x0 = x1;
        w0 = w1;
    }

    // Draw the mass.
    SetThickPixel(x1, w1, 2, black);

    WindowApplication2::OnDisplay();
}
Пример #28
0
//----------------------------------------------------------------------------
void PointInPolyhedron::CreateScene ()
{
    mScene = new0 Node();
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    // Create a semitransparent sphere mesh.
    VertexFormat* vformatMesh = VertexFormat::Create(1,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0);
    TriMesh* mesh = StandardMesh(vformatMesh).Sphere(16, 16, 1.0f);
    Material* material = new0 Material();
    material->Diffuse = Float4(1.0f, 0.0f, 0.0f, 0.25f);
    VisualEffectInstance* instance = MaterialEffect::CreateUniqueInstance(
        material);
    instance->GetEffect()->GetAlphaState(0, 0)->BlendEnabled = true;
    mesh->SetEffectInstance(instance);

    // Create the data structures for the polyhedron that represents the
    // sphere mesh.
    CreateQuery(mesh);

    // Create a set of random points.  Points inside the polyhedron are
    // colored white.  Points outside the polyhedron are colored blue.
    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);
    int vstride = vformat->GetStride();

    VertexBuffer* vbuffer = new0 VertexBuffer(1024, vstride);
    VertexBufferAccessor vba(vformat, vbuffer);
    Float3 white(1.0f, 1.0f, 1.0f);
    Float3 blue(0.0f, 0.0f, 1.0f);
    for (int i = 0; i < vba.GetNumVertices(); ++i)
    {
        Vector3f random(Mathf::SymmetricRandom(),
            Mathf::SymmetricRandom(), Mathf::SymmetricRandom());

        vba.Position<Vector3f>(i) = random;

        if (mQuery->Contains(random))
        {
            vba.Color<Float3>(0, i) = white;
        }
        else
        {
            vba.Color<Float3>(0, i) = blue;
        }
    }

    DeleteQuery();

    mPoints = new0 Polypoint(vformat, vbuffer);
    mPoints->SetEffectInstance(VertexColor3Effect::CreateUniqueInstance());

    mScene->AttachChild(mPoints);
    mScene->AttachChild(mesh);
}
Пример #29
0
std::string color::to_hex_string() const
{
    if (alpha_ == 255 )
    {
        return (boost::format("#%1$02x%2$02x%3$02x")
                % red()
                % green()
                % blue() ).str();
    }
    else
    {
        return (boost::format("#%1$02x%2$02x%3$02x%4$02x")
                % red()
                % green()
                % blue()
                % alpha()).str();
    }
}
Пример #30
0
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();
}