int maintime::idle_progress (long ticks) { m_tick = ticks; m_window->clear(); m_gc->set_foreground(black()); m_window->draw_rectangle ( m_gc, false, 0, 0, m_window_x - 1, m_window_y - 1 ); int width = m_window_x - m_pill_width - 1; int tick_x = ((m_tick % m_ppqn) * (m_window_x - 1)) / m_ppqn ; int beat_x = (((m_tick / 4) % m_ppqn) * width) / m_ppqn ; int bar_x = (((m_tick / 16) % m_ppqn) * width) / m_ppqn ; if (tick_x <= (m_window_x / 4)) { m_gc->set_foreground(grey()); m_window->draw_rectangle ( m_gc, true, 2, /*tick_x + 2,*/ 2, m_window_x - 4, m_window_y - 4 ); } m_gc->set_foreground(black()); m_window->draw_rectangle ( m_gc, true, beat_x + 2, 2, m_pill_width, m_window_y - 4 ); m_window->draw_rectangle ( m_gc, true, bar_x + 2, 2, m_pill_width, m_window_y - 4 ); return true; }
int CBwfind::valuefirst(int tb[][8] ) { int flag,minus,corner=0,v,ComMobil,ManMobil,DiffMobil,Num,squre; int danger; flag=ComChoice; ComMobil=Mobility(tb,ComChoice); ManMobil=Mobility(tb,ManChoice); //DiffMobil=ComMobil*ComMobil-ManMobil*ManMobil; //a DiffMobil=ComMobil-ManMobil; //b Num=Total(tb); if(flag==1){ minus=white(tb)-black(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=black(tb); } if(flag==-1){ minus=black(tb)-white(tb); if(minus>=0) squre=minus*minus; else squre=-minus*minus; danger=white(tb); } if(Num<25){ v=minus+2*DiffMobil; } else{ v=minus+3*DiffMobil; } if(danger==0) v=-10000; return v; }
int alone(char **t, int n, int i, int j) { return black(t, n, i-1, j) && black(t, n, i+1, j) && black(t, n, i, j-1) && black(t, n, i, j+1); }
void seqtime::update_pixmap () { m_gc->set_foreground(white()); /* clear background */ m_pixmap->draw_rectangle(m_gc, true, 0, 0, m_window_x, m_window_y); m_gc->set_foreground(black()); m_pixmap->draw_line(m_gc, 0, m_window_y - 1, m_window_x, m_window_y - 1); /* * See the description in the banner. */ int measure_length_32nds = m_seq.get_bpm() * 32 / m_seq.get_bw(); int measures_per_line = (128 / measure_length_32nds) / (32 / m_zoom); if (measures_per_line <= 0) measures_per_line = 1; int ticks_per_measure = m_seq.get_bpm() * (4 * c_ppqn) / m_seq.get_bw(); int ticks_per_step = ticks_per_measure * measures_per_line; int start_tick = m_scroll_offset_ticks - (m_scroll_offset_ticks % ticks_per_step); int end_tick = (m_window_x * m_zoom) + m_scroll_offset_ticks; m_gc->set_foreground(black()); /* draw vert lines */ for (int i = start_tick; i < end_tick; i += ticks_per_step) { int base_line = i / m_zoom; m_pixmap->draw_line /* the beat */ ( m_gc, base_line - m_scroll_offset_x, 0, base_line - m_scroll_offset_x, m_window_y ); char bar[5]; snprintf(bar, sizeof(bar), "%d", (i / ticks_per_measure) + 1); m_gc->set_foreground(black()); p_font_renderer->render_string_on_drawable ( m_gc, base_line + 2 - m_scroll_offset_x, 0, m_pixmap, bar, font::BLACK ); } long end_x = m_seq.get_length() / m_zoom - m_scroll_offset_x; m_gc->set_foreground(black()); m_pixmap->draw_rectangle(m_gc, true, end_x, 9, 19, 8); p_font_renderer->render_string_on_drawable ( m_gc, end_x + 1, 9, m_pixmap, "END", font::WHITE ); }
inline typename ImageFactory<T>::view_type* logical_combine(T& a, const U& b, const FUNCTOR& functor, bool in_place) { if (a.nrows() != b.nrows() || a.ncols() != b.ncols()) throw std::runtime_error("Images must be the same size."); typedef typename T::value_type TVALUE; typedef typename ImageFactory<T>::view_type VIEW; if (in_place) { typename T::vec_iterator ia = a.vec_begin(); typename U::const_vec_iterator ib = b.vec_begin(); typename choose_accessor<T>::accessor ad = choose_accessor<T>::make_accessor(a); for (; ia != a.vec_end(); ++ia, ++ib) { bool b = functor(is_black(*ia), is_black(*ib)); if (b) ad.set(white(a), ia); else ad.set(black(a), ia); } // Returning NULL is converted to None by the wrapper mechanism return NULL; } else { typename ImageFactory<T>::data_type* dest_data = new typename ImageFactory<T>::data_type(a.size(), a.origin()); VIEW* dest = new VIEW(*dest_data); typename T::vec_iterator ia = a.vec_begin(); typename U::const_vec_iterator ib = b.vec_begin(); typename VIEW::vec_iterator id = dest->vec_begin(); typename choose_accessor<VIEW>::accessor ad = choose_accessor<VIEW>::make_accessor(*dest); try { // Vigra's combineTwoImages does not clip back to one of the standard // Gamera image types, so we have to do this differently ourselves. MGD for (; ia != a.vec_end(); ++ia, ++ib, ++id) { bool b = functor(is_black(*ia), is_black(*ib)); if (b) ad.set(white(a), id); else ad.set(black(a), id); } } catch (std::exception e) { delete dest; delete dest_data; throw; } return dest; } }
inline bool thin_hs_hit_and_miss(const T& in, T& H_M, const size_t& j, const size_t& k) { bool flag; /* HIT operation */ flag = false; for (size_t r = 1; r < in.nrows() - 1; ++r) { for (size_t c = 1; c < in.ncols() - 1; ++c) { for (size_t l = 0; l < 3; ++l) { for (size_t m = 0; m < 3; ++m) { if (is_white(in.get(Point(c + m - 1, r + l - 1)))) { if (thin_hs_elements[j][l] & (1 << m)) goto remove; } else { if (thin_hs_elements[k][l] & (1 << m)) goto remove; } } } H_M.set(Point(c, r), black(H_M)); flag = true; continue; remove: H_M.set(Point(c, r), white(H_M)); } } return flag; }
void RfkFinale::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(this); QBrush black(Qt::SolidPattern); int y = (this->height()-m_love.height())/2; painter.setBrush(black); painter.drawRect(0, 0, this->width(), this->height()); painter.drawPixmap(m_robotX+ (this->m_kitten.width() - this->m_robot.width()), y, m_robot); painter.drawPixmap(this->width()-(m_robotX+m_kitten.width()), y, m_kitten); if (m_loveSize > 0) { painter.drawPixmap((this->width()-m_loveSize)/2, (y+m_love.height()/2)-m_loveSize/2, m_loveSize, m_loveSize, m_love); } }
TYPED_TEST(ColorTest, ShouldDefineConstants) { Color<TypeParam> black(0, 0, 0); ASSERT_EQ(black, Color<TypeParam>::black()); Color<TypeParam> white(1, 1, 1); ASSERT_EQ(white, Color<TypeParam>::white()); }
bool DIYmain::update() { // grab the time since the application started (in seconds) float time = (float)glfwGetTime(); // calculate a delta time float deltaTime = time - prevTime; prevTime = time; Gizmos::clear(); upDate2DPhysics(deltaTime); vec4 white(1); vec4 black(0, 0, 0, 1); for (int i = 0; i <= 20; ++i) { Gizmos::addLine(vec3(-10 + i, -0.01, -10), vec3(-10 + i, -0.01, 10), i == 10 ? white : black); Gizmos::addLine(vec3(-10, -0.01, -10 + i), vec3(10, -0.01, -10 + i), i == 10 ? white : black); } m_camera.update(deltaTime); return true; }
//---------------------------------------------------------------------------- void Boolean2D::DrawPolySolid (BspPolygon2& polygon, ColorRGB color) { Vector2d v0, v1; Edge2 edge; int i, x0, y0, x1, y1; // Draw the edges. for (i = 0; i < polygon.GetNumEdges(); ++i) { polygon.GetEdge(i, edge); polygon.GetVertex(edge.I0, v0); polygon.GetVertex(edge.I1, v1); x0 = (int)(v0.X() + 0.5f); y0 = GetWidth() - 1 - (int)(v0.Y() + 0.5f); x1 = (int)(v1.X() + 0.5f); y1 = GetWidth() - 1 - (int)(v1.Y() + 0.5f); DrawLine(x0, y0, x1, y1, color); } // Draw the vertices. ColorRGB black(0, 0, 0); for (i = 0; i < polygon.GetNumVertices(); ++i) { polygon.GetVertex(i, v0); x0 = (int)(v0.X() + 0.5f); y0 = GetWidth() - 1 - (int)(v0.Y() + 0.5f); SetThickPixel(x0, y0, 1, black); } }
void C2DRenderUtils::RenderTest_Quads( float fTime, const ColorF& color ) { float no_quads = 20.f; float quad_width = m_pLayoutManager->GetVirtualWidth()/no_quads; float quad_height = m_pLayoutManager->GetVirtualHeight()/no_quads; const int xquads = (int)(m_pLayoutManager->GetVirtualWidth()/quad_width); const int yquads = (int)(m_pLayoutManager->GetVirtualHeight()/quad_height); float fX = 0; float fY = 0; for( int ix=0; ix<xquads; ix++ ) //float fX=0; fX<=m_pLayoutManager->GetVirtualWidth()-quad_width; fX+=quad_width ) { for( int iy=0; iy<yquads; iy++ ) //float fY=0; fY<=m_pLayoutManager->GetVirtualHeight()-quad_height; fY+=quad_height ) { float x = fX; float y = fY; float sx = quad_width; float sy = quad_height; DrawQuad( x, y, sx, sy, color ); ColorF black( 0.0f, 0.0f, 0.0f, 1.0f ); DrawLine( x, y, x+sx, y, black ); DrawLine( x+sx, y, x+sx, y+sy, black ); DrawLine( x+sx, y+sy, x, y+sy, black ); DrawLine( x, y+sy, x, y, black ); fY += quad_height; } fX += quad_width; fY = 0; } }
void CategoryMgr::savePrefs(void) { if (!m_changed) return; int count = 1; QString section = "CategoryMgr"; QString prefBaseName; CategoryListIterator it(m_categories); for (Category* curCategory = it.toFirst(); curCategory != NULL; curCategory = ++it) { prefBaseName.sprintf("Category%d_", count++); pSEQPrefs->setPrefString(prefBaseName + "Name", section, curCategory->name()); pSEQPrefs->setPrefString(prefBaseName + "Filter", section, curCategory->filter()); pSEQPrefs->setPrefString(prefBaseName + "FilterOut", section, curCategory->filterout()); pSEQPrefs->setPrefColor(prefBaseName + "Color", section, curCategory->color()); } QColor black("black"); while (count <= tMaxNumCategories) { prefBaseName.sprintf("Category%d_", count++); pSEQPrefs->setPrefString(prefBaseName + "Name", section, ""); pSEQPrefs->setPrefString(prefBaseName + "Filter", section, ""); pSEQPrefs->setPrefString(prefBaseName + "FilterOut", section, ""); pSEQPrefs->setPrefColor(prefBaseName + "Color", section, black); } }
void BoundingBox::setupVBOs() { HandleGLError("bounding box setup VBOs enter"); float thickness = 0.001*glm::length(maximum-minimum); glm::vec3& A = minimum; glm::vec3& B = maximum; glm::vec4 black(0,0,0,1); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,A.y,A.z),glm::vec3(A.x,A.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,A.y,B.z),glm::vec3(A.x,B.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,B.y,B.z),glm::vec3(A.x,B.y,A.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,B.y,A.z),glm::vec3(A.x,A.y,A.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(B.x,A.y,A.z),glm::vec3(B.x,A.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(B.x,A.y,B.z),glm::vec3(B.x,B.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(B.x,B.y,B.z),glm::vec3(B.x,B.y,A.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(B.x,B.y,A.z),glm::vec3(B.x,A.y,A.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,A.y,A.z),glm::vec3(B.x,A.y,A.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,A.y,B.z),glm::vec3(B.x,A.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,B.y,B.z),glm::vec3(B.x,B.y,B.z),black,black,thickness,thickness); addEdgeGeometry(bb_verts,bb_tri_indices,glm::vec3(A.x,B.y,A.z),glm::vec3(B.x,B.y,A.z),black,black,thickness,thickness); glBindBuffer(GL_ARRAY_BUFFER,bb_verts_VBO); glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosNormalColor)*bb_verts.size(),&bb_verts[0],GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,bb_tri_indices_VBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(VBOIndexedTri)*bb_tri_indices.size(),&bb_tri_indices[0],GL_STATIC_DRAW); HandleGLError("bounding box setup VBOs finished"); }
// canvas::draw overridable virtual void draw( HELEMENT he, graphics& gx, UINT width, UINT height ) { if( !data.is_array() ) { draw_message( gx, width, height, const_wchars(L"Data not found") ); return; } color black(0,0,0); // x axis gx.line_cap(LINE_CAP_BUTT); gx.line_color(black); gx.line( 0.5, height - 0.5, width - 0.5, height - 0.5 ); // 0.5 - to draw line in the middle of the pixel for( int n = 0; n < data.length(); ++n ) { json::value bar_def = data[n]; json::value color_v = bar_def.k2v(L"color"); json::value value_v = bar_def.k2v(L"value"); if( color_v.is_undefined() || value_v.is_undefined()) { draw_message( gx, width, height, const_wchars(L"Bad data structure") ); return; } draw_bar(gx, width, height, n, data.length(), color(color_v.get(0)), value_v.get(1.0)); } }
void FV_VisualDragText::drawCursor(PT_DocPosition newPos) { if(m_bCursorDrawn) return; getGraphics()->allCarets()->disable(true); m_pView->m_countDisable++; fp_Run * pRunLow = NULL; fl_BlockLayout * pBlock = NULL; UT_sint32 xLow, yLow; UT_uint32 heightCaret; UT_sint32 xCaret2, yCaret2; bool bDirection=false; bool bEOL=false; m_pView->_findPositionCoords(newPos, bEOL, xLow, yLow, xCaret2, yCaret2, heightCaret, bDirection, &pBlock, &pRunLow); m_recCursor.left = xLow; m_recCursor.top = yLow; m_recCursor.width = getGraphics()->tlu(2); // the cursor is 2 device units wide, not // logical units m_recCursor.height = heightCaret; m_recDoc.left = xLow - getGraphics()->tlu(1); m_recDoc.top = yLow - getGraphics()->tlu(1); m_recDoc.width = getGraphics()->tlu(3); m_recDoc.height = heightCaret + getGraphics()->tlu(1); UT_ASSERT(m_pDocUnderCursor == NULL); GR_Painter painter(getGraphics()); m_pDocUnderCursor = painter.genImageFromRectangle(m_recDoc); UT_RGBColor black(0,0,0); painter.fillRect( black, m_recCursor); m_bCursorDrawn = true; }
Light* SkyDome::getLight(int time){ double t = getT(time, 0.1, 0.55); double a = t*M_PI; double sina = sin(a); Colour black(0,0,0); Colour white(1,1,1); Light shadow; shadow.ambient = black; shadow.diffuse = black; shadow.specular = black; Light lit; lit.ambient = black*(1-sina) + sina*Colour(0.2,0.2,0.2); lit.diffuse = black*(1-sina) + sina*white; lit.specular = black*(1-sina) + sina*white; Light* lights = new Light[2]; lights[0] = shadow; lights[1] = lit; return lights; }
//---------------------------------------------------------------------------- void ClodPolyline::OnDisplay () { ClearScreen(); ColorRGB black(0, 0, 0); const int numVertices = mPolyline->GetNumVertices(); const Vector3f* vertices = mPolyline->GetVertices(); const int numEdges = mPolyline->GetNumEdges(); const int* edges = mPolyline->GetEdges(); Vector3f vertex; int i; for (i = 0; i < numVertices; ++i) { vertex = vertices[i]; int x = (int)(0.25f*mSize*(vertex.X() + 2.0f)); int y = mSize - 1 - (int)(0.25f*mSize*(vertex.Y() + 2.0f)); SetThickPixel(x, y, 1, black); } for (i = 0; i < numEdges; ++i) { vertex = vertices[edges[2*i]]; int x0 = (int)(0.25f*mSize*(vertex.X() + 2.0f)); int y0 = mSize - 1 - (int)(0.25f*mSize*(vertex.Y() + 2.0f)); vertex = vertices[edges[2*i+1]]; int x1 = (int)(0.25*mSize*(vertex.X() + 2.0f)); int y1 = mSize - 1 - (int)(0.25f*mSize*(vertex.Y() + 2.0f)); DrawLine(x0, y0, x1, y1, black); } WindowApplication2::OnDisplay(); }
void QvisAbstractOpacityBar::drawColorBackground() { int w = contentsRect().width(); int h = contentsRect().height(); QRgb *bgCols = new QRgb[w]; if(backgroundColorControlPoints) { unsigned char *cols = new unsigned char[w*3]; backgroundColorControlPoints->GetColors(cols, w); for (int i=0; i < w; ++i) bgCols[i] = QColor(cols[i*3+0], cols[i*3+1], cols[i*3+2]).rgb(); delete[] cols; } else { QColor black(0, 0, 0 ); QRgb cb = black.rgb(); for (int i=0; i < w; ++i) bgCols[i] = cb; } for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) image->setPixel(x,y, bgCols[x]); } delete [] bgCols; }
//---------------------------------------------------------------------------- void RoughPlaneParticle2::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(); }
void *julia_cube(void *d) { int l[3]; long double z[4]; long double tmp; t_thread *m; m = (t_thread*)d; l[0] = m->lim[0] - 1; while (++l[0] < m->lim[2] && (l[1] = m->lim[1] - 1)) while (++l[1] < m->lim[3] && (l[2] = -1)) { z[2] = -0.7 + m->s->x / X; z[3] = 0.27015 + m->s->y / Y; z[0] = 1.5 * (l[0] - X / 2) / (0.5 * X) * m->s->z[0] + m->s->m[0]; z[1] = (l[1] - Y / 2) / (0.5 * Y) * m->s->z[0] + m->s->m[1]; while (++l[2] < m->s->imax && (z[0] * z[0] + z[1] * z[1]) < 4) { tmp = z[0]; z[0] = z[0] * z[0] - z[1] * z[1] + z[2]; z[1] = -2 * z[1] * tmp - z[3]; } (l[2] == m->s->imax) ? px_img(m->s, l[0], l[1], black(fmod(fabsl(l[2] / z[0]), 999))) : px_img(m->s, l[0], l[1], ft_colors_earth(fabsl(l[2] * z[1]))); } return (NULL); }
void Slider::draw(Renderer *renderer){ #ifdef D3D10 #else renderer->setDepthFunc(DEPTH_NONE); renderer->setBlending(SRC_ALPHA, ONE_MINUS_SRC_ALPHA); renderer->apply(); // Background renderer->drawRoundRect(xPos, yPos, xPos + width, yPos + height, 10, color); renderer->setDepthFunc(DEPTH_NONE); renderer->apply(); vec4 black(0, 0, 0, 1); // Border renderer->drawRoundRect(xPos, yPos, xPos + width, yPos + height, 10, black, 3); if (isHorizontal){ float vx = lerp(xPos + 12.0f, xPos + width - 12.0f, (value - r0) / (r1 - r0)) + 0.5f; renderer->drawLine(xPos + 12, yPos + 0.5f * height, xPos + width - 12, yPos + 0.5f * height, black, 3); renderer->drawRoundRect(vx - 5, yPos + 3, vx + 5, yPos + height - 3, 4, black); } else { float vy = lerp(yPos + 12.0f, yPos + height - 12.0f, (r1 - value) / (r1 - r0)) + 0.5f; renderer->drawLine(xPos + 0.5f * width, yPos + 12, xPos + 0.5f * width, yPos + height - 12, black, 3); renderer->drawRoundRect(xPos + 3, vy - 5, xPos + width - 3, vy + 5, 4, black); } #endif }
void GcScopeBar::paintBackground(QPaintEvent *) { QPainter painter(this); painter.save(); QRect all(0,0,width(),height()); // fill with a linear gradient #ifdef Q_OS_MAC int shade = isActiveWindow() ? 178 : 225; #else int shade = isActiveWindow() ? 200 : 250; #endif QLinearGradient linearGradient(0, 0, 0, 23); linearGradient.setColorAt(0.0, QColor(shade,shade,shade, 100)); linearGradient.setColorAt(0.5, QColor(shade,shade,shade, 180)); linearGradient.setColorAt(1.0, QColor(shade,shade,shade, 255)); linearGradient.setSpread(QGradient::PadSpread); painter.setPen(Qt::NoPen); painter.fillRect(all, linearGradient); QPen black(QColor(100,100,100)); painter.setPen(black); painter.drawLine(0,height()-1, width()-1, height()-1); QPen gray(QColor(230,230,230)); painter.setPen(gray); painter.drawLine(0,0, width()-1, 0); painter.restore(); }
void XICView::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { if(xic == NULL) return; QColor black(0,0,0); // Use black background for contrast. painter->setPen(QPen(black)); painter->setBrush(QBrush(black)); painter->drawRect(0,0, width, height); QColor green(0,255,0); painter->setPen(QPen(green)); // Display XIC. double srt = width / (maxrt - minrt), sI = height / maxI; double logImin = conf.logImin_disp, logImax = conf.logImax_disp; // Display only points within current range. for(size_t i = 0; i < xic->chrom.size(); i++) { lcms::peak &p = xic->chrom[i]; if(p.retentionTime < maxrt && p.retentionTime > minrt) { double x = (p.retentionTime - minrt) * srt; // Chose color to display. double logI = log10(p.intensity); int level = 0; if(logI > logImax) level = 255; else if( logI < logImin ) level = 0; else level = (int)((logI - logImin) / (logImax - logImin) * 256.0); QPen peak_color(colors[level]); painter->setPen(peak_color); painter->drawLine(QPointF(x, height), QPointF(x, height - p.intensity * sI)); } } }
bool ParticleScene::Update(float deltaTime) { _camera->Update(deltaTime); // Update our particle emitter _emitter->Update(deltaTime, _camera->GetTransform()); Gizmos::clear(); Gizmos::addTransform(glm::mat4(1)); glm::vec4 white(1); glm::vec4 black(0, 0, 0, 1); for (int i = 0; i < 21; i++) { Gizmos::addLine(glm::vec3(-10 + i, 0, 10), glm::vec3(-10 + i, 0, -10), i == 10 ? white : black); Gizmos::addLine(glm::vec3(10, 0, -10 + i), glm::vec3(-10, 0, -10 + i), i == 10 ? white : black); } return true; }
void testSkinRecogWithThreshold(const std::vector<double> &mean, const Matrix &cov, ImageType &image, std::string out){ RGB white(255,255,255); RGB black(0,0,0); int height, width, levels; image.getImageInfo(height,width,levels); RGB val; std::vector<double> pc(2); // pure color double thR, thG; for(int row = 0; row < height; row++){ for(int col = 0; col < width; col++){ image.getPixelVal(row, col, val); pc[0] = val.r/float(val.r+val.g+val.b); pc[1] = val.g/float(val.r+val.g+val.b); thR = exp(-(cov[0][0] * pow((pc[0] - mean[0]),2) + cov[0][1] * (pc[0]- mean[0]))); thG = exp(-(cov[1][0] * (pc[1] - mean[1]) + cov[1][1] * pow((pc[1] - mean[1]),2))); if((thR >= .9 && thG >= 1.0 && thG < 1.2) || (thR <= .8 && thR >= .7 && thG > 1.1)){ image.setPixelVal(row, col, white); } else{ image.setPixelVal(row, col, black); } } } // end outer for loop writeImage(out.c_str(), image); }
void InsertTextTool::readSettings() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); KConfigGroup group = config->group(d->configGroupName); QColor black(0, 0, 0); QFont defaultFont; int orgW = d->previewWidget->imageIface()->originalSize().width(); int orgH = d->previewWidget->imageIface()->originalSize().height(); if ( orgW > orgH ) { d->defaultSizeFont = (int)(orgH / 8.0); } else { d->defaultSizeFont = (int)(orgW / 8.0); } defaultFont.setPointSize(d->defaultSizeFont); d->textRotation->setCurrentIndex(group.readEntry(d->configTextRotationEntry, 0)); d->fontColorButton->setColor(group.readEntry(d->configFontColorEntry, black)); d->textOpacity->setValue(group.readEntry(d->configTextOpacity, 100)); d->textEdit->setText(group.readEntry(d->configTextStringEntry, i18n("Enter your text here."))); d->textFont = group.readEntry(d->configFontPropertiesEntry, defaultFont); d->fontChooserWidget->setFont(d->textFont); d->alignTextMode = group.readEntry(d->configTextAlignmentEntry, (int) InsertTextWidget::ALIGN_LEFT); d->borderText->setChecked(group.readEntry(d->configBorderTextEntry, false)); d->transparentText->setChecked(group.readEntry(d->configTransparentTextEntry, false)); d->previewWidget->setPositionHint(group.readEntry(d->configPositionHintEntry, QRect())); d->alignButtonGroup->button(d->alignTextMode)->setChecked(true); slotAlignModeChanged(d->alignTextMode); }
void FrameProcessor::filterColor(int threshold) { LOG(INFO) << __PRETTY_FUNCTION__; try{ ImageRGB::pixel_type p,p_end; ImageRGB::value_type black(0,0,0); ImageRGB::value_type green(0,255,0); for(p = frame_in.begin(), p_end = frame_in.end(); p != p_end; ++p) { ImageRGB::value_type& v = *p; if (v._green > v._blue && v._green > v._red) { int temp = v._blue < v._red ? v._blue : v._red; if (v._green - temp > threshold) *p = green; else *p = black; } else *p = black; } } catch(mirage::Exception::Any& e) { LOG(ERROR) << "Error : " << e.what(); } catch(...) { LOG(ERROR) << "Unknown error"; } }
void Bitmap::ring(float x, float y, float r, float t) { r = std::max(1.0f, r-1.0f); float w = (float)width; float h = (float)height; float lr = r - t; common::Color white(1,1,1,1); common::Color black(0,0,0,0); for(float cx=0; cx<w; cx+=1.0f) { for(float cy=0; cy<h; cy+=1.0f) { float dx = cx-x; float dy = cy-y; float cr = sqrtf(dx*dx+dy*dy); pixel((uint32_t)cx, (uint32_t)cy, ((cr < r) && (cr > lr)) ? white : black); // outer AA float dr = cr-r; if(dr >= 0.0f && (dr < 1.0f)) { float fract = 1.0f-(dr - floor(dr)); pixel((uint32_t)cx, (uint32_t)cy, common::Color(1,1,1,fract)); } // inner AA dr = cr-lr; if(dr >= 0.0f && (dr < 1.0f)) { float fract = (dr - floor(dr)); pixel((uint32_t)cx, (uint32_t)cy, common::Color(1,1,1,fract)); } } } }
void AppPostProcess::ondraw() { // bind our target glBindFramebuffer(GL_FRAMEBUFFER, render.FBO); glViewport(0, 0, getWidth(), getHeight()); // clear the target glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // draw our 3D scene //sky.draw(camera.rotationX, camera.rotationY); box.draw(camera); //Gizmos --------------------------- Gizmos::clear(); Gizmos::addTransform(glm::mat4(1)); vec4 white(1); vec4 black(0, 0, 0, 1); for (int i = 0; i < 21; ++i) { Gizmos::addLine(vec3(-10 + i, 0, 10), vec3(-10 + i, 0, -10), i == 10 ? white : black); Gizmos::addLine(vec3(10, 0, -10 + i), vec3(-10, 0, -10 + i), i == 10 ? white : black); } Gizmos::draw(camera.getProjectionView()); FBXDraw(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, getWidth(), getHeight()); // just clear the back-buffer depth as // each pixel will be filled glClear(GL_DEPTH_BUFFER_BIT); // draw out full-screen quad screen.texture = render.texture; screen.draw(); }
void perfroll::draw_background_on ( Glib::RefPtr<Gdk::Drawable> a_draw, int a_sequence ) { long tick_offset = m_4bar_offset * m_ticks_per_bar; long first_measure = tick_offset / m_measure_length; a_sequence -= m_sequence_offset; int y = m_names_y * a_sequence; int h = m_names_y; m_gc->set_foreground(white()); a_draw->draw_rectangle(m_gc, true, 0, y, m_window_x, h); m_gc->set_foreground(black()); for ( int i = first_measure; i < first_measure + (m_window_x*m_perf_scale_x/m_measure_length) + 1; i++ ) { int x_pos = ((i * m_measure_length) - tick_offset) / m_perf_scale_x; a_draw->draw_drawable ( m_gc, m_background, 0, 0, x_pos, y, m_background_x, m_names_y ); } }