Exemplo n.º 1
0
/* JPEG格式图片的扇形展开效果 */
void effect_jpeg_sector()
{
	int i, x, y;
	long r_max;
	double degree, degree_part, degree_part_tmp;
	unsigned char *buf_line, *tmp_buf_line;

	system("clear");

	buf_line = (unsigned char *)malloc(picture_w * picture_bits);
	buffer = (unsigned char *)malloc(picture_w * picture_h * picture_bits);
	memset(buffer, 0, picture_w * picture_h * picture_bits);

	/* 把图片每个像素的rgb值存入buffer中 */
	tmpbuf = buffer;
	for(i = 0; i < picture_h; i++)
	{
		tmp_buf_line = buf_line;
		memset(tmp_buf_line, 0, picture_w * picture_bits);
		jpeg_read_scanlines(&cinfo, &tmp_buf_line, 1);
		memcpy(tmpbuf + i * picture_w * picture_bits, tmp_buf_line, picture_w * picture_bits);
	}
	
	/* 从中心想边沿画图像 */
	r_max = sqrt(picture_h * picture_h + picture_w * picture_w) / 2;
	for(degree = 0 ; degree <= PI * 2; degree += PI / 180 / 25)
	{
		degree_part_tmp = PI / 2;
		for(degree_part = PI / 2; degree_part < PI * 3 / 2; degree_part += PI / 180 / 25)
		{
			draw_part(r_max, degree + degree_part);
			
			degree_part_tmp -= PI / 180 / 25;
			draw_part(r_max, degree + degree_part_tmp);
			
			usleep(100);
		}
		break;
	}
	
	free(buf_line);
	free(buffer);

	return;
}
Exemplo n.º 2
0
void dviRenderer::set_vf_char(unsigned int cmd, unsigned int ch)
{
#ifdef DEBUG_RENDER
    kDebug(kvs::dvi) << "dviRenderer::set_vf_char( cmd=" << cmd << ", ch=" << ch << " )";
#endif

    static unsigned char   c;
    macro *m = &currinf.fontp->macrotable[ch];
    if (m->pos == NULL) {
        kError(kvs::dvi) << "Character " << ch << " not defined in font " << currinf.fontp->fontname << endl;
        m->pos = m->end = &c;
        return;
    }

    long dvi_h_sav = currinf.data.dvi_h;

    struct drawinf oldinfo = currinf;
    currinf.data.w         = 0;
    currinf.data.x         = 0;
    currinf.data.y         = 0;
    currinf.data.z         = 0;

    currinf.fonttable         = &(currinf.fontp->vf_table);
    currinf._virtual          = currinf.fontp;
    quint8 *command_ptr_sav  = command_pointer;
    quint8 *end_ptr_sav      = end_pointer;
    command_pointer           = m->pos;
    end_pointer               = m->end;
    draw_part(currinf.fontp->scaled_size_in_DVI_units*(dviFile->getCmPerDVIunit() * 1200.0 / 2.54)/16.0, true);
    command_pointer           = command_ptr_sav;
    end_pointer               = end_ptr_sav;
    currinf = oldinfo;

    if (cmd == PUT1)
        currinf.data.dvi_h = dvi_h_sav;
    else
        currinf.data.dvi_h += (int)(currinf.fontp->scaled_size_in_DVI_units * dviFile->getCmPerDVIunit() *
                                    (1200.0 / 2.54)/16.0 * m->dvi_advance_in_units_of_design_size_by_2e20 + 0.5);
}
Exemplo n.º 3
0
static void *
draw_drop(void *arg)
{
    DATA mydata;
    int mystats;

    /*
     * Find myself in the list of threads so we can count the number of loops.
     */
    for (mystats = 0; mystats < MAX_THREADS; ++mystats) {
#if defined(__MINGW32__) && !defined(__WINPTHREADS_VERSION)
	if (drop_threads[mystats].myself.p == pthread_self().p)
#else
	if (drop_threads[mystats].myself == pthread_self())
#endif
	    break;
    }

    do {
	if (mystats < MAX_THREADS)
	    drop_threads[mystats].counter++;

	/*
	 * Make a copy of caller's data.  We're cheating for the cases after
	 * the first loop since we still have a pointer into the main thread
	 * to the data which it uses for setting up this thread (but it has
	 * been modified to use different coordinates).
	 */
	mydata = *(DATA *) arg;

	draw_part(part1, 0, &mydata);
	draw_part(part2, 1, &mydata);
	draw_part(part3, 2, &mydata);
	draw_part(part4, 3, &mydata);
	draw_part(part5, 4, &mydata);
	draw_part(part6, 0, &mydata);
    } while (get_next_drop());

    return NULL;
}
Exemplo n.º 4
0
void draw_logo(void)
{
    float left_start = -20.0;
    float f_width = 7.2;
    float l_width = 4.3;
    float a_width = 6.6;
    float t_width = 3.7;
    float n_width = 6.6;
    float d_width = 6.6;
    float position;
    char flatland[] = "flatland";
    int i; 
    char tmp;

    
#ifdef TYPEO
	if( swap_position>=0 && swap_position<8 )
	{ 
	    tmp = flatland[swap_position];
	    flatland[swap_position] = flatland[swap_position+1];
	    flatland[swap_position+1] = tmp;
    	}
#endif
	        
	glEnable(GL_CULL_FACE);

    	glPushMatrix( );
	
    	glTranslatef(1.0, -5.0, 0.0);

    	glPushMatrix( );
        glRotatef(15.0, 1.0, 0.0, 0.0);
	draw_part(0);
    	glPopMatrix( );
    	
    	groen_texture();

    	position = left_start;

    	for( i=0; i<8; i++ )
	{
    	    switch( flatland[i] )
	    {
	    case 'f':
    		// width of F = 7.2
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef(-20.0, 4.3, 5.0);
		draw_part(1);
    		glPopMatrix( );
    		position += f_width;
    	    	break;

    	    case 'l':
		//width of l = 4.3
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef(-12.8, 4.3, 5.0);
	//	glTranslatef(7.2, 0.0, 0.0);
		draw_part(2);
    		glPopMatrix( );
    		position += l_width;
    	    	break;
		
	    case 'a':
    		// width of a = 4.7
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef( left_start, 4.3, 5.0);
	//	glTranslatef(-8.5, 4.3, 5.0);
	//	glTranslatef(4.3, 0.0, 0.0);
		draw_part(3);
    		glPopMatrix( );
    		position += a_width;
    	    	break;
		
	    case 't':
    		// width of t = 3.7
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef(-3.8, 4.3, 5.0);
	//	glTranslatef(4.7, 0.0, 0.0);
		draw_part(4);
    		glPopMatrix( );
    		position += t_width;
    	    	break;
		
//    		// width of l = 4.3
//    		glPushMatrix( );
//		glTranslatef( position, 4.3, 5.0);
//	//	glTranslatef(-0.1, 4.3, 5.0);
//	//	glTranslatef(3.7, 0.0, 0.0);
//		draw_part(5);
//    		glPopMatrix( );
//    		position += l_width;
//    	    	
//    		// width of a = 6.6
//    		glPushMatrix( );
//		glTranslatef( position, 4.3, 5.0);
//	//	glTranslatef(4.2, 4.3, 5.0);
//	//	glTranslatef(4.3, 0.0, 0.0);
//		draw_part(6);
//    		glPopMatrix( );
//    		position += a_width;
    	    	
	    case 'n':
    		// width of n = 6.6
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef(10.8, 4.3, 5.0);
	//	glTranslatef(6.6, 0.0, 0.0);
		draw_part(7);
    		glPopMatrix( );
    		position += n_width;
    	    	break;
		
	    case 'd':
    		// width of d = 6.6
    		glPushMatrix( );
		glTranslatef( position, 4.3, 5.0);
	//	glTranslatef(17.4, 4.3, 5.0);
	//        glTranslatef(6.8, 0.0, 0.0);
        	draw_part(8);
    		glPopMatrix( );
    		position += d_width;
		break;
		
	    default:
	    	break;
	    }
    	}
    	glPopMatrix( );
}
Exemplo n.º 5
0
template <typename M> void MatchT<M>::draw(const std::string& _drawMode) const
{
    // Draw points
    if(displayMode_ & POINTS)
    {
        typename std::vector<MeshPoint>::const_iterator itPoint(points_.begin()), itEnd(points_.end());
        
        for (; itPoint != itEnd; ++itPoint)
        {
            draw_point(*itPoint);
        }
    }

    // draw mesh
    if(displayMode_ & MESH)
    {
        glDisable(GL_BLEND);
        glEnable(GL_LIGHTING);
        glShadeModel(GL_SMOOTH);

        glPushMatrix();
        
        if (!disableAlignmtx_)
        {
            glMultMatrixd(alignMtx_);
        }
       
        if(!segmented_)
        {
            if(ShapeT<M>::isMeshOpen())
            {
                ShapeT<M>::draw(_drawMode);
            }
        }
        else
        {
            if(selectedPartID_ >=0)
            {
                // A specific part is chosen, so draw it
                const Part& cPart = parts_.at(selectedPartID_);
                // part ids start from 2, so subtract 2, but just in case, check it's not smaller than 0
                int col = cPart.partID_-2;
                
                if(col<0)
                {
                    col = 0;
                }
                // Draw all parts with the same color if colorOverride is true
                if (colorOverride_)
                {
                    col = 1;
                    
                    // If all parts are being drawn in the same color and this part is hovered, draw only this part in red
                    if(hoveredPartID_>=0 && cPart.partID_ == hoveredPartID_)
                    {
                        col = 0;
                    }
                }
                
                OpenMesh::Vec4f color(shapeColors[col][0],shapeColors[col][1],shapeColors[col][2],shapeColors[col][3]);
                
                int _f=GL_FRONT_AND_BACK, _m=GL_DIFFUSE;
                
                glMaterialfv(_f, _m, &color[0]);
                
                cPart.partShape_.draw(_drawMode);
            }
            else
            {
                typename std::vector<Part>::const_iterator itPart(parts_.begin()), itEnd(parts_.end());
                
                for (; itPart != itEnd; ++itPart)
                {
                    if(itPart->partType_!=0)
                    {
                        // part ids start from 2, so subtract 2, but just in case, check it's not smaller than 0
                        int col = itPart->partID_-2;
                        
                        if(col<0)
                        {
                            col = 0;
                        }
                        // Draw all parts with the same color if colorOverride is true
                        if (colorOverride_)
                        {
                            col = 1;
                            
                            // If all parts are being drawn in the same color and this part is hovered, draw only this part in red
                            if(hoveredPartID_>=0 && itPart->partID_ == hoveredPartID_)
                            {
                                col = 0;
                            }
                        }
                        OpenMesh::Vec4f color(shapeColors[col][0],shapeColors[col][1],shapeColors[col][2],shapeColors[col][3]);
                        
                        int _f=GL_FRONT_AND_BACK, _m=GL_DIFFUSE;
                        
                        glMaterialfv(_f, _m, &color[0]);

                        itPart->partShape_.draw(_drawMode);
                    }
                }
            }
        }
        
        glPopMatrix();
    }
    
    
    // draw boxes
    if(displayMode_ & BOX)
    {
        glEnable(GL_BLEND);
        glDisable(GL_LIGHTING);
        glShadeModel(GL_SMOOTH);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        
        // Draw template boxes
        if(selectedPartID_ >=0)
        {
            // A specific part is chosen, so draw it
            const Part& cPart = parts_.at(selectedPartID_);
            draw_part(cPart);
        }
        else
        {
            typename std::vector<Part>::const_iterator itPart(parts_.begin()), itEnd(parts_.end());
            
            for (; itPart != itEnd; ++itPart)
            {
                draw_part(*itPart);
            }
        }
    }

    
}
Exemplo n.º 6
0
void dviRenderer::draw_page()
{
    // Reset a couple of variables
    HTML_href         = 0;
    source_href       = 0;
    penWidth_in_mInch = 0.0;

    // Calling resize() here rather than clear() means that the memory
    // taken up by the vector is not freed. This is faster than
    // constantly allocating/freeing memory.
    currentlyDrawnPage->textBoxList.resize(0);

    RenderedDviPagePixmap* currentDVIPage = dynamic_cast<RenderedDviPagePixmap*>(currentlyDrawnPage);
    if (currentDVIPage)
    {
        currentDVIPage->sourceHyperLinkList.resize(0);
    }

#ifdef PERFORMANCE_MEASUREMENT
    // If this is the first time a page is drawn, take the time that is
    // elapsed till the kdvi_multipage was constructed, and print
    // it. Set the flag so that is message will not be printed again.
    if (performanceFlag == 0) {
        kDebug(kvs::dvi) << "Time elapsed till the first page is drawn: " << performanceTimer.restart() << "ms";
        performanceFlag = 1;
    }
#endif


#ifdef DEBUG_RENDER
    kDebug(kvs::dvi) <<"draw_page";
#endif

#if 0
    if (!accessibilityBackground)
    {
#endif
        foreGroundPainter->fillRect( foreGroundPainter->viewport(), PS_interface->getBackgroundColor(current_page) );
#if 0
    }
    else
    {
        // In accessiblity mode use the custom background color
        foreGroundPainter->fillRect( foreGroundPainter->viewport(), accessibilityBackgroundColor );
    }
#endif

    // Render the PostScript background, if there is one.
    if (_postscript)
    {
#if 0
        // In accessiblity mode use the custom background color
        if (accessibilityBackground)
        {
            // Flag permanent is set to false because otherwise we would not be able to restore
            // the original background color.
            PS_interface->setBackgroundColor(current_page, accessibilityBackgroundColor, false);
        }
        else
#endif
            PS_interface->restoreBackgroundColor(current_page);

        PS_interface->graphics(current_page, resolutionInDPI, dviFile->getMagnification(), foreGroundPainter);
    }

    // Now really write the text
    if (dviFile->page_offset.isEmpty() == true)
        return;
    if (current_page < dviFile->total_pages) {
        command_pointer = dviFile->dvi_Data() + dviFile->page_offset[int(current_page)];
        end_pointer     = dviFile->dvi_Data() + dviFile->page_offset[int(current_page+1)];
    } else
        command_pointer = end_pointer = 0;

    memset((char *) &currinf.data, 0, sizeof(currinf.data));
    currinf.fonttable      = &(dviFile->tn_table);
    currinf._virtual       = 0;

    double fontPixelPerDVIunit = dviFile->getCmPerDVIunit() * 1200.0/2.54;

    draw_part(65536.0*fontPixelPerDVIunit, false);
    if (HTML_href != 0) {
        delete HTML_href;
        HTML_href = 0;
    }
    if (source_href != 0) {
        delete source_href;
        source_href = 0;
    }
}