void ColorScanAction::testColor(Comm::SensorType type, int sensorId, int state) { if (type == Comm::ColorSensor) { if (sensorId == _leftSensorId) checkColor(_leftArmState, state, _leftOpponentColorAction, _leftOurColorAction); if (sensorId == _rightSensorId) checkColor(_rightArmState, state, _rightOpponentColorAction, _rightOurColorAction); } }
void qlua_toColor(lua_State *L, int idx, vec4_t color, qboolean strict) { int i=0; for(i=0;i<4;i++) { color[i] = luaL_optnumber(L,i+idx,0); } checkColor(color,strict); }
void adjustColor(vec4_t color, float amt) { color[0] = (color[0] + amt); color[1] = (color[1] + amt); color[2] = (color[2] + amt); color[3] = color[3]; checkColor(color,qtrue); }
void insert(int key) { Node* n = add(key); repair(n); // dump(_root); cout << endl; check(_root); checkColor(_root); }
void GBufferedImage::fillRegion(double x, double y, double width, double height, int rgb) { checkIndex("fillRegion", x, y); checkIndex("fillRegion", x + width - 1, y + height - 1); checkColor("fillRegion", rgb); for (int r = (int) y; r < y + height; r++) { for (int c = (int) x; c < x + width; c++) { m_pixels[r][c] = rgb; } } pp->gbufferedimage_fillRegion(this, x, y, width, height, rgb); }
void frameBuffer::floodFill(int x, int y){ if (checkColor(x,y)){} //if (checkColor(x,y)){} else { // printf("%d\n", x); // printf("%d\n", y); if (( x > 0 && y > 0 && x < vinfo.xres - 60 && y < vinfo.yres - 60 )) { blockBuilder(x,y,1,0,0,0); } floodFill(x+1,y); floodFill(x-1,y); floodFill(x,y+1); floodFill(x,y-1); } }
QScriptValue ImageBuilder::fill(const QString &colorName) { QColor color; QScriptValue err = checkColor(context(), colorName, color); if (err.isError()) return err; TPixel32 pix(color.red(), color.green(), color.blue(), color.alpha()); if (m_img) { if (m_img->getType() != TImage::RASTER) context()->throwError("Can't fill a non-'Raster' image"); TRaster32P ras = m_img->raster(); if (ras) ras->fill(pix); } else if (m_width > 0 && m_height > 0) { TRaster32P ras(m_width, m_height); ras->fill(pix); m_img = TRasterImageP(ras); } return context()->thisObject(); }
void GBufferedImage::init(double x, double y, double width, double height, int rgb) { checkSize("constructor", width, height); checkColor("constructor", rgb); this->x = x; this->y = y; this->m_width = width; this->m_height = height; this->m_pixels.resize((int) this->m_height, (int) this->m_width); pp->gbufferedimage_constructor(this, x, y, width, height, rgb); if (x != 0 || y != 0) { setLocation(x, y); } this->m_backgroundColor = rgb; if (rgb != 0) { fill(rgb); } }
bool KalmanDetectionFilter::checkObservation(const samplereturn_msgs::NamedPoint& msg) { double dist = current_filter_->distance(msg); bool color_check = checkColor(current_filter_->huemodel, msg.model.hue); bool dist_check = dist < config_.max_dist; if (dist_check && color_check) { ROS_DEBUG("Adding measurement to filter"); current_filter_->predict(); current_filter_->measure(msg, config_.PDgO, config_.PDgo); current_filter_->huemodel = samplereturn::HueHistogram(msg.model.hue); return true; } else if (dist_check && !color_check) { ROS_DEBUG("Color Check Failed"); } else { ROS_DEBUG("Distance check failed"); } return false; }
static bool readConfig(const char *file, Options *opts, Options *def) #endif { #ifdef __cplusplus if(file.isEmpty()) { const char *xdg=xdgConfigFolder(); if(xdg) { QString filename(xdg); filename+="/"QTC_FILE; return readConfig(filename, opts, def); } } #else if(!file) { const char *xdg=xdgConfigFolder(); if(xdg) { char filename[QTC_MAX_FILENAME_LEN]; sprintf(filename, "%s/"QTC_FILE, xdg); return readConfig(filename, opts, def); } } #endif else { #ifdef __cplusplus QtCConfig cfg(file); if(cfg.ok()) { #else GHashTable *cfg=loadConfig(file); if(cfg) { #endif QTC_CFG_READ_ROUND(round) QTC_CFG_READ_DI(highlightFactor) QTC_CFG_READ_TB_BORDER(toolbarBorders) QTC_CFG_READ_APPEARANCE(appearance, def->appearance) QTC_CFG_READ_BOOL(fixParentlessDialogs) QTC_CFG_READ_BOOL(stripedProgress) QTC_CFG_READ_BOOL(animatedProgress) QTC_CFG_READ_BOOL(lighterPopupMenuBgnd) QTC_CFG_READ_BOOL(embolden) QTC_CFG_READ_DEF_BTN(defBtnIndicator) QTC_CFG_READ_LINE(sliderThumbs) QTC_CFG_READ_LINE(handles) QTC_CFG_READ_BOOL(highlightTab) QTC_CFG_READ_SHADE(shadeSliders, false) QTC_CFG_READ_SHADE(shadeMenubars, true) QTC_CFG_READ_SHADE(shadeCheckRadio, false) QTC_CFG_READ_APPEARANCE(menubarAppearance, def->menubarAppearance) QTC_CFG_READ_APPEARANCE(menuitemAppearance, opts->appearance) QTC_CFG_READ_APPEARANCE(toolbarAppearance, def->toolbarAppearance) QTC_CFG_READ_LINE(toolbarSeparators) QTC_CFG_READ_LINE(splitters) QTC_CFG_READ_BOOL(customMenuTextColor) QTC_CFG_READ_MOUSE_OVER(coloredMouseOver) QTC_CFG_READ_BOOL(menubarMouseOver) QTC_CFG_READ_BOOL(shadeMenubarOnlyWhenActive) QTC_CFG_READ_BOOL(thinnerMenuItems) QTC_CFG_READ_COLOR(customSlidersColor) QTC_CFG_READ_COLOR(customMenubarsColor) QTC_CFG_READ_COLOR(customMenuSelTextColor) QTC_CFG_READ_COLOR(customMenuNormTextColor) QTC_CFG_READ_COLOR(customCheckRadioColor) QTC_CFG_READ_SCROLLBAR(scrollbarType) QTC_CFG_READ_BOOL(shadowButtons) QTC_CFG_READ_APPEARANCE(lvAppearance, opts->appearance) QTC_CFG_READ_APPEARANCE(tabAppearance, opts->appearance) QTC_CFG_READ_APPEARANCE(sliderAppearance, opts->appearance) QTC_CFG_READ_APPEARANCE(progressAppearance, opts->appearance) #ifndef QTC_PLAIN_FOCUS_ONLY QTC_CFG_READ_BOOL(stdFocus) #endif QTC_CFG_READ_BOOL(lvLines) QTC_CFG_READ_BOOL(drawStatusBarFrames) QTC_CFG_READ_BOOL(fillSlider) QTC_CFG_READ_BOOL(roundMbTopOnly) QTC_CFG_READ_BOOL(borderMenuitems) QTC_CFG_READ_BOOL(gradientPbGroove) QTC_CFG_READ_BOOL(darkerBorders) QTC_CFG_READ_BOOL(vArrows) QTC_CFG_READ_BOOL(colorMenubarMouseOver) #ifdef __cplusplus QTC_CFG_READ_BOOL(stdSidebarButtons) QTC_CFG_READ_BOOL(gtkScrollViews); QTC_CFG_READ_BOOL(gtkComboMenus); #endif #ifndef QTC_COMMON_ONLY_COVERTERS QTC_CFG_READ_SHADING(shading, SHADING_HSL); #endif #ifndef __cplusplus releaseConfig(cfg); #endif if(SHADE_SELECTED==opts->shadeCheckRadio) opts->shadeCheckRadio=SHADE_BLEND_SELECTED; checkColor(&opts->shadeMenubars, &opts->customMenubarsColor); checkColor(&opts->shadeSliders, &opts->customSlidersColor); checkColor(&opts->shadeCheckRadio, &opts->customCheckRadioColor); if(APPEARANCE_BEVELLED==opts->toolbarAppearance) opts->toolbarAppearance=APPEARANCE_GRADIENT; else if(APPEARANCE_RAISED==opts->toolbarAppearance) opts->toolbarAppearance=APPEARANCE_FLAT; if(APPEARANCE_BEVELLED==opts->menubarAppearance) opts->menubarAppearance=APPEARANCE_GRADIENT; else if(APPEARANCE_RAISED==opts->menubarAppearance) opts->menubarAppearance=APPEARANCE_FLAT; if(APPEARANCE_BEVELLED==opts->sliderAppearance) opts->sliderAppearance=APPEARANCE_GRADIENT; if(APPEARANCE_BEVELLED==opts->tabAppearance) opts->tabAppearance=APPEARANCE_GRADIENT; if(opts->highlightFactor<((100.0+MIN_HIGHLIGHT_FACTOR)/100.0) || opts->highlightFactor>((100.0+MAX_HIGHLIGHT_FACTOR)/100.0)) opts->highlightFactor=DEFAULT_HIGHLIGHT_FACTOR; if(opts->animatedProgress && !opts->stripedProgress) opts->animatedProgress=false; if(SHADE_CUSTOM==opts->shadeMenubars || SHADE_BLEND_SELECTED==opts->shadeMenubars || !opts->borderMenuitems) opts->colorMenubarMouseOver=true; return true; } } return false; } static bool fileExists(const char *path) { struct stat info; return 0==lstat(path, &info) && (info.st_mode&S_IFMT)==S_IFREG; } static const char * getSystemConfigFile() { static const char * constFiles[]={ "/etc/qt4/"QTC_FILE, "/etc/qt3/"QTC_FILE, "/etc/qt/"QTC_FILE, NULL }; int i; for(i=0; constFiles[i]; ++i) if(fileExists(constFiles[i])) return constFiles[i]; return NULL; } static void defaultSettings(Options *opts) { /* Set hard-coded defaults... */ opts->contrast=7; opts->highlightFactor=DEFAULT_HIGHLIGHT_FACTOR; opts->round=ROUND_FULL; opts->lighterPopupMenuBgnd=true; opts->animatedProgress=true; opts->stripedProgress=true; opts->highlightTab=true; opts->embolden=false; opts->appearance=APPEARANCE_DULL_GLASS; opts->lvAppearance=APPEARANCE_BEVELLED; opts->tabAppearance=APPEARANCE_GRADIENT; opts->sliderAppearance=APPEARANCE_DULL_GLASS; opts->menubarAppearance=APPEARANCE_GRADIENT; opts->menuitemAppearance=APPEARANCE_DULL_GLASS; opts->toolbarAppearance=APPEARANCE_GRADIENT; opts->progressAppearance=APPEARANCE_DULL_GLASS; opts->defBtnIndicator=IND_COLORED; opts->sliderThumbs=LINE_DOTS; opts->handles=LINE_DOTS; opts->shadeSliders=SHADE_BLEND_SELECTED; opts->shadeMenubars=SHADE_DARKEN; opts->shadeCheckRadio=SHADE_NONE; opts->toolbarBorders=TB_NONE; opts->toolbarSeparators=LINE_DOTS; opts->splitters=LINE_DOTS; opts->fixParentlessDialogs=false; opts->customMenuTextColor=false; opts->coloredMouseOver=MO_PLASTIK; opts->menubarMouseOver=true; opts->shadeMenubarOnlyWhenActive=true; opts->thinnerMenuItems=false; opts->scrollbarType=SCROLLBAR_KDE; opts->shadowButtons=true; #ifndef QTC_PLAIN_FOCUS_ONLY opts->stdFocus=true; #endif opts->lvLines=false; opts->drawStatusBarFrames=false; opts->fillSlider=true; opts->roundMbTopOnly=true; opts->borderMenuitems=true; opts->gradientPbGroove=true; opts->darkerBorders=false; opts->vArrows=false; opts->colorMenubarMouseOver=false; #ifdef __cplusplus opts->stdSidebarButtons=false; opts->gtkScrollViews=false; opts->gtkComboMenus=false; opts->customMenubarsColor.setRgb(0, 0, 0); opts->customSlidersColor.setRgb(0, 0, 0); opts->customMenuNormTextColor.setRgb(0, 0, 0); opts->customMenuSelTextColor.setRgb(0, 0, 0); opts->customCheckRadioColor.setRgb(0, 0, 0); #else opts->customMenubarsColor.red=opts->customMenubarsColor.green=opts->customMenubarsColor.blue=0; opts->customSlidersColor.red=opts->customSlidersColor.green=opts->customSlidersColor.blue=0; opts->customMenuNormTextColor.red=opts->customMenuNormTextColor.green=opts->customMenuNormTextColor.blue=0; opts->customMenuSelTextColor.red=opts->customMenuSelTextColor.green=opts->customMenuSelTextColor.blue=0; opts->customCheckRadioColor.red=opts->customCheckRadioColor.green=opts->customCheckRadioColor.blue=0; #endif /* Read system config file... */ { static const char * systemFilename=NULL; if(!systemFilename) systemFilename=getSystemConfigFile(); if(systemFilename) readConfig(systemFilename, opts, opts); } }
void RenderRadio::paintObject(PaintInfo& i, int _tx, int _ty) { ASSERT(node()); Element* element = static_cast<Element*>(node()); InputElement* inputElement = toInputElement(element); bool isEnabled = element->isEnabledFormControl(); bool isChecked = inputElement->isChecked(); i.context->save(); RefPtr<Image> image = Image::loadPlatformResource( "radioButtonStates" ).get(); IntPoint destPt( _tx, _ty ); IntRect srcRect( 0, 0, 14, 16 ); if (isEnabled) { if (node()->active()) { if (isChecked) { srcRect.move( 75, 0 ); } else { srcRect.move( 60, 0 ); } } else if (node()->hovered()) { if (isChecked) { srcRect.move( 45, 0 ); } else { srcRect.move( 30, 0 ); } } else { if (isChecked) { srcRect.move( 15, 0 ); } else { } } } else { if (isChecked) { srcRect.move( 105, 0 ); } else { srcRect.move( 90, 0 ); } } i.context->drawImage( image.get(), DeviceColorSpace, destPt, srcRect ); // draw the focus ring. // if (node()->focused()) { IntRect focusRingSrcRect( 120, 0, 15, 17 ); i.context->drawImage( image.get(), DeviceColorSpace, destPt, focusRingSrcRect ); } #if 0 // this is the old "moveto - lineto" drawing code IntRect checkRect(_tx + borderLeft() , _ty + borderTop() , width() - borderLeft() - borderRight() , height() - borderBottom() - borderTop()); Color fillColor(0xff, 0xff, 0xff, 0x00); Color rectColor(0x18, 0x52, 0x84); Color checkColor(0x21, 0xa5, 0x21); if (!node()->isEnabled()) { rectColor = Color(0xce, 0xce, 0xdb); checkColor = Color(0xce, 0xce, 0xdb); } i.context->setStrokeThickness(1); i.context->setStrokeStyle(SolidStroke); i.context->setStrokeColor(rectColor); i.context->setFillColor(fillColor); i.context->drawEllipse(checkRect); if(node()->isEnabled() && node()->hovered()) { i.context->setStrokeColor(Color(0xff, 0xb5, 0x31)); IntRect hoverRect = checkRect; hoverRect.inflateX(-1); hoverRect.inflateY(-1); i.context->drawEllipse( hoverRect ); hoverRect.inflateX(-1); hoverRect.inflateY(-1); i.context->drawEllipse( hoverRect ); } if (isChecked) { i.context->setStrokeThickness(2); i.context->setStrokeColor(checkColor); i.context->setFillColor(checkColor); IntRect fillRect = checkRect; fillRect.inflateX(-2); fillRect.inflateY(-2); i.context->drawEllipse(fillRect); } #endif i.context->restore(); }
int main(int argc,char **argv) { if (FILE_SEP == 0) fSEP = "\\"; APP_PATH = argv[0]; string::size_type i = APP_PATH.find_last_of(fSEP); if (i != string::npos) APP_PATH.erase(i+1); if (argc < 2 || argc > 5) { usage(); } // Create scene int color; int xSize = 80; int ySize = 60; Scene scn; // used photoshop color spectrum to select colors Color c = Color::BLACK; if (strcmp(argv[1], "cloud") == 0) { CloudTexture cloud = CloudTexture(); c.FromInt(0xCCE5FF); scn.setTexture(&cloud); } else if (strcmp(argv[1], "wood") == 0) { c.FromInt(0x7906131); WoodTexture wood = WoodTexture(); scn.setTexture(&wood); } else if (strcmp(argv[1], "marble") == 0) { c.FromInt(0xb2daed); MarbleTexture marble = MarbleTexture(40.0f); scn.setTexture(&marble); } else if (strcmp(argv[1], "lava") == 0) { c.FromInt(0x8e1b1b); CellTexture latex = CellTexture(10.0f, 5550, WorleyNoise::MANHATTAN, WorleyNoise::D3); scn.setTexture(&latex); } else if (strcmp(argv[1], "cell") == 0) { c.FromInt(0xc99968); CellTexture gro = CellTexture(1.0f, 1305, WorleyNoise::EUCLIDIAN, WorleyNoise::D1); scn.setTexture(&gro); } else { usage(); } if (argc == 3) { color = checkColor(argv[2]); c.FromInt( color ); } else if (argc == 4) { xSize = checkSize(argv[2]); ySize = checkSize(argv[3]); } else if (argc == 5) { color = checkColor(argv[2]); c.FromInt( color ); xSize = checkSize(argv[3]); ySize = checkSize(argv[4]); } scn.setColor(c); //Render image scn.SetResolution(xSize,ySize); scn.Render(); concat = APP_PATH + "texture.bmp"; scn.SaveBitmap(concat.c_str()); }
bool DitheringCase::drawAndCheckUnicoloredQuad (const Vec4& quadColor) const { TestLog& log = m_testCtx.getLog(); Random rnd (deStringHash(getName())); const int maxViewportWid = 32; const int maxViewportHei = 32; const int viewportWid = de::min(m_renderCtx.getRenderTarget().getWidth(), maxViewportWid); const int viewportHei = de::min(m_renderCtx.getRenderTarget().getHeight(), maxViewportHei); const int viewportX = rnd.getInt(0, m_renderCtx.getRenderTarget().getWidth() - viewportWid); const int viewportY = rnd.getInt(0, m_renderCtx.getRenderTarget().getHeight() - viewportHei); Quad quad; Surface renderedImg (viewportWid, viewportHei); GLU_CHECK_CALL(glViewport(viewportX, viewportY, viewportWid, viewportHei)); log << TestLog::Message << "Dithering is " << (m_ditheringEnabled ? "enabled" : "disabled") << TestLog::EndMessage; if (m_ditheringEnabled) GLU_CHECK_CALL(glEnable(GL_DITHER)); else GLU_CHECK_CALL(glDisable(GL_DITHER)); log << TestLog::Message << "Drawing an unicolored quad with color " << quadColor << TestLog::EndMessage; quad.color[0] = quadColor; quad.color[1] = quadColor; quad.color[2] = quadColor; quad.color[3] = quadColor; m_renderer->render(quad); glu::readPixels(m_renderCtx, viewportX, viewportY, renderedImg.getAccess()); GLU_CHECK_MSG("glReadPixels()"); log << TestLog::Image(("Quad" + de::toString(m_iteration)).c_str(), ("Quad " + de::toString(m_iteration)).c_str(), renderedImg); // Validate, at each pixel, that each color channel is one of its two allowed values. { Surface errorMask (viewportWid, viewportHei); bool colorChoicesOk = true; for (int y = 0; y < renderedImg.getHeight(); y++) { for (int x = 0; x < renderedImg.getWidth(); x++) { if (!checkColor(quadColor, renderedImg.getPixel(x, y), colorChoicesOk)) { errorMask.setPixel(x, y, tcu::RGBA::red); if (colorChoicesOk) { log << TestLog::Message << "First failure at pixel (" << x << ", " << y << ") (not printing further errors)" << TestLog::EndMessage; colorChoicesOk = false; } } else errorMask.setPixel(x, y, tcu::RGBA::green); } } if (!colorChoicesOk) { log << TestLog::Image("ColorChoiceErrorMask", "Error mask for color choices", errorMask); return false; } } // When dithering is disabled, the color selection must be coordinate-independent - i.e. the entire rendered image must be unicolored. if (!m_ditheringEnabled) { const tcu::RGBA renderedClr00 = renderedImg.getPixel(0, 0); for (int y = 0; y < renderedImg.getHeight(); y++) { for (int x = 0; x < renderedImg.getWidth(); x++) { const tcu::RGBA curClr = renderedImg.getPixel(x, y); if (curClr != renderedClr00) { log << TestLog::Message << "Failure: color at (" << x << ", " << y << ") is " << curClr << " and does not equal the color at (0, 0), which is " << renderedClr00 << TestLog::EndMessage; return false; } } } } return true; }
bool DitheringCase::drawAndCheckGradient (const bool isVerticallyIncreasing, const Vec4& highColor) const { TestLog& log = m_testCtx.getLog(); Random rnd (deStringHash(getName())); const int maxViewportWid = 256; const int maxViewportHei = 256; const int viewportWid = de::min(m_renderCtx.getRenderTarget().getWidth(), maxViewportWid); const int viewportHei = de::min(m_renderCtx.getRenderTarget().getHeight(), maxViewportHei); const int viewportX = rnd.getInt(0, m_renderCtx.getRenderTarget().getWidth() - viewportWid); const int viewportY = rnd.getInt(0, m_renderCtx.getRenderTarget().getHeight() - viewportHei); const Vec4 quadClr0 (0.0f, 0.0f, 0.0f, 0.0f); const Vec4& quadClr1 = highColor; Quad quad; Surface renderedImg (viewportWid, viewportHei); GLU_CHECK_CALL(glViewport(viewportX, viewportY, viewportWid, viewportHei)); log << TestLog::Message << "Dithering is " << (m_ditheringEnabled ? "enabled" : "disabled") << TestLog::EndMessage; if (m_ditheringEnabled) GLU_CHECK_CALL(glEnable(GL_DITHER)); else GLU_CHECK_CALL(glDisable(GL_DITHER)); log << TestLog::Message << "Drawing a " << (isVerticallyIncreasing ? "vertically" : "horizontally") << " increasing gradient" << TestLog::EndMessage; quad.color[0] = quadClr0; quad.color[1] = isVerticallyIncreasing ? quadClr1 : quadClr0; quad.color[2] = isVerticallyIncreasing ? quadClr0 : quadClr1; quad.color[3] = quadClr1; m_renderer->render(quad); glu::readPixels(m_renderCtx, viewportX, viewportY, renderedImg.getAccess()); GLU_CHECK_MSG("glReadPixels()"); log << TestLog::Image(isVerticallyIncreasing ? "VerGradient" : "HorGradient", isVerticallyIncreasing ? "Vertical gradient" : "Horizontal gradient", renderedImg); // Validate, at each pixel, that each color channel is one of its two allowed values. { Surface errorMask (viewportWid, viewportHei); bool colorChoicesOk = true; for (int y = 0; y < renderedImg.getHeight(); y++) { for (int x = 0; x < renderedImg.getWidth(); x++) { const float inputF = ((float)(isVerticallyIncreasing ? y : x) + 0.5f) / (float)(isVerticallyIncreasing ? renderedImg.getHeight() : renderedImg.getWidth()); const Vec4 inputClr = (1.0f-inputF)*quadClr0 + inputF*quadClr1; if (!checkColor(inputClr, renderedImg.getPixel(x, y), colorChoicesOk)) { errorMask.setPixel(x, y, tcu::RGBA::red); if (colorChoicesOk) { log << TestLog::Message << "First failure at pixel (" << x << ", " << y << ") (not printing further errors)" << TestLog::EndMessage; colorChoicesOk = false; } } else errorMask.setPixel(x, y, tcu::RGBA::green); } } if (!colorChoicesOk) { log << TestLog::Image("ColorChoiceErrorMask", "Error mask for color choices", errorMask); return false; } } // When dithering is disabled, the color selection must be coordinate-independent - i.e. the colors must be constant in the gradient's constant direction. if (!m_ditheringEnabled) { const int increasingDirectionSize = isVerticallyIncreasing ? renderedImg.getHeight() : renderedImg.getWidth(); const int constantDirectionSize = isVerticallyIncreasing ? renderedImg.getWidth() : renderedImg.getHeight(); for (int incrPos = 0; incrPos < increasingDirectionSize; incrPos++) { tcu::RGBA prevConstantDirectionPix; for (int constPos = 0; constPos < constantDirectionSize; constPos++) { const int x = isVerticallyIncreasing ? constPos : incrPos; const int y = isVerticallyIncreasing ? incrPos : constPos; const tcu::RGBA clr = renderedImg.getPixel(x, y); if (constPos > 0 && clr != prevConstantDirectionPix) { log << TestLog::Message << "Failure: colors should be constant per " << (isVerticallyIncreasing ? "row" : "column") << " (since dithering is disabled), but the color at position (" << x << ", " << y << ") is " << clr << " and does not equal the color at (" << (isVerticallyIncreasing ? x-1 : x) << ", " << (isVerticallyIncreasing ? y : y-1) << "), which is " << prevConstantDirectionPix << TestLog::EndMessage; return false; } prevConstantDirectionPix = clr; } } } return true; }
void Paint::loop() { sf::Event e; int t[2]; t[0] = t[1] = -1; drawBrush(_App, _colors); while (1) { if (_App->GetEvent(e)) { if (e.Type == sf::Event::MouseButtonPressed || _pressed == true) { const sf::Input &input = _App->GetInput(); int x = input.GetMouseX(); int y = input.GetMouseY(); if (y > 100) { if (_type == PAINT) _App->Draw(sf::Sprite(sf::Image(5, 5, _currentColor), sf::Vector2f(x, y))); else if ((_type == CARRE || _type == CERCLE) && _pressed == false) { t[0] = x; t[1] = y; } _pressed = true; } else { if (x >= 220 && x <= 333) { if (y >= 10 && y <= 65) { _type = CARRE; } } else if (x >= 350 && 429) { if (y >= 10 && y <= 65) _type = CERCLE; } else _currentColor = checkColor(x, y, _colors, _currentColor, _App); _pressed = false; } } if (e.Type == sf::Event::MouseButtonReleased) { if ((_type == CARRE || _type == CERCLE) && _pressed == true) { const sf::Input &input = _App->GetInput(); int x = input.GetMouseX(); int y = input.GetMouseY(); if (_type == CARRE) { sf::Shape p(sf::Shape::Rectangle(t[0], t[1], x, y, _currentColor)); _App->Draw(p); } else { int r = ABS((t[1] - y)); if (t[1] - r > 100) { sf::Shape p(sf::Shape::Circle(t[0], t[1], (t[1] - y), _currentColor)); _App->Draw(p); } } t[0] = t[1] = -1; _type = PAINT; } _pressed = false; } } _App->Display(); } }
void fillWay(Way * way){ if(map == NULL){ fprintf(stderr,"La map est NULL dans line fonction fillWay\n"); return; } if(way == NULL){ fprintf(stderr,"Le way est NULL dans line fonction fillWay\n"); return; } ListNode * l = way->listNd; if(l == NULL){ fprintf(stderr,"Le way %ld a pas de noeud : line.c fonction fill way\n",way->id ); return; } refListNode * current =l->firstRef; int nbre=0; if(way->size != 0){ short coord_x [way->size]; short coord_y [way->size]; while(current != NULL){ Node * currentNode = searchNode(map->avl,current->nd); if(currentNode != NULL){ if(currentNode->c != NULL){ coord_x[nbre] = miseAEchelleX(currentNode->c->x,map->bounds->max->x,windows_Width); coord_y[nbre] = miseAEchelleY(currentNode->c->y,map->bounds->max->y,windows_Height); nbre++; } else{ fprintf(stderr,"le node %ld n'a pas de coordonnees\n",current->nd ); } current = current->next; } else{ fprintf(stderr,"Le node %ld n'est pas définis dans le fichier d'entree \n",current->nd ); } } if(way->tag != NULL && way->tag->tagKey != NULL && way->tag->c != NULL){ if(strcmp(way->tag->tagKey,"highway")==0){ int draw = 1; int thick = 0; if(way->tag->thick != 0){ thick = (way->tag->thick+modifThink); if(thick < 1){ draw = zoomDrawHighway(way->tag->tagValue,modifThink); thick = 1; } thick *= zoom; } int i; int x = coord_x[0]; int y = coord_y[0]; if(draw == 1){ for(i=0;i<way->size;i++){ thickLineRGBA(renderer,x,y,coord_x[i],coord_y[i],thick,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255); if(drawContour ==1){ int diff = 100; thickLineRGBA(renderer,x+thick/2,y+thick/2,coord_x[i]+thick/2,coord_y[i]+thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255); thickLineRGBA(renderer,x-thick/2,y-thick/2,coord_x[i]-thick/2,coord_y[i]-thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255); } x = coord_x[i]; y = coord_y[i]; } //highway(way,coord_y,coord_x,thick); //nameHighway(way,l); } } else{ if(drawContour == 1){ polygonRGBA(renderer,coord_x,coord_y,way->size,139,71,137,255); } filledPolygonRGBA(renderer,coord_x,coord_y,way->size,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255); } } else{ filledPolygonRGBA(renderer,coord_x,coord_y,way->size,0,0,255,255); } } }
void GBufferedImage::setRGB(double x, double y, int rgb) { checkIndex("setRGB", x, y); checkColor("setRGB", rgb); m_pixels[(int) y][(int) x] = rgb; pp->gbufferedimage_setRGB(this, x, y, rgb); }
void loop() { pickup(); auto dropPlace = checkColor(); dropInBox(dropPlace); }
void GBufferedImage::fill(int rgb) { checkColor("fill", rgb); m_pixels.fill(rgb); pp->gbufferedimage_fill(this, rgb); }