コード例 #1
0
ファイル: Graphics.cpp プロジェクト: yerg/Snake2
Image* Graphics::NewImage(std::wstring &text, SDL_Color &color, bool fast){
	std::basic_string<Uint16> utext (text.begin(),text.end());
	SDL_Surface* tmp = fast ? TTF_RenderUNICODE_Solid(font, utext.c_str(), color) : TTF_RenderUNICODE_Blended(font, utext.c_str(), color);
	if( tmp == NULL ) std::cout << std::endl << "Unable to render text surface! SDL_ttf Error: " << TTF_GetError();
	Image* image = new Image();
	image->texture = SDL_CreateTextureFromSurface(renderer, tmp);
	image->h=tmp->h;
	image->w=tmp->w;
	SDL_FreeSurface(tmp);
	return image;
}
コード例 #2
0
ファイル: sucqgraph.c プロジェクト: JOravetz/SeisUnix
void subplot(float *data, int nt, int nx, string title,
	string label1, string label2, float truemax, float max)
{
	int i,plotfat,axisfat,dtict,ntict,nticx;
	float sizet,sizex,scalet,scalex,zerot,zerox,margint,marginx,dticx;
	float dash,gap,truedticx,xmin,dx;
	int titlsz,lablsz,ticsz,hcopy,dashflag;
	char tval[8];		/* tic value string			*/

	zerot = 0.5;		fgetpar("zerox",&zerot);
	zerox = 1.0;		fgetpar("zeroy",&zerox);

	sizet = 8.0;		fgetpar("sizex",&sizet);
	sizex = 5.0;		fgetpar("sizey",&sizex);

	dashflag = 0; 		igetpar("dash",&dashflag);

	nticx = 1; 		igetpar("nticy",&nticx);
	ntict = 5;		fgetpar("nticx",&ntict);

	dtict = nt/ntict;
	if (dtict>10) dtict -= dtict%10;
	igetpar("dticx",&dtict);

	margint = 0.01;		fgetpar("marginx",&margint);
	marginx = 0.04;		fgetpar("marginy",&marginx);

	ticsz = 3;		igetpar("ticsz",&ticsz);

	hcopy = 0;		igetpar("hcopy",&hcopy);
	if ( hcopy == 1 ) {
		sizet=4.5; 
		sizex=3.5;
		ticsz=2;
	}

	scalet = sizet/nt;	
	scalex = 0.5*sizex;
	setscl(scalet,scalex);
	set0(zerot, zerox + 0.5*sizex );
	setfat(axisfat);


	/* ZERO LINE*/
	setcol(3);  
	umove( 0.0,         0.0 );
	udraw( (float)nt,   0.0 );

	/* Amplitude tics */

	dticx = max/nticx;
	truedticx = truemax/nticx;

	
	for ( i = -nticx ; i <= nticx ; i++ ) {
		umove( (float)nt , i*dticx  / max );
		udraw( (1.0 + margint) * nt, i*dticx / max ); 
		sprintf( tval, "%.3g", i*truedticx );
		utext( (1.0 + 2*margint) * nt, i*dticx / max , ticsz, 0, tval);
	}


	/* DRAW N2 WIGGLE TRACES */
	for ( i = 0 ; i < nx ; i++ ) {
		if ( dashflag ) {
			dash = ( i % 6 ) * .05;
			gap = dash;
			if ( dash ) {
				setdash(dash,gap,dash,gap);
			}
		}
	 	setcol(6 - i % 6); 
		wgl1( data + nt*i, nt); 
	}
}