Beispiel #1
0
OneBitImageView* flatten(const T &src )
{
typedef typename T::value_type value_type;
int x,y;

OneBitImageData* dest_data = new OneBitImageData(src.size(), src.origin());
OneBitImageView* dest = new OneBitImageView(*dest_data);
OneBitPixel blackval = black(*dest);
OneBitPixel whiteval = white(*dest);

for (y = 0; y < (int)src.nrows(); y++)
    for (x = 0; x < (int)src.ncols(); x++) {
        if (src.get(Point(x,y))!=0)
            dest->set(Point(x,y),blackval);
        else
            dest->set(Point(x,y),whiteval);
    }
return dest;
}
Beispiel #2
0
// Affichage de la scène
void SceneSimple::Render()
{
    ResourceManager& res = ResourceManager::getInstance();
    VarManager& var = VarManager::getInstance();

    DrawAxes();

    glColor3f(1.0f, 0.0f, 0.0f);
//	DrawTraj();

    glPushMatrix();
//	glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f);


    vec4 white(1.0f, 1.0f, 1.0f, 1.0f);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    vec4 pos(0.0, 0.0, 1.0, 0.0);
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glLightfv(GL_LIGHT0, GL_AMBIENT, white);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
    glLightfv(GL_LIGHT0, GL_SPECULAR, white);

    // Ici on va activer notre texture
    // On pourrait accéder à notre texture via :
    // Texture2D* pTex = res.getTexture2D("rocks_diffuse.jpg");
    // et cela éviterait d'avoir une variable de classe pour accéder à la ressource

    // On bind la texture en slot 0
    m_pMyTex->Bind(0);

    // On dessine un objet
    glColor3f(1.0f, 0.0f, 0.0f);
    glutSolidTeapot(5.0);
//	res.getMesh("simpsons_table.obj")->Draw();
    // la teapot est dessinée dans le mauvais sens, mais c'est un bug de glut,
    // les autres primitives sont, elles, dessinées dans le bon sens.

    // On la débind en slot 0 aussi
    m_pMyTex->Unbind(0);

    glPopMatrix();
}
Beispiel #3
0
RGBImageView* visualize(const T &src )
{
typedef typename T::value_type value_type;
int x,y;

RGBImageData* dest_data = new RGBImageData(src.size(), src.origin());
RGBImageView* dest = new RGBImageView(*dest_data);
RGBPixel blackval = black(*dest);
RGBPixel whiteval = white(*dest);

for (y = 0; y < (int)src.nrows(); y++)
    for (x = 0; x < (int)src.ncols(); x++) {
        switch (src.get(Point(x,y))) {
        case (1) :
            dest->set(Point(x,y),blackval);
            break; // black, music
        case (2) :
            dest->set(Point(x,y),RGBPixel(228, 228, 228));
            break; // light grey, border
        case (4) :
            dest->set(Point(x,y),RGBPixel(0, 127, 0));
            break; // dark green, ornate letter
        case (8) :
            dest->set(Point(x,y),RGBPixel(0, 255, 0));
            break; // light green, text in staff
        case (16) :
            dest->set(Point(x,y),RGBPixel(255, 127, 0));
            break; // orange, lyrics
        case (32) :
            dest->set(Point(x,y),RGBPixel(255, 227, 0));
            break; // yellow, title
        case (64) :
            dest->set(Point(x,y),RGBPixel(0, 0, 255));
            break; // blue, UNUSED
        case (128) :
            dest->set(Point(x,y),RGBPixel(255, 0, 255));
            break; // magenta, UNUSED
        default :
            dest->set(Point(x,y),whiteval);
        }
    }
return dest;
}
/**
* NewDrawNode
*/
NewDrawNodeTest::NewDrawNodeTest()
{
    auto s = Director::getInstance()->getWinSize();

    auto parent = Node::create();
    parent->setPosition(s.width/2, s.height/2);
    addChild(parent);

    auto rectNode = DrawNode::create();
    Point rectangle[4];
    rectangle[0] = Point(-50, -50);
    rectangle[1] = Point(50, -50);
    rectangle[2] = Point(50, 50);
    rectangle[3] = Point(-50, 50);

    Color4F white(1, 1, 1, 1);
    rectNode->drawPolygon(rectangle, 4, white, 1, white);
    parent->addChild(rectNode);
}
void CASW_VGUI_Computer_Frame::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

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

	vgui::HFont LabelFont = pScheme->GetFont( "Default", IsProportional() );
	Color white(255,255,255,255);
	Color blue(19,20,40, 255);
	m_pLogoffLabel->SetFont(LabelFont);
	m_pLogoffLabel->SetPaintBackgroundEnabled(true);
	m_pLogoffLabel->SetContentAlignment(vgui::Label::a_center);
	m_pLogoffLabel->SetBgColor(Color(19,20,40,255));
	m_pLogoffLabel->SetBorders("TitleButtonBorder", "TitleButtonBorder");
	m_pLogoffLabel->SetColors(white, white, white, white, blue);
	m_pLogoffLabel->SetPaintBackgroundType(2);

	// fade scanlines in
	if (!m_bSetAlpha)
	{
		m_bSetAlpha = true;
		m_pScan[0]->SetAlpha(0);
		m_pScan[1]->SetAlpha(0);
		m_pScan[2]->SetAlpha(0);
		// alphas were 85 170 255
		vgui::GetAnimationController()->RunAnimationCommand(m_pScan[0], "Alpha", 42, 0, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pScan[1], "Alpha", 85, 0, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pScan[2], "Alpha", 128, 0, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);

		m_pBackdropImage->SetAlpha(0);
		vgui::GetAnimationController()->RunAnimationCommand(m_pBackdropImage, "Alpha", 255, 0, 2.0f, vgui::AnimationController::INTERPOLATOR_LINEAR);
	}
	else
	{
		m_pScan[0]->SetAlpha(42);
		m_pScan[1]->SetAlpha(85);
		m_pScan[2]->SetAlpha(128);
		m_pBackdropImage->SetAlpha(255);
	}
}
Beispiel #6
0
  typename ImageFactory<T>::view_type* thin_lc(const T& in) {
    //typedef typename ImageFactory<T>::data_type data_type;
    typedef typename ImageFactory<T>::view_type view_type;

    // Chain to thin_zs
    view_type* thin_view = thin_zs(in);
    if (in.nrows() == 1 || in.ncols() == 1) {
      return thin_view;
    }

    try {
      size_t nrows = thin_view->nrows();
      size_t ncols = thin_view->ncols();
      typename view_type::vec_iterator it = thin_view->vec_begin();
      for (size_t y = 0; y < nrows; ++y) {
	size_t y_before = (y == 0) ? 1 : y - 1;
	size_t y_after = (y == nrows - 1) ? nrows - 2 : y + 1;
	for (size_t x = 0; x < ncols; ++x, ++it) {
	  if (is_black(*it)) {
	    size_t x_before = (x == 0) ? 1 : x - 1;
	    size_t x_after = (x == ncols - 1) ? ncols - 2 : x + 1;
	    
	    size_t j = ((is_black(thin_view->get(Point(x_after, y_after))) << 3) |
			(is_black(thin_view->get(Point(x_after, y))) << 2) |
			(is_black(thin_view->get(Point(x_after, y_before))) << 1) |
			(is_black(thin_view->get(Point(x, y_before)))));
	    
	    size_t i = ((is_black(thin_view->get(Point(x_before, y_before))) << 3) |
			(is_black(thin_view->get(Point(x_before, y))) << 2) |
			(is_black(thin_view->get(Point(x_before, y_after))) << 1) |
			(is_black(thin_view->get(Point(x, y_after)))));
	    
	    if (thin_lc_look_up[i] & (1 << j))
	      *it = white(*thin_view);
	  }
	}
      }
    } catch (std::exception e) {
      delete thin_view->data();
      delete thin_view;
    }
    return thin_view;
  }
Beispiel #7
0
void
Triangle::paint(QPainter& painter)
{
    painter.setBrush(brush_);
    painter.setPen(pen_);

    std::vector<QPoint> plist = dynamics_->getPositionList();
    std::vector<QPoint>::iterator idx = plist.begin();

    QBrush black( QColor(0x33, 0x33, 0x33), Qt::SolidPattern);
    QBrush white( QColor(0xFF, 0xFF, 0xFF), Qt::SolidPattern);
    QBrush brush;

    while (idx != plist.end())
    {
        painter.translate(*idx);
        painter.drawPolygon(triangle_);
        painter.translate(-(idx->x()),
                          -(idx->y()));

        if (targeted_)
            brush = black;
        else
            brush = white;

        painter.setBrush(brush);
        int X0 = idx->x() + (bounds_.width()/2);
        int Y0 = idx->y() + 2*(bounds_.height()/3);
        int W = bounds_.width()/3;
        int H = bounds_.height()/3;
        painter.setBrush(brush);
        // painter.setPen(pen_);
        painter.drawEllipse(X0 -W/2,
                            Y0 - H/2,
                            W,
                            H);
        painter.setBrush(brush_);
        painter.setBrush(brush_);

        ++idx;
    }
}
Beispiel #8
0
int main(int argc, char* argv[]) {
  Color merah(255,0,0);
  Color biru(0,0,255);
  Color hijau(0,255,0);
  Color kuning(255,255,0);
  Color white(200,200,200);
  
  screen.init();
  thread t1(inputHandler);
  while(!stop) {
  	if (wakeUp) {
  		usleep(16667);
  	}
  }
  t1.join();
  
  screen.terminate();
  
  return 0;
}
void gcProgressBar::doHandPaint(wxPaintDC& dc)
{
	wxSize size = GetSize();
	uint32 w = size.GetWidth();
	uint32 h = size.GetHeight()-2;

	uint32 wp = w*m_uiProg/100;

	wxColour green(0, 255, 0);
	wxColour white(255, 255, 255);
	wxColour black(0, 0, 0);

	dc.SetPen(wxPen(green,1)); 
	dc.SetBrush(wxBrush(green));
	dc.DrawRectangle(0,0, wp, h);

	dc.SetPen(wxPen(white,1)); 
	dc.SetBrush(wxBrush(white));
	dc.DrawRectangle(wp,0, w, h);
}
void CASW_VGUI_Message_Log::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	Color white(255,255,255,255);
		Color blue(19,20,40, 255);

	for (int i=0;i<ASW_MAX_LOGGED_MESSAGES;i++)
	{
		if (!m_pMessageButton)
			continue;

		m_pMessageButton[i]->SetAlpha(255);
		m_pMessageButton[i]->SetPaintBackgroundEnabled(true);
		m_pMessageButton[i]->SetContentAlignment(vgui::Label::a_center);
		m_pMessageButton[i]->SetBorders("TitleButtonBorder", "TitleButtonBorder");		
		m_pMessageButton[i]->SetColors(white, white, white, white, blue);
		m_pMessageButton[i]->SetPaintBackgroundType(2);
	}
}
Beispiel #11
0
  inline void thin_zs_flag(const T& thin, T& flag, const unsigned char a, const unsigned char b) {
    register unsigned char p;
    size_t N, S; 
    for (size_t y = 0; y < thin.nrows(); ++y) {
      size_t y_before = (y == 0) ? 1 : y - 1;
      size_t y_after = (y == thin.nrows() - 1) ? thin.nrows() - 2 : y + 1;
      for (size_t x = 0; x < thin.ncols(); ++x) {
	if (is_black(thin.get(Point(x, y)))) {
	  thin_zs_get(y, y_before, y_after, x, thin, p, N, S);
	  if ((N <= 6) && (N >= 2) &&
	      (S == 1) &&
	      !((p & a) == a) &&
	      !((p & b) == b))  
	    flag.set(Point(x, y), black(flag));
	  else
	    flag.set(Point(x, y), white(flag));
	}
      }
    }
  }
Beispiel #12
0
void TagView::paintEvent(QPaintEvent *e){
    QPainter p(this);
    p.setRenderHints(p.Antialiasing);
    QFontMetrics fm(font);
    QColor white(255,255,255,100);
    if (nrow==1){
        p.setFont(font);
        p.setPen(Qt::transparent);
        p.setBrush(white);
        int w=fm.width(name)+10;
        int h=fm.height()+6;
        p.drawRoundedRect(0,0,w,h,3,3);
        QRect trect(5,3,w-10,h-6);
        p.setPen(Qt::darkGray);
        p.drawText(trect,Qt::AlignCenter,name);
    }
    else if (nrow==2){}
    else e->ignore();
    e->accept();
}
Beispiel #13
0
void Diagram::add(Index vertex,PtrLen<const NTIndex> str,RIndex rule)
 {
  if( !str.len ) return;
  
  Index null(IndexNull);
  Index finish(IndexFinish);
  
                                            // vertex = V(n)
                                            // (str,rule) = (a1,a2,...,ak,r) , k>=1
                                            //
  Index a(*str);                            // a = a1
                                            //
  ++str;                                    // (str,rule) = (a2,...,ak,r)
                                            //
  if( a.hasClass(IndexNonTerminal) )        // a == n'
    add(vertex,a,null,str,rule);            // V(n) -> V(n') : (, (a2,...,ak,r) )
                                            //
  for(;;)                                   // i=1,...,k
    {                                       // vertex = ? or V(n) if( i==1 )
                                            // a = ai
                                            // (str,rule) = (a(i+1),...,ak,r)
                                            //
     add(vertex,finish,a,str,rule);         // vertex -> Finish : (ai, (a(i+1),...,ak,r) )
                                            //
     if( !str ) break;                      //
                                            // 
     Index b(*str);                         // b = a(i+1) , i<k
                                            //
     ++str;                                 // (str,rule) = (a(i+2),...,ak,r)
                                            //
     if( b.hasClass(IndexNonTerminal) )     // a(i+1) == n'
       add(vertex,b,a,str,rule);            // vertex -> V(n') : (ai, (a(i+2),...,ak,r) )
                                            //
     Index white(DoWhite);                  // next vertex = ?
                                            //
     add(vertex,white,a);                   // vertex -> next vertex : (ai, () )
                                            //
     a=b;                                   // a = a(i+1)
     vertex=white;                          // vertex=next vertex
    }
 }
Beispiel #14
0
void
Help(void)
{
	unsigned      i;

	white();
	high();
	printf("\n%s", hlp[1]);
	clear();
	printf("\n");
	for (i = 0; i < strlen(hlp[1]); i++)
		(void)putchar('-');
	printf("\n");
	high();
	printf("\r\t q,g\t%s\n", hlp[2]);
	printf("\t k\t%s\n", hlp[3]);
	printf("\t !\t%s\n", hlp[4]);
	printf("\t +\t%s\n", hlp[5]);
	printf("\t -\t%s\n", hlp[6]);
	printf("\t a\t%s\n", hlp[7]);
	printf("\t e\t%s\n", hlp[8]);
	printf("\t j\t%s\n", hlp[9]);
	printf("\t n\t%s\n", hlp[11]);
	printf("\t r\t%s\n", hlp[12]);
	printf("\t s\t%s\n", hlp[13]);
	printf("\t find foobar\t%s\n",hlp[25]);
	printf("\t conf\t%s\n", hlp[14]);
	printf("\t clean\t%s\n", hlp[15]);
	printf("\t load\t%s\n", hlp[16]);
#ifndef FRENCH
	printf("\t review\t%s\n", hlp[17]);
#else  /* francais */
	printf("\t revois\t%s\n", hlp[17]);
#endif
	printf("\t files\t%s\n", hlp[18]);
	printf("\t tag help\t%s\n", hlp[19]);
	printf("\t head\t%s\n", hlp[22]);
	printf("\t scan\t%s\n", hlp[24]);
	printf("\t qlist\t%s\n", hlp[23]);
	printf("\n");
}
Beispiel #15
0
/* Create a new backing pixmap of the appropriate size */
int ScribbleDrawingArea::configure_event_impl (GdkEventConfigure * /* event */)
  {

    Gdk_Font font ( "-*-courier-bold-*-*-*-*-240-*-*-*-*-*-*");
    list<NNode*>::iterator curnode;
    list<NNode*> seenlist;
    Gdk_Color red("red");
    Gdk_Color white("white");
    Gdk_Color black("black");
    get_colormap().alloc(black);
    get_colormap().alloc(white);

    char text[20];

    win = get_window();
    visual = win.get_visual();

    if (pixmap)
      pixmap.release();
    
    pixmap.create(get_window(),  width(), height());

    if (!gc)
      {
        gc = Gdk_GC(pixmap);
	gc.set_foreground(white);
      }
    //gc = get_style()->get_white_gc();
    gc.set_foreground(white);
    pixmap.draw_rectangle (gc,
			TRUE,
			0, 0,
			width(),
			height());


    //Draw network off of the drawlist
    drawrows(nodes);

    return TRUE;
  }
Beispiel #16
0
bool Physics::update()
{
    if (Application::update() == false)
    {
        return false;
    }

    Gizmos::clear();

    float dt = (float)glfwGetTime();
    m_delta_time = dt;
    glfwSetTime(0.0);

    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);
    }
	Gizmos::addAABBFilled(glm::vec3(0, 0, 0), glm::vec3(500, 0, 500),glm::vec4(0.3,0.3,0.8,1));

    m_camera.update(1.0f / 60.0f);

	UpdatePhysX(m_delta_time);

	renderGizmos(g_PhysicsScene);

	shootTimer += m_delta_time;

	if (glfwGetKey(m_window, GLFW_KEY_SPACE) == GLFW_PRESS && shootTimer >= shootTimeOut)
	{
		shootTimer = 0;
		Shoot();
	}

    return true;
}
Beispiel #17
0
OneBitRleImageView* extract(const T &src, int ex_type)
{
typedef typename T::value_type value_type;
int x,y;

OneBitRleImageData* dest_data = new OneBitRleImageData(src.size(), src.origin());
OneBitRleImageView* dest = new OneBitRleImageView(*dest_data);
OneBitPixel blackval = black(*dest);
OneBitPixel whiteval = white(*dest);

ex_type = VIGRA_CSTD::pow(2.0,(ex_type));

for (y = 0; y < (int)src.nrows(); y++)
    for (x = 0; x < (int)src.ncols(); x++) {
        if (src.get(Point(x,y))==ex_type)
            dest->set(Point(x,y),blackval);
        else
            dest->set(Point(x,y),whiteval);
    }
return dest;
}
Beispiel #18
0
Color3 Material::texture_lookup(Vector2 texCoord) const
{
    if (tex_data && tex_width && tex_height) { 
        int i = floor(texCoord.x*tex_width); 
        int j = floor(texCoord.y*tex_height);
        float u = texCoord.x*tex_width - i; 
        float v = texCoord.y*tex_height - j;
        u = 3*u*u - 2*u*u*u; 
        v = 3*v*v - 2*v*v*v;
        Color3 c1 = (1-u)*(1-v)*get_texture_pixel(i%tex_width, j%tex_height); 
        Color3 c2 = u*(1-v)*get_texture_pixel((i+1)%tex_width, j%tex_height); 
        Color3 c3 = (1-u)*v*get_texture_pixel(i%tex_width, (j+1)%tex_height); 
        Color3 c4 = u*v*get_texture_pixel((i+1)%tex_width, (j+1)%tex_height);
        Color3 tex_color = c1 + c2 + c3 + c4; 
        return tex_color; 
    } 

    Color3 white(1.0, 1.0, 1.0); 
    return white;

}
void Application::GenerateGrid(int _size)
{
	assert(_size > 0 && "Needs to be a positive size"); //program will terminate if false

	Gizmos::addTransform(glm::mat4(1));
	glm::vec4 white(1);
	glm::vec4 black(0, 0, 0, 1);

	int halfSize = _size / 2;

	for (int i = 0; i < _size + 1; ++i)
	{
		Gizmos::addLine(glm::vec3(-halfSize + i, 0, halfSize),
						glm::vec3(-halfSize + i, 0, -halfSize),
						i == halfSize ? white : black);

		Gizmos::addLine(glm::vec3(halfSize, 0, -halfSize + i),
						glm::vec3(-halfSize, 0, -halfSize + i),
						i == halfSize ? white : black);
	}
}
Beispiel #20
0
void CurrentApp::ForwardDraw(float dt)
{
	m_particleEmitter->renderParticles();

	//Draw Stuffs here
	vec4 white(1, 1, 1, 1);
	vec4 black(0, 0, 0, 1);

	//Draw a Grid
	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);
	}

	m_skybox->Render(dt, &m_camera->GetProjection(), m_camera->GetView());

	m_renderer->Render(m_camera, dt, CurrentTime());

	Gizmos::draw(m_camera->GetProjectionView());
	Gizmos::clear();
}
Beispiel #21
0
void start_note(NOTE*           self,
                WAVESOURCE* waves,
                unsigned char   velocity,
                uint32_t        start_frame,
                float           harmonic_gain[],
                unsigned short  harmonics, 
                float           width,
                float           envelope[])
{
    unsigned char i;
    self->velocity = (float)velocity/127;//currently linear which is lame
    self->start_frame = start_frame;
    self->release_frame = 0;
    self->sus = 0;

    //harmonics
    self->nframes_since_harm_change = 0;
    self->cells = harmonics;
    for(i=0;i<MAX_N_HARMONICS;i++)
    {
        self->harm_gain[i] = self->velocity*harmonic_gain[i];
        self->harmonic[i] = harmonics&(1<<i);
        self->fwidth[i] = myPow2(width*white(waves,0,0)); 
    }
    //and the root
    i = MAX_N_HARMONICS;
    self->harm_gain[i] = self->velocity*harmonic_gain[i];
    //self->phase[i] = 0;

    //envelope
    //self->env_gain = 0;
    self->env_state = ENV_ATTACK;
    self->note_dead = false;
    for(i=0;i<6;i++)
        self->envelope[i] = envelope[i];

    //modulations
    self->amod_phase = 0;
    self->fmod_phase = 0;
}
void APP_OBJLoader::Draw()
{
	Gizmos::clear();
	Gizmos::addTransform(glm::mat4(1));

	vec4 white(1);
	vec4 black(0, 0, 0, 1);

	//	draws the home grid
	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);
	}

	drawObj();

	Gizmos::draw(GameCam->GetProjectionView());
}
Beispiel #23
0
static QGLMaterial *qCreateFluid()
{
    QImage image(QSize(128,128), QImage::Format_ARGB32);
    QRgb col = qRgba(rval(), rval(), rval(), 196);
    image.fill(col);
    QPainter painter(&image);
    QLinearGradient linearGrad(QPointF(56, 56), QPointF(72, 72));
    linearGrad.setColorAt(0, col);
    linearGrad.setColorAt(1, QColor(col).lighter());
    linearGrad.setSpread(QGradient::ReflectSpread);
    painter.fillRect(image.rect(), linearGrad);
    painter.end();
    QGLMaterial *mat = new QGLMaterial;
    QColor white(Qt::white);
    white.setAlpha(128);
    mat->setAmbientColor(white);
    mat->setDiffuseColor(white);
    QGLTexture2D *tex = new QGLTexture2D(mat);
    tex->setImage(image);
    mat->setTexture(tex);
    return mat;
}
Beispiel #24
0
bool ImageItem::reload()
{
    // destroy the old image instance
    clearPage();

    //qDebug("Begin Load Image %s!\n", name().toStdString().c_str());
    // Reconstruct the image by key
    if (name() == EMPTY_BACKGROUND)
    {
        data_.reset(new QImage(EMPTY_BACKGROUND_WIDTH,
                               EMPTY_BACKGROUND_HEIGHT,
                               QImage::Format_ARGB32));
        QColor white(255, 255, 255);
        data_->fill(white.rgba());
    }
    else
    {
        data_.reset(new QImage(name()));
    }
    //qDebug("End Load Image! %s\n", name().toStdString().c_str());

    if (data_->isNull())
    {
        // if the image is broken, display the warning map
        data_->load(":/images/invalid.png");
    }

    private_info_.reset();
    dirty_    = false;
    actualSize() = data_->size();

    // reset the render setting
    // TODO. Use default rotation value
    RenderSetting setting;
    setting.setContentArea(QRect(0, 0, actualSize().width(), actualSize().height()));
    setting.setRotation(ROTATE_0_DEGREE);
    setRenderSetting(setting);
    return true;
}
Beispiel #25
0
int
main()
{
  typedef agg::pixfmt_bgr24 pixel_type;
  
  const unsigned w = 60, h = 50;
  
  unsigned row_size = pixel_type::pix_width * w;
  unsigned buf_size = row_size * h;
  agg::pod_array<unsigned char> img_buf(buf_size);
  
  agg::rendering_buffer rbuf(img_buf.data(), w, h, app_flip_y ? -row_size : row_size);
  pixel_type pixf(rbuf);
  
  typedef agg::renderer_base<pixel_type> renderer_base;
  typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;

  renderer_base rb(pixf);
  renderer_solid rs(rb);
  
  agg::rasterizer_scanline_aa<> ras;
  agg::scanline_p8 sl;

  agg::rgba8 white(255, 255, 255);
  rb.clear(white);

  agg::rgba8 color(160, 0, 0);

  agg::ellipse shape(30.0, 25.0, 12.0, 12.0);
  
  ras.add_path(shape);
  rs.color(color);
  agg::render_scanlines(ras, sl, rs);
  
  save_image_file(rbuf, "output.ppm");
  
  return 0;
}
int main(int argc, char *argv[])
{
    PNMreader reader(argv[1]);

    Crop crop;
    crop.SetRegion(300, 1400, 50, 400);
    crop.SetInput(reader.GetOutput());

    Transpose t;
    t.SetInput(crop.GetOutput());

    Invert i;
    i.SetInput(t.GetOutput());

    Color color(50, 1101, 0, 0, 128);
    
    LRConcat lr;
    lr.SetInput(color.GetOutput());
    lr.SetInput2(i.GetOutput());

    Color white(401, 1101, 255, 255, 255);

    Checkerboard cb;
    cb.SetInput(lr.GetOutput());
    cb.SetInput2(white.GetOutput());

    cb.GetOutput()->Update();

    PNMwriter writer;
    writer.SetInput(cb.GetOutput());
    writer.Write(argv[2]);

    CheckSum cs;
    cs.SetInput(cb.GetOutput());
    cs.OutputCheckSum();
    Logger::Finalize();
}
Beispiel #27
0
osgToy::TetraStrip::TetraStrip()
{
    osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() );

    osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() );
    setNormalBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() );
    setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec3 ppp(  1,  1,  1);   osg::Vec4 white(1,1,1,1);
    osg::Vec3 nnp( -1, -1,  1);   osg::Vec4 blue(0,0,1,1);
    osg::Vec3 pnn(  1, -1, -1);   osg::Vec4 red(1,0,0,1);
    osg::Vec3 npn( -1,  1, -1);   osg::Vec4 green(0,1,0,1);
    osg::Vec3 ppn(  1,  1, -1);   osg::Vec4 yellow(1,1,0,1);
    osg::Vec3 pnp(  1, -1,  1);   osg::Vec4 magenta(1,0,1,1);
    osg::Vec3 nnn( -1, -1, -1);   osg::Vec4 black(0,0,0,1);
    osg::Vec3 npp( -1,  1,  1);   osg::Vec4 cyan(0,1,1,1);

#if 1
    vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white);
    vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue);
    vAry->push_back(pnn); nAry->push_back(pnn); cAry->push_back(red);
    vAry->push_back(npn); nAry->push_back(npn); cAry->push_back(green);
    vAry->push_back(ppp); nAry->push_back(ppp); cAry->push_back(white);
    vAry->push_back(nnp); nAry->push_back(nnp); cAry->push_back(blue);
#else
    vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow);
    vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta);
    vAry->push_back(nnn); nAry->push_back(nnn); cAry->push_back(black);
    vAry->push_back(npp); nAry->push_back(npp); cAry->push_back(cyan);
    vAry->push_back(ppn); nAry->push_back(ppn); cAry->push_back(yellow);
    vAry->push_back(pnp); nAry->push_back(pnp); cAry->push_back(magenta);
#endif

    addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) );
}
Beispiel #28
0
void
Bolt::Render(Video* video, DWORD flags)
{
	if ((flags & RENDER_ADDITIVE) == 0)
	return;

	if (visible && !hidden && video && life) {
		const Camera*  camera = video->GetCamera();

		Point head  = loc;
		Point tail  = origin;
		Point vtail = tail - head;
		Point vcam  = camera->Pos() - loc;
		Point vtmp  = vcam.cross(vtail);
		vtmp.Normalize();
		Point vlat  = vtmp * -width;
		Vec3  vnrm  = camera->vpn() * -1;

		vset.loc[0] = head + vlat;
		vset.loc[1] = tail + vlat;
		vset.loc[2] = tail - vlat;
		vset.loc[3] = head - vlat;

		vset.nrm[0] = vnrm;
		vset.nrm[1] = vnrm;
		vset.nrm[2] = vnrm;
		vset.nrm[3] = vnrm;

		ColorValue  white((float) shade, (float) shade, (float) shade);
		mtl.Ka = white;
		mtl.Kd = white;
		mtl.Ks = Color::Black;
		mtl.Ke = white;

		video->DrawPolys(1, &poly);
	}
}
Beispiel #29
0
void
Square::paint(QPainter& painter) {

    painter.setBrush(brush_);
    painter.setPen(pen_);

    std::vector<QPoint> plist = dynamics_->getPositionList();
    std::vector<QPoint>::iterator idx = plist.begin();
    QBrush black( QColor(0x33, 0x33, 0x33), Qt::SolidPattern);
    QBrush white( QColor(0xFF, 0xFF, 0xFF), Qt::SolidPattern);
    QBrush brush;

    while (idx != plist.end()) {
      painter.drawRect(idx->x() - bounds_.width()/2,
           idx->y() - bounds_.height()/2,
           bounds_.width(),
           bounds_.height());
      if (targeted_)
        brush = black;
      else
        brush = white;

      painter.setBrush(brush);
      int X0 = idx->x();
      int Y0 = idx->y();
      int W = bounds_.width()/3;
      int H = bounds_.height()/3;
      painter.setBrush(brush);
      painter.drawRect(X0 - W/2,
           Y0 - H/2,
           W,
           H);
      painter.setBrush(brush_);

      ++idx;
    }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QImage PoleFigureMaker::generatePoleFigureImage(const PoleFigureData& config)
{
  int imageWidth = config.imageSize[0];
  int imageHeight = config.imageSize[1];

  QImage image(imageWidth, imageHeight, QImage::Format_ARGB32_Premultiplied);


  QVector<float> xPoints = config.xData;
  QVector<float> yPoints = config.yData;
  int size = yPoints.size();

  QColor white(255, 255, 255, 255);
  QColor black(0.25 * 255, 0.2549 * 255, 0.7961 * 255, 255);
  image.fill(white.rgba()); // Fill all white
  QRgb black_Rgba = black.rgba();

  // Flip the pixels to black that came from the data xy coords
  for (int i = 0; i < size; ++i)
  {
    //    float xp = xPoints[i];
    //    float yp = yPoints[i];
    int xCoord = (xPoints[i] + 1) * imageWidth / 2;
    int yCoord = (yPoints[i] + 1) * imageHeight / 2;
    if (xCoord > imageWidth || yCoord > imageHeight)
    {
      qDebug() << "This is bad" << "\n";
    }
    image.setPixel(xCoord, yCoord, black_Rgba);
  }

  // Flip the image so the (-1, -1) is in the lower left
  image = image.mirrored(true, false);

  return paintImage(config.imageSize[0], config.imageSize[1], config.label, image);

}