All pastes #154249 Raw Edit

Miscellany

public text v1 · immutable
#154249 ·published 2006-08-30 08:07 UTC
rendered paste body
#include <iostream>
#include <string>
#include <cmath>
#include "GammaFonts.h"
using namespace std;
int len[10],a,i,j,k,l,m,row[10],rows=6,binar[10][8][72];
int element[8],width[10],mult;
int lines[10][8][20];
const int offset=0x20; 
string text[2];

void dec_bin(int); 

main ()
{

//text="123456789";
  text[0]="MICHAEL";
  text[1]="KALIGA :)";
   mult=8;
for (m=0; m<2; m++)
{
	len[m]=text[m].length();
	width[m]=len[m]*mult;
	cout <<"lenght " <<len[m]<<" width="<<width[m] <<endl;
}

for (m=0; m<2; m++)
for (i=0;i<len[m];i++)
{	
	
	
		if (text[m][i]<0)
		{
			if (text[m][i]=='&#260;') 	row[m]=0xA5-offset;
			if (text[m][i]=='&#262;') 	row[m]=0xC6-offset;
			if (text[m][i]=='&#280;') 	row[m]=0xCA-offset;
			if (text[m][i]=='&#321;') 	row[m]=0xA3-offset;
			if (text[m][i]=='&#323;')	row[m]=0xD1-offset;
			if (text[m][i]=='Ó') 	row[m]=0xD3-offset;
			if (text[m][i]=='&#346;')    row[m]=0x8C-offset;
			if (text[m][i]=='&#377;') 	row[m]=0x8F-offset;
			if (text[m][i]=='&#379;') 	row[m]=0xAF-offset;
		}
		else 
		row[m]=text[m][i]-offset;	

//cout<<text[i]<<"  ";

		for(j=0; j<8; j++) { lines[m][j][i]=gGammaFont6x6[row[m]][j]; 
		
		/*if (lines[j][i]>15) cout <<"0x"<<hex <<lines[j][i]<<",";
		else cout <<"0x0"<<hex <<lines[j][i]<<",";*/
		}
		//cout <<endl<<endl;
	
}
/*
for (i=0; i<rows; i++)
{
	for (j=0; j<len; j++)
	{
	
	if (lines[i][j] >15) cout << "0x"<<hex<<lines[i][j]<<",";
	else cout <<"0x0"<<hex<<lines[i][j]<<",";
	}
	cout <<endl;
}
//cout<<"wyswietlilem \"lines\""<<endl;
*/

for (m=0; m<2; m++)
for (i=0; i<rows; i++)
{
	for (k=0; k<len[m]; k++)
	{
		//cout<< "k ="<<k<<" ";
		//if (k==8) cout << lines[i][k];
		dec_bin(lines[m][i][k]);
		for (j=k*mult; j<k*mult+8; j++)
		{
			binar[m][i][j]=element[l];
			l++;
		}
		for (a=0; a<8; a++) element[a]=0;
		l=0;
		
		
	}
}	


cout<<endl<<"+";
for (i=0; i<36 ; i++)
cout << " -";
cout <<"  +"<<endl;
for (m=0; m<2; m++)
for (i=0; i<rows; i++)
{
	for (j=0; j<width[1]+1; j++)   // !! UWAGA - width[0] !!
	{
        /*if ( (i==0)&&(j==0) ) cout <<"+";*/
        if  ((i>0) && (j==0)) cout <<"|";
        if  ((m==0) && (i>0) && (j==width[1])) cout <<"                  |";
        if  ((m==1) && (i>0) && (j==width[1])) cout <<"  |";
        /*if ((i==0) && (j>0) && (j<38)) 
        {
                   if (j<37) cout <<"-";
                   else cout <<" +";
        }*/
		if (j<width[m]) 
           if (binar[m][i][j]==0) cout << " ";
		   else cout << "*";
	}
		cout <<endl;
}	
cout<<endl<<"+";
for (i=0; i<36 ; i++)
cout << " -";
cout <<"  +";
    
 //   cout <<lines[1][0];
    
     cin >>a;
}

void dec_bin(int dec)  
{
double wykl;
int f;
double dec_double;

dec_double=dec;

if (dec!=0)
{
	do
	{
		wykl=0;
		while( pow(2,wykl)< dec_double) 
		{
			wykl++;
		}
		if (pow(2,wykl)>dec_double) wykl--;
		dec_double=dec_double-pow(2,wykl);
		f=wykl;
		element[7-f]=1;
	} while (dec_double!=0);
}
	return;
}