TYPED_TEST( ColorRGBATest, TestToArray3 ) { const ColorRGBA<TypeParam> c = ColorRGBA<TypeParam>::Red(); const std::vector<TypeParam>& actual = c.toArray3(); const std::vector<TypeParam> expected{ 1.0, 0.0, 0.0 }; EXPECT_EQ( expected, actual ); }
void StageSettings::updateFromStage() { if (stage_ == 0) return; color_button->setColor(stage_->getBackgroundColor()); slider_->setValue((int) Scene::getMouseSensitivity() - 1); wheel_slider_->setValue((int) Scene::getMouseWheelSensitivity() - 1); eye_distance_slider->setValue((int) (stage_->getEyeDistance() * 10.0)); focal_distance_slider->setValue((int) (stage_->getFocalDistance() * 10.0)); fog_slider->setValue((int) (stage_->getFogIntensity())); fog_box->setChecked(stage_->getFogIntensity() > 0); animation_smoothness->setValue((int) (Scene::getAnimationSmoothness() * 10.0)); //TODO: integration of textures //environment_box->setChecked(stage->getTexture()!=""); or pointer to some texture //setTextureUpDirection_(stage->getTextureUpDirection()); ColorRGBA color = ClippingPlane::getCappingColor(); capping_color_button->setColor(color); capping_transparency->setValue(255 - (int)color.getAlpha()); eyeDistanceChanged(); focalDistanceChanged(); getGLSettings(); downsampling_slider->setSliderPosition(scene_->getDownsamplingFactor()*4.); downsamplingSliderChanged(); }
ColorRGBA ColorRGBA::Decomposite(const ColorRGBA& foreground) const { ColorRGBA result = *this; result = (result - foreground * foreground.Alpha()) / (1 - foreground.Alpha()); result.SetAlpha(1.f); return result; }
ColorRGBA ColorRGBA::Composite(const ColorRGBA& foreground) const { ColorRGBA result = *this; result = result * (1 - foreground.Alpha()) + foreground * foreground.Alpha(); result.SetAlpha(1.f); return result; }
Point ColorPicker::foundHSL(void) { _currentPickerColor = ColorRGBA((unsigned char)_rgbs[0]->getValue(), (unsigned char)_rgbs[1]->getValue(), (unsigned char)_rgbs[2]->getValue()); float hls[3]; ColorRGBA colorHLS = _currentPickerColor; colorHLS.toHLS(hls); _saturation = hls[2] * 100.f; _rgbs[3]->setValue(_saturation); return Point((int)(hls[0]*360),(int)(100.f-hls[1]*99.f-1.f)); }
void GLRenderWindow::renderText(float x, float y, float z, const String& text, const ColorRGBA& color, Size size) { // TEST! return; QFont font; font.setPixelSize(size); font.setBold(true); glDisable(GL_LIGHTING); glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); QGLWidget::renderText(x, y, z, text.c_str(), font); glEnable(GL_LIGHTING); }
void GLRenderWindow::renderText(int x, int y, const String& text, const ColorRGBA& color, Size size) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, m_fmt.getWidth(), m_fmt.getHeight()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); QFont font; font.setPixelSize(size); font.setBold(true); glDisable(GL_LIGHTING); glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); QGLWidget::renderText(x, y, text.c_str(), font); glEnable(GL_LIGHTING); }
void Graphics2D::drawImage(Image const& img, Vector2D const (&dstP)[4], ColorRGBA const& color) { GLshort vertexGL[2 * 4]; GLfloat coordGL[2 * 4] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, }; GLubyte indicesGL[4]; GLfloat colorGL[4 * 4]; for(int i = 0; i < 4; i++) { indicesGL[i] = i; for(uint j = 0; j < Vector2D::dimension(); j++) { vertexGL[Vector2D::dimension()*i + j] = dstP[i][j]; } for(uint j = 0; j < color.dimension(); j++) { colorGL[i*color.dimension() + j] = color[j]; } } glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnable(GL_TEXTURE_2D); { glBindTexture( GL_TEXTURE_2D, img.name() ); glVertexPointer( Vector2D::dimension(), GL_SHORT, 0, vertexGL ); glTexCoordPointer( Vector2D::dimension(), GL_FLOAT, 0, coordGL ); glColorPointer( ColorRGBA::dimension(), GL_FLOAT, 0, colorGL); glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, indicesGL); } glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_TEXTURE_2D); }
TYPED_TEST( ColorRGBATest, TestAdd ) { ColorRGBA<TypeParam> c = ColorRGBA<TypeParam>::Red(); c.add( ColorRGBA<TypeParam>::Green() ); EXPECT_EQ( 1.0, c.getRed() ); EXPECT_EQ( 1.0, c.getGreen() ); EXPECT_EQ( 0.0, c.getBlue() ); EXPECT_EQ( 0.0, c.getAlpha() ); }
bool Planet::get_color(ColorRGBA& resulting_color, const Vector2& screen, Math::Ray ray, gfloat& distance)const { if(sphere.radius<=0.f) return false; ray.transform(sphere.inv_transformation); if(!sphere.intersects_local(ray, distance)) return false; Vector3 p = ray.origin + ray.dir*distance; p.normalize(); p *= sphere.radius; Vector3 normal = p; normal *= 1.f/sphere.radius; if(Manager::get_settings().get_dbg_normal()) { resulting_color.set_direction(normal); }else { Vector2 uv; vec_to_uv(uv, normal); if(Manager::get_settings().get_dbg_uv()) { resulting_color.set(uv.x, uv.y, 0.f, 1.f); }else { shader(resulting_color, screen, uv, normal, ray); } } return true; }
ColorL::ColorL(ColorRGBA const & other) : val(0.299f * other.r() + 0.587f * other.g() + 0.114f * other.b()) {}
void StageSettings::apply() { if (stage_ == 0) return; stage_->setBackgroundColor(color_button->getColor()); Scene::setMouseSensitivity(slider_->value() + 1); Scene::setMouseWheelSensitivity(wheel_slider_->value() + 1); stage_->setEyeDistance((float)(eye_distance_slider->value() / 10.0)); stage_->setFocalDistance((float)(focal_distance_slider->value() / 10.)); //TODO integration of textures //if (environement_map->isChecked()) //{ // stage->setTextureUpDirection(getTextureUpDirection_())); // String filenname = ascii(texture_file_edit->text())); // if (filename is valid?) // stage->setTexture(filename)); //} stage_->setSwapSideBySideStereo(swap_sss_button->isChecked()); if (fog_box->isChecked()) { stage_->setFogIntensity(fog_slider->value()); } else { stage_->setFogIntensity(0); } Camera::ProjectionMode projection_mode = radioButton_perspectiveProjection->isChecked() ? Camera::PERSPECTIVE : Camera::ORTHOGRAPHIC; stage_->getCamera().setProjectionMode(projection_mode); Scene::setShowLightSources(show_lights_->isChecked()); Scene::setAnimationSmoothness(((float)animation_smoothness->value()) / 10.0); scene_->setOffScreenRendering(offscreen_group->isChecked(), resolution_factor->value()); ColorRGBA color; color = capping_color_button->getColor(); color.setAlpha(255 - capping_transparency->value()); ClippingPlane::getCappingColor() = color; scene_->setFPSEnabled(show_fps->isChecked()); scene_->setPreview(use_preview->isChecked()); // use vertex buffers ? bool use_buffer = use_vertex_buffers->isChecked() && use_vertex_buffers->isEnabled(); GLRenderer& renderer = scene_->getGLRenderer(); if (use_buffer != renderer.vertexBuffersEnabled() && getMainControl()->getRepresentationManager().getNumberOfRepresentations() > 0) { getMainControl()->setStatusbarText(tr("Because of change in usage of vertex buffer, all Representations have to be deleted!"), true); // remove representations RepresentationManager& pm = getMainControl()->getRepresentationManager(); Size nr = pm.getNumberOfRepresentations(); list<Representation*> reps = pm.getRepresentations(); for (Position p = 0; p < nr; p++) { getMainControl()->remove(**reps.begin()); reps.pop_front(); } } renderer.enableVertexBuffers(use_buffer); renderer.setSmoothLines(smooth_lines_->isChecked()); scene_->setDownsamplingFactor(downsamplingfactor_label->text().toFloat()); if (radioButton_opengl->isChecked()) scene_->switchRenderer(RenderSetup::OPENGL_RENDERER); else scene_->switchRenderer(RenderSetup::RTFACT_RENDERER); }
void ColorHSV::get(ColorRGBA& color) const { color.set(*this); }
// creates a polygon from a given vector RegularData1D * data void RegularData2DWidget::createPlot() { // no data => no polygon if (data_ == 0 || data_->size() == 0) { return; } // set up the ColorMap... TODO: This should be done by a dialog or something similar ColorRGBA colorList[3]; ColorMap color_table_; colorList[0] = ColorRGBA(1.,0.,0.,1.); colorList[1] = ColorRGBA(0.,1.,0.,1.); colorList[2] = ColorRGBA(0.,0.,1.,1.); color_table_.setBaseColors(colorList, 3); color_table_.setNumberOfColors(100); // determine the minimal and maximal values in data_ float min = (*data_)[0]; float max = (*data_)[0]; for (Position i=1; i < (*data_).size(); i++) { if ((*data_)[i] < min) min = (*data_)[i]; else if ((*data_)[i] > max) max = (*data_)[i]; } color_table_.setRange(min, max); color_table_.createMap(); //maximal number of Lines and Columns Size max_x = (*data_).getSize().x; Size max_y = (*data_).getSize().y; // Draw the points QPixmap pixmap; pixmap.resize(max_x, max_y); pixmap.fill(); // delete the old picture QPainter paint; paint.begin(&pixmap); // set the Painter try { QColor pCol; for (Position y=0; y< max_y; y++) { for (Position x=0; x< max_x; x++) { ColorRGBA mapcolor = color_table_.map(data_->getData(x + y * max_x)); pCol = QColor(mapcolor.getRed(), mapcolor.getGreen(), mapcolor.getBlue()); paint.setPen(pCol); paint.drawPoint(x, y); } } } catch(...) { setStatusbarText("Error: Point in dataset out of grid!"); Log.error() << "Error: Point in dataset out of grid!" << std::endl; return; } paint.end(); //put the pixmapItem into objects PixmapItem* pixItem = new PixmapItem(&canvas_, pixmap); pixItem->show(); objects_.push_back(dynamic_cast<Q3CanvasItem*> (pixItem)); // resize the canvas to fit the data canvas_.resize(max_x, max_y); }