بسم الله الرحمن الرحيم
السلام عليكم جميعاً إخوتي
بعد البداية الشاقة والحمد لله وصلت إلى نقطة الصفر .. وبعد أن بدأت بتطبيق ما قرأته عن الصفوف classes اكتشفت أنني أصبحت الآن ""مبتدئاّ"
ويبدو أن الطريقة الوحيدة للارتقاء دوماً ... هي الارتقاء الجماعي . وهو ما عاينتموه حضراتكم في هذا المنتدى ..
بعد خمس ساعات من قراءة مواضيع في هذا القسم .. تأكدت أن google كان على حق عندما كانت النتيجة كما يلي :
بارك الله فيكم .. وأسأل الله أن أستفيد منكم ما شاء الله لي أن أستفيد ...
وحتى لا أكون سلبياً (متلقي فقط ) أرغب من بعد إذنكم في الاستفسار عن أمر مهم .. ((لمن بحث في مواضيع اللينكس يعرف أن السبب الرئيس في تطوير كل الأنظمة المفتوحة هو أن المصدر متوفر للجميع وكل واحد يدلي بدلوه , ولذلك حبّذا لو نبدأ في تطوير برنامج نضع فيه كل ما تعلمناه ))
وكمبادرة .. فقد استغرق معي تحويل بيئة الدوس الجامدة إلى بيئة شبه رسومية ذات بعدين حوالي 96 ساعة من العمل , وتم إنجاز برنامج رسم باستخدام الأسهم , كما أنه يرسم الأشكال المعروفة كالدائرة والمستقيم والمستطيل ..
أرجو منكم الدعاء .. وأهدي البرنامج ....... لا داعي لهذه الفقرة ..
إليكم البرنامج وبإذن الله يعجبكم و نتعاون فيه .. ... إليكم البرنامج ( جربوه .. ثم خرّبوه)
ملاحظة أخيرة :: انسخ البرنامج .. نفّذه ... عندما يبدأ العمل اضغط رقم صفر لتحصل على التعليمات كاملة ... الحقوق محفوظة لكم ..
/////////////////Drown VER 1.0\\\\\\\\\\Thank for God only\\\\\\\\*/
#include<iostream.h>
#include<windows.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#define Y 56
#define X 80
/////////////////////////////
class M{public:M();
inline void S_O();//Screen Out
inline void S_fO();//screen file Out
inline void S_S();//Screen Set
inline void Sq();//Square
inline void EC();//enter coordinates
inline void N();//N:allocate the move side
inline void a_();//allocate the button pressed
inline void sqsomain();//Ec Sq S_O main_;
inline void main_();//main;
inline void line_();
inline void circle_();
inline void rectangle_();
inline void line(double,double,double,double,int);
inline void circle(double,double,double,int);
inline void rectangle(int,int,int,int);
private:
char screen[Y][X],c,c2;int x,y,L,step,b,a;};
/////some time /////cleer screen /////pause////////////////
void st(double i=1){for(int j=0;j<1250*i;j++)cout<<1<<"\r";}
void cls(){system("cls");st();}
void paus(){system("pause");}
//////////////////
void M::rectangle_(){int x1,y1,x2,y2;
cout<<"Drawing a rectangle \ntow point P1,P2 for the corners\nx1=";cin>>x1;x1+=2;cout<<"y1=";cin>>y1;
cout<<"x2=";cin>>x2;x2+=2;cout<<"y2=";cin>>y2;rectangle(x1,y1,x2,y2);}
//////////////////
double linefx(double m_,double x,double x1,double y1){double y=(m_*x)-(m_*x1)+y1;return y;}
double linef_y(double m_,double y,double x1,double y1){double x=((y-y1)/m_)+x1;return x;}
////////////////*//////////////////
void M::circle_(){
double x0,y0,r;int e0=3;
cout<<"enter the center coordinates: x0=";cin>>x0;x0+=2;
cout<<"y0=";cin>>y0;cout<<"r=";cin>>r;if(r>9)e0=7;if(r>19)e0=10;if(r>29)e0=15;
circle(x0,y0,r,e0);}
///////////////circle////////////////////
void M::circle(double x0,double y0,double r,int e0){
for(double j=y0-r;j<=y0+r;j++)
for(double i=x0-r;i<=x0+r;i++)
for(int e=-1*e0;e<=e0;e++){
if(int((j-y0)*(j-y0)+(i-x0)*(i-x0))==int(r*r)+e)screen[int(j)][int(i)]=c;
//if(int((j-y0)*(j-y0)+(i-x0)*(i-x0))>int(r*r)+e) screen[int(j)][int(i)]='o';
//if(int((j-y0)*(j-y0)+(i-x0)*(i-x0))<int(r*r)+e)screen[int(j)][int(i)]='M';
//if(int((j-y0+(r/4))*(j-y0+(r/4))/36+(i-x0-(r/2))*(i-x0-(r/2))/16)<1) screen[int(j)][int(i)]=1;
//if(int((j-y0+(r/4))*(j-y0+(r/4))/36+(i-x0+(r/2))*(i-x0+(r/2))/16)<1) screen[int(j)][int(i)]=2;
//if(int(-(i-x0)*(i-x0)/(r/4))+(j-y0)*(j-y0)/(r/5)==1) screen[int(j)][int(i)]=3;
/*if(int((j-y0-r)+(i-x0)*(i-x0)/16)==-1) screen[int(j)][int(i)]=3;*/}}
////////////////////rectangle////////////////////////////
void M::rectangle(int x1,int y1,int x2,int y2)
{int minx=x1,miny=y1,maxx=x2,maxy=y2;if(x2<x1){maxx=x1;minx=x2;}if(y2<y1){maxy=y1;miny=y2;}
for(int i=minx;i<=maxx;i++)for(int j=miny;j<=maxy;j++){
if(i==x1||i==x2||j==y1||j==y2){screen[j]=c;}
}}
////////////////////////////////////////////////
void M::line(double x1,double y1,double x2,double y2,int pp=1)
{ double minx=x1,maxx=x2,miny=y1,maxy=y2;
if(y1>y2){maxy=y1;miny=y2;}
if(x1>x2){maxx=x1;minx=x2;}
if(x2!=x1) {
double m_=(y2-y1)/(x2-x1);
for(double i=minx+2;i<=maxx+2;i++)screen[int(linefx(m_,i-2,x1,y1))][int(i)]=c;
if(pp=='2')for(double j=miny;j<=maxy;j++)screen[int(j)][int(linef_y(m_,j,x1,y1))+2]=c;}
else for(double j=miny;j<=maxy;j++)screen[int(j)][int(x1)]=c;
}
//////////////////////////
void M::line_()
{double x1,x2,y1,y2;char a[3];
cout<<"To draw a line we want tow points P1(x1,y1),P2(x2,y2)\n";
cout<<"So For P1(x1,y1) :: \nx1= ";cin>>x1;
cout<<" y1= ";cin>>y1;
cout<<"and For P2(x2,y2) :: \nx2= ";cin>>x2;
cout<<" y2= ";cin>>y2;
cout<<"Wich mode:1 or 2 ?";
cin>>a;
line(x1,y1,x2,y2,a[0]);}
//////////////////////yes//////////////////////////////
int yes(){return((getche()=='y'&&getche()=='e'&&getche()=='s')?1:0);}
//////////////////showxy///////
void showxy(int x,int y){char msg[11]={"x= ,y= ."};
msg[3]=char(x%10+48);
msg[2]=char((x-x%10)/10+48);
msg[8]=char(y%10+48);msg[7]=char((y-y%10)/10+48);
MessageBox(NULL,msg,"Coordinates",64);}
//////////////////////////////////////////
void pause(){system("pause");}
////////////////////////////////Help//////////////
void help()
{
cls();
cout<<"Welcome \noptions available here are :\n1- Space to change x,y"
<<"\n2- Enter to change x,y,your square side length(L/2),the drawing\ncharachter and step "
<<"\n3- Tab to change the drawing charachter"
<<"\n4- Back space to use the eraser , then press tab to return\nto the bruch tool"
<<"\n5- X to show x and y"
<<"\n6- Escape to save your picture"
<<"\n7-numbers:\n\t 1:to change bruch mode \n\t 2:to reset,then just type yes \n\t 3:to change step\n\t 4: to change (L/2)"
<<"\n\t 7: Drow a rectangle any where\n\t 8:Drow a circle any where \n\t 9: Drow a line any where"
<<"\n\t\t 0:for help"
<<"\nEnjoy\n";st(10);paus();cls();
}
//////////////////////a_////////////////////
void M::a_()
{ a=getch();
if(a==224){a=getch();N();}
else if(a==8)c=c2;
else if(a==9){cout<<"enter the charachter";cout.flush();a=getch();if(a=='2')c=char(219);else c=a;}
else if(a==13){EC();sqsomain();}
else if(a==27)S_fO();
else if(a==32){cout<<"Enter new x,y\nx=";cin>>x;x+=2;if(x<2)x=40;cout<<"y=";cin>>y;if(y<0)y=27;}
else if(a==48){help();}
else if(a==49){cout<<"Welcome :what the mode you want sur?0,1,2,3,4\n";cin>>b;}
else if(a==50){cout<<"Restart?";cout.flush();if(yes()){cout<<"\nbackground charachter";cin>>c2;S_S();}}
else if(a==52){cout<<"new L:";cin>>L;}
else if(a==51){cout<<"enter the step";cin>>step;}
else if(a==57)line_();
else if(a==56)circle_();
else if(a==55)rectangle_();
else if(a==120){showxy(x,y);}
}
///////////////////////////Screen Out//////////////////
void M::S_O(){cls();for(int c0=0;c0<Y;c0++){for(int c1=0;c1<X;c1++){cout<<screen[c0][c1];}cout<<"\r";}st();}
///////////////////////////Screen fOut//////////////////
void M::S_fO(){
MessageBox(NULL,"enter yor file name please ","Saving",1);
char name[20];char txt[]={".txt"};
cin>>name;
strcat(name,txt);
reinterpret_cast<const char*>(name);
ofstream outfile(name,ios::out);
outfile<<"#include<iostream.h>"<<endl<<"#include<windows.h>"<<endl<<"void main(){cout";
for(int c0=0;c0<Y-2;c0++){outfile<<"<<\"";
for(int c1=2;c1<X;c1++){
outfile<<screen[c0][c1];}outfile<<"\\n\""<<endl;}
outfile<<";system(\"pause\");}";outfile.close();system(name);}
////////////////////////////Screen Set///////////////////
void M::S_S(){
for(int c0=0;c0<56;c0++){
for(int c1=0;c1<X;c1++){
if(c1==0&&c0<Y-2)screen[c0][c1]=(c0-c0%10)/10+48;
else if(c1==1&&c0<Y-2)screen[c0][c1]=c0%10+48;
else if(c0==Y-2&&c1>1)screen[c0][c1]=(c1-2)%10+48;
else if(c0==Y-1&&c1>1)screen[c0][c1]=((c1-2)-(c1-2)%10)/10+48;
else screen[c0][c1]=c2;}}}
/////////////////////////////////Main///////////////
void main(){M ohammad;ohammad.sqsomain();}
//////////////////////////////////M()///////////////
M::M(){system("color f0");c='0';x=39;y=27;L=0;step=1;b=1;a=0;c2='.';S_S();S_O();}
//////////////////////square....screen out.....main_/////////////
void M::sqsomain(){Sq();S_O();main_();}
/*main_:a_ to get ch and analyze it
* square to draw square
* screen out
* main_ to repeat the operation
*/
void M::main_(){a_();Sq();S_O();main_();}
//////t/h/e////m/o/s/t///i/m/p/o/r/t/a/n/t////f/u/n/c/t/i/o/n////
//////////////////////////////Square/////////////////////////////////
void M::Sq()
{
for(int c0=y-L;c0<=y+L;c0++){
for(int c1=x-L;c1<=x+L;c1++){
if(c0<0||c1<2)continue;
if(c0>Y-3||c1>X-1)continue;if(b!=0&&b!=1&&b!=2&&b!=3&&b!=4)b=0;
/*All the surface screen*/ if(b==0)screen[c0][c1]=c;
/*Only the perimeterif*/ else if(b==1&&(c0==y-L||c0==y+L||c1==x-L||c1==x+L))screen[c0][c1]=c;
/*the perimeter and X in the shape*/else if(b==2){if(c0==y-L||c0==y+L||c1==x-L||c1==x+L)screen[c0][c1]=c;
else if(c1-c0==x-y||c1+c0==y+x)screen[c0][c1]=c;}
/*Xin the shape*/ else if(b==3){if(c1-c0==x-y||c1+c0==y+x)screen[c0][c1]=c;}
/*the surface without the center*/ else if(b==4){if(c0!=y||c1!=x)screen[c0][c1]=c;else screen[c0][c1]=c2;}}}
}
/////////////////////N///////////EC//////////
void M::N(){if(a==77) x+=step;else if(a==80) y+=step;else if(a==72) y-=step;else if(a==75) x-=step;}
void M::EC(){ char yesorno[5];cout<<"Do you wonna enter the coordinates?";cin>>yesorno;
if(yesorno[0]!='n'){cout<<"enter the coordinates of the center\n x=";cin>>x;x+=2;if(x<2)x=40;
cout<<"y=";cin>>y;if(y<0)y=27;
cout<<"enter the side length of the Sq:\n L=";cin>>L;if(L<0)L=0;
cout<<"Enter the charachter you wonna drow by:";cin>>yesorno;c=yesorno[0];
cout<<"Enter step\nstep=";cin>>step;cls();}else cls();}
/////////////////////////////////////////
/*
void choose
{int choose_=1;
cout<<"Choose the shape ypu wonna draw:\n1-LINE\n2-square\n3-rectangle\t";
cin>>choose_;
if(choose_==1)line_();
else if(choose_==2)square_();
else if(choose_==3)rectangle_();
else if(choose_==4)circle_();
else line_();
}
*/لا إله إلا الله وحده لا شريك له له الملك وله الحمد وهو على كل شيء قدير ...
بارك الله فيكم والسلام عليكم ...


