.


:




:

































 

 

 

 


,




1

 

ASCII ++

 

ASCII ++ Windows. ++ .

 

1.

, , ASCII , ++ . , , , ASCII . ASCII , . Scan , ASCII Scan-ASCII . Scan-ASCII , BIOS , .

 

2.

1. Windows, . ASCII .

2. Windows MS DOS. . , .

 

1 .

1. New New Items Console Wizard Source Type ++. ++ Builder

 

 

//---------------------------------------------------------------------------

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused

int main(int argc, char* argv[])

{

return 0;

}

//---------------------------------------------------------------------------

 

2. -,

 

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

//---------------------------------------------------------------------------

#include <conio.h>

#include <system.hpp>

#include <stdio.h>

#define dx 24 /* */

#define dy 5 /* */

void my_box(int xul,int yul,int xlr,int ylr,int btype)

{

static int boxcar[2][6] = { /* */

{ 218,196,191,179,192,217 }, /* */

{ 201,205,187,186,200,188 } /* */

};

int i,hzchar,vtchar;

if(btype) {

hzchar = boxcar[btype -1][1];

vtchar = boxcar[btype -1][3];

/* */

gotoxy(xul,yul);

for(i = xul; i<= xlr; i++) putch(hzchar);

gotoxy(xul,ylr);

for(i = xul; i<= xlr; i++) putch(hzchar);

/* */

for(i = yul; i<= ylr; i++)

{ gotoxy(xul,i); putch(vtchar);

gotoxy(xlr,i); putch(vtchar);

}

/* :*/

/* */

gotoxy(xul,yul); putch(boxcar[btype - 1][0]);

/* */

gotoxy(xlr,yul); putch(boxcar[btype - 1][2]);

/* */

gotoxy(xlr,ylr); putch(boxcar[btype - 1][5]);

/* */

gotoxy(xul,ylr); putch(boxcar[btype - 1][4]);

 

}

}

//----------------------------------------------------------------------------

 

#pragma argsused

int main(int argc, char* argv[])

{

int c,ch;

int btype;

int xul,yul; /* */

int xlr,ylr; /* */

int N,n; /* N - , n - */

char S_1[7],S_2[15],S_3[15],S_4[8]; /* Ctr+shift -> EN*/

/* Ctrl+Shift -> Ru */

p1: clrscr(); btype = 2;

gotoxy(3,22); textcolor(RED); cprintf("ESC");

gotoxy(7,22); textcolor(GREEN); CharToOem("\n",S_1); cprintf(S_1);

gotoxy(1,23); textbackground(LIGHTCYAN); textcolor(RED);

CharToOem(" \n",S_2); cprintf(S_2);

gotoxy(1,24); CharToOem(" 8 ->1 \n",S_3); cprintf(S_3);

textmode(LASTMODE); gotoxy(1,1);

N = 1; xul =1; yul = 1; ch = (dx - 2) * (dy -1) + 2;

do

{ xlr = xul + dx; n = 0;

ylr = yul + dy;

textcolor(CYAN);

my_box(xul,yul,xlr,ylr,btype);

window(xul + 1,yul + 1,xlr - 1,ylr - 1);

gotoxy(0,0);

do

{ c = getch();

if(c!= 0x1b)

{ textbackground(BLUE); textcolor(YELLOW);

putch(c);

n++;

}

else

goto p2;

} while(n <= ch);

window(1,1,80,25);

gotoxy(xlr - 17,ylr + 1); textbackground(LIGHTGRAY);

textcolor(MAGENTA); cprintf(" ASCII "); CharToOem(" \n",S_4);cprintf(S_4);

gotoxy(xlr - 17,ylr + 2); textbackground(GREEN);

textcolor(RED); cprintf(" "); putch(c);

cprintf("= 0x%x ",c);

textmode(LASTMODE);

N++; btype --;

xul = xlr + 1; /* window(1,1,80,25) */

yul = ylr + 1;

} while(N <= 3);

window(1,1,80,25);

goto p1;

p2:;

return 0;

} /*end main*/

//---------------------------------------------------------------------------

 

2 .

1. New New Items Console Wizard Source Type ++. ++ Builder

 

//---------------------------------------------------------------------------

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused

int main(int argc, char* argv[])

{

return 0;

}

//---------------------------------------------------------------------------

 

2. -,

 

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

//---------------------------------------------------------------------------

/*===============================================*

* *

* ASCII *

*===============================================*/

#include <system.hpp>

#include <stdio.h>

#include <conio.h>

void draw_border(int startx,int starty,int endx,int endy)

{ register int i;

textcolor(LIGHTCYAN);

gotoxy(startx,starty); cprintf("%c",218); /* putchar(218);*/

gotoxy(startx,endy); cprintf("%c",192); /* putchar(192);*/

gotoxy(endx,starty); cprintf("%c",191); /* putchar(191);*/

gotoxy(endx,endy); cprintf("%c",217); /* putchar(217);*/

getch();

for(i = startx + 1; i < endx; i++)

{ textcolor(LIGHTRED);

gotoxy(i,starty); cprintf("%c",196); /*putchar(196);*/

gotoxy(i,endy); cprintf("%c",196); /*putchar(196);*/

getch();

}

for(i = starty + 1; i < endy; i++)

{ textcolor(LIGHTMAGENTA);

gotoxy(startx,i); cprintf("%c",179); /* putchar(179);*/

gotoxy(endx,i); cprintf("%c",179); /* putchar(179);*/

getch();

}

textmode(LASTMODE);

}

//---------------------------------------------------------------------------

 

#pragma argsused

int main(int argc, char* argv[])

{

int lux,luy; /* */

int rdx,rdy; /* */

char S_1[15],S_2[15],S_3[15],S_4[20],S_5[22],S_6[22],S_7[22];

char S_8[30],S_9[30],S_10[30],S_11[30];

/* Ctr+shift -> EN*/

/* Ctrl+Shift -> Ru */

m1: clrscr();

gotoxy(1,23); textbackground(LIGHTCYAN); textcolor(RED);

CharToOem(" \n",S_1); cprintf(S_1);

gotoxy(1,24); CharToOem(" 8->2 \n",S_2); cprintf(S_2);

gotoxy(30,1); textbackground(GREEN); textcolor(RED);

CharToOem("\n",S_3); cprintf(S_3);

gotoxy(1,3); textbackground(LIGHTGRAY); textcolor(LIGHTBLUE);

CharToOem(" \n",S_4); cprintf(S_4);

gotoxy(1,4);

CharToOem(" \n",S_5); cprintf(S_5);

gotoxy(28,4); textmode(LASTMODE); textcolor(LIGHTGREEN);

cprintf(" X="); scanf("%d", &lux);

gotoxy(37,4); cprintf(" Y="); scanf("%d", &luy);

gotoxy(40,23); textbackground(LIGHTGRAY); textcolor(LIGHTBLUE);

CharToOem(" \n",S_6); cprintf(S_6);

gotoxy(40,24);

CharToOem(" \n",S_7); cprintf(S_7);

gotoxy(62,24); textmode(LASTMODE); textcolor(LIGHTGREEN);

cprintf(" X="); scanf("%d", &rdx);

gotoxy(72,24); cprintf(" Y="); scanf("%d", &rdy);

if(rdx < lux)

{ textcolor(LIGHTBLUE);

gotoxy(40,10);

CharToOem(" X \n",S_8); cprintf(S_8);

gotoxy(40,11);

CharToOem(" \n",S_9); cprintf(S_9);

getch(); textmode(LASTMODE);

goto m1;

}

if(rdy < luy)

{ textcolor(LIGHTBLUE);

gotoxy(40,12);

CharToOem(" Y \n",S_10); cprintf(S_10);

gotoxy(40,13);

CharToOem(" \n",S_11); cprintf(S_11);

cprintf(" ");

getch(); textmode(LASTMODE);

goto m1;

}

lux =(lux > 70)? 70: lux;

luy =(luy > 20)? 18: luy;

rdx =(rdx > 80)? 80: rdx;

rdy =(rdy > 20)? 20: rdy;

draw_border(lux,luy,rdx,rdy);

return 0;

} /* end main() */

//---------------------------------------------------------------------------

 

 

2

 

, ++ Builder

 

, , , .

 

,

 

++ Builder , .2.1.

2.1

Image () Additional : ,
DBImage ( ) Data Controls Image
PaintBox ( ) System ,

 

, , Canvas (). Canvas . ++ Builder Canvas, , . , Image, DBImage, PaintBox . , ++ Builder .

X Y. . X , Y . .

, . . Tcolor.

. (Pixels) . (Pen) Pen.

Pixels , :

Cavas->Pixels[int X][int Y]

: , , . , Cavas->Pixels[int X][int Y] = clBlue; - . F(x) Image, Ymin, Ymax Xmin, Xmax.,

 

//--------------------------------------------------------------

float x, y; //---

float PX, PY; //---

for(PX=0; PX <= Image1->Width; PX ++)

{ //--x ,

x = Xmin + PX*(Xmax - Xmin) / Image -> Width;

y = F(x);

//--PY , y

PY = Image1->Width (y - Ymin)* Image->Height/(Ymax - Ymin);

//---

Image1->Canvas->Pixels[PX][PY] = clBlack;

}

//--------------------------------------------------------------

 

Pen . , . Color , , Widht . 1. Style . :

 

psSolid psDash psDot psDashDot psDashDotDot psClear psInsideFrame - , Widht > 1 Windows

 

Widht = 1. . psInsideFrame , . Windows. PenPos . PenPos, .. MovTo(X,Y). (,) , . , LineTo(X,Y) (,). LineTo(X,Y) .

Pen , . , :

Arc Chord   Ellipse Pie Polygon Polyline Rectangle RoundRect , - -

 

 

Brush . . Brush , . Color . Style ().

 

. 1. , Sin(X) : Pixels; Pen MovTo(X,Y) LineTo(X,Y).

2. , Pen .

 

1 :

1. D:\ Lab_2 Sin_2 P_Sin_2.

2. Additional Image1, .

3. Standart Button1 .

4. OnClik Button1.

5. TForm1::Button1Click(TObject *Sender) , Sin(X) Pixels

 

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "U_Sin_2.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

#include <math.h>

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

#define Pi 3.14159

float X,Y; //

int PX,PY; //

for (PX = 0; PX <= Image1->Width; PX++)

{

//X - , PX

 

X = PX * 4 * Pi / Image1->Width;

Y = sin(X);

//PY - , Y

PY = Image1->Height - (Y+1) * Image1->Height / 2;

//

Image1->Canvas->Pixels[PX][PY] = clRed;

}

}

 

//---------------------------------------------------------------------------

 

6. Pen Sin(X) Image2.

7. . Shift Image1, Image2 . Size Grow to largest Shrink to smallest.

8. TForm1::Button1Click(TObject *Sender)

 

//---------------------------------------------------------------------------

#include <math.h>

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

#define Pi 3.14159

float X,Y; //

int PX,PY; //

Image2->Canvas->MoveTo(0,Image2->Height/2);

 

for (PX = 0; PX <= Image1->Width; PX++)

{

//X - , PX

X = PX * 4 * Pi / Image1->Width;

Y = sin(X);

//PY - , Y

PY = Image1->Height - (Y+1) * Image1->Height / 2;

//

Image1->Canvas->Pixels[PX][PY] = clRed;

//

Image2->Canvas->LineTo(PX,PY);

}

}

//---------------------------------------------------------------------------

9.

 

 

2 :

1. D:\, Lab_2, Figures_2 P_Figures_2.

2. Image1 U_Figures_2 :

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

 

#include "U_figures_2.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

 

void __fastcall TForm1::FormCreate(TObject *Sender)

{

Image1->Canvas->Font->Style << fsBold;

Image1->Canvas->Arc(10,10,90,90,90,50,10,50);

Image1->Canvas->TextOut(40,60,"Arc");

Image1->Canvas->Chord(110,10,190,90,190,50,110,50);

Image1->Canvas->TextOut(135,60,"Chord");

Image1->Canvas->Ellipse(210,10,290,50);

Image1->Canvas->TextOut(230,60,"Ellipse");

Image1->Canvas->Pie(310,10,390,90,390,30,310,30);

Image1->Canvas->TextOut(340,60,"Pie");

TPoint points[5];

points[0] = Point(30,150);

points[1] = Point(40,130);

points[2] = Point(50,140);

points[3] = Point(60,130);

points[4] = Point(70,150);

Image1->Canvas->Polygon(points,4);

Image1->Canvas->TextOut(30,170,"Polygon");

points[0].x += 100;

points[1].x += 100;

points[2].x += 100;

points[3].x += 100;

points[4].x += 100;

Image1->Canvas->Polyline(points,4);

Image1->Canvas->TextOut(130,170,"Polyline");

Image1->Canvas->Rectangle(230,120,280,160);

Image1->Canvas->TextOut(230,170,"Rectangle");

Image1->Canvas->RoundRect(330,120,380,160,20,20);

Image1->Canvas->TextOut(325,170,"RoundRect");

}

//---------------------------------------------------------------------------

 

3.

 

3

 

++

Windows. - Image Editor . .





:


: 2017-02-11; !; : 365 |


:

:

, , .
==> ...

1571 - | 1476 -


© 2015-2024 lektsii.org - -

: 0.143 .