SlideShare a Scribd company logo
Prog_2 course- 2014 
2 bytes team 
Kinan keshkeh 
IT Engineering-Damascus University 
3rd year
GRAPH
Introduction 
In all programs we were using TXTmode (all outputs 
were in Text). 
In PASCAL there is a Graph Unit, which allow us 
to change into Graphicmode and draw diagrams.
Change into Graph mode 
Uses Graph; 
procedure my_initgraph; 
var gd, gm, error,detect:integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error)); halt(1); 
end; 
end;
1- Uses Graph : to include Graph library. 
2- gd:=detect : detect ,to determine the kind of 
display card . 
3- initgraph(gd,gm,'c:evgrga.bgi') 
that in (2) 
display system : ex: gm=VGAHI , so the screen will be 2640*480*16 (16 number of colors ). 
4- error:=graphresult : to insure if initgraph success in 
changing to Graph mode, it return a value if success or error. 
5-GraphErrorMsg(error) : display an error message , if an error happens when changing into graphic mode. 
6-Halt: to exit the procedure.
2Bytesprog2 course_2014_c9_graph
Note: 
If we have this folder to save code file in it : C:MyFolderpro.pas 
Go to (Turbo Pascal) folder , open ‘BGI’ folder 
1)Copy this file EGAVGA.BGI and paste it in ‘C:MyFolder’ 2)Copy this fileGRAPH.TPU’ unit from ‘Units’ folder (in Turbo 
Pascal folder).and paste it in the path ‘C:MyFolder’ too. 
3)From pascal program , choose File -> Change dir -> 
C:MyFolder . 
* That to initialize Graph environment in pascal !
How to paint a Normal function: 
1) The function : Y= f(x) ex: (y=2x) . 
2) X domain: ex: x in [ x0=-100, xn=100] . 
4) Painting step dx : dx=(xn-x0)/n . 
3) N number of points. 
5) The Algorithm : 
x1=x0; y1=F(x0); 
For(i:=1) to (N) do 
begin 
x2 = x0+i*dx; 
y2 = F(x2); 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end;
Example : 
paint ( Y=f(x) = x ) : 
1- (f(x) = x ) 2- let x in [0,50] 3- n=100 
4-dx=(50-0)/100 = 0.5 ; 
5- Algorithm: 
x1=x0; y1=x0; 
For(i:=1) to (n) do 
begin 
x2 = x0+i*dx; 
y2 = x2; 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end; 
x1 
y1 
x2 
y2 
x2 
y2
How to paint a Polar function: 
1) The function :R= F(u) ex: (y=cos(x) ) . 
2) U domain: ex: U in [ u0=-100, un=100] . 
4) Painting step du : du=(Un-U0)/n . 
3) N number of points. 
5) The Algorithm : 
x1=F(u0)*cos(u0); y1=F(u0)*sin(u0); 
For(i:=1) to (N) do 
begin 
U= u0+ i*du; 
x2=F(u)*cos(u); 
y2=F(u)*sin(u); 
line(x1,y1,x2,y2); 
x1:=x2; y1:=y2 
end; 
x 
y 
U
the Coordinates 
(wXb,wYb) 
paper 
bottom 
(wXt,wYt) 
top 
(vXb,vYb) 
screen 
bottom 
(vXt,vYt) 
top
Coordinates appropriate 
- If you have On paper x in [0..460] 
..it would be On Screen x in [0..230] 
- So each two points on screen , one point on paper . 
(6,0) paper -> (3,0) screen 
- So the Ratio: 
Sx = | vXb – vXt | / | wXt – wXb | 
Sy = | vYb – vYt | / | wYt – wYb | 
0 
460 
230 
0 
vXt 
vXb 
wXb 
wXt 
3 
6 
1)Increasing and decreasing coordinates:
EX: 
If the paper Coordinates are 640*320 , and the screen Coordinates are 1280*640 . 
What are the coordinates on screen of the point (4,6) on paper ? 
answer : 
Sx=(1280-0) / (640-0) = 2 
Sy=(640-0) / (320-0) = 2 
the point on paper(4,6) -> (8,12) on screen
Xv= (x-wXb)*Sx + vXt 
2)Displacement coordinates: 
0 
200 
vXt 
vXb 
-50 
50 
wXb 
wXt 
Ex: the point (50,0) -> Xv=(50+50)*2 + 0 = 200 (x on screen). 
paper 
Screen
Yv= (y-wYb)*Sy + (GetMaxY – vYb) 
0 
0 
paper 
wYb 
100 
100 
vYt 
wYt 
vYb 
Screen 
GetMaxY = 100 
Ex: the point (0,100) -> Yv=(100-0)*1 +(100-100) = 100 (x on screen).
Some important functions and procedures : 
Line(x1,y1,x2,y2) : draw a line between the two points. 
Circle(x,y,radius) : draw a circle . 
Rectangle(x1,y1,x2,y2): draw a rectangle between the two points . 
Setcolor(color): change the color where the color is a number from [0..15] and each number is a color. 
Setviewport(x1,y1,x2,y2,clipOn/clipOff): determine a specific display window 
clipOn: inside it we can see, clipOff: outside it we can see. 
TXTout(“Hello world”) or TXToutXY(50,20,“Hello world”) : print a text on screen with Graphicmode (at specific coordinate), 
whereas at TXTmode we use writeln,write .
Lets make it real :D !! 
What u do in Exams
Normal functions: F(x)=1+x2 
س:ارسم الخط البياني للتابع: 
2+x1 
F(x)= 
حيث x ضمن المجال ]100,+100-[ 
2000 
N= 
Program draw; 
const n=2000; x0=-100; xm=100; dx=0.1 ; { (xm-x0)/n= [100-(-100)]/2000=0.1} uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy , i : integer; alpha , beta :real;
procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; 
function f(x:real):real begin f:=x*x+1; end;
Begin my_initgraph; x1:=x0; y1:=f(x0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/(xm-x0); beta:=maxy/abs( f(xm) - f(x0) );; line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin x2:=x0+i*dx; y2:=f(x2); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; 
appropriate the coordinate 
Displacement 
Draw the axis
Polar functions: F(u)=1+sin(u) 
س:ارسم منحني التابع 
+sin(u)1 
F(u)= 
0.02du=, 0 =0 
U 
Program draw; 
const n=2500; u0=0; du=0.02; 
uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy,i :integer; alpha ,beta :real;
procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; 
function f(u:real):real begin f:=1+sin(u); end;
Begin my_initgraph; x1:=f(u0)*cos(u0); y1:=f(u0)*sin(u0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/ ( n*du) beta:= maxy/abs( f(u0+n*du) - f(u0) ); line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin u:=u0+i*du; x2:=f(u)*cos(u); y2:=f(u)*sin(u); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; 
Draw the axis
The End of the course !!
Group : group link 
Mobile phone- Kinan : 0994385748 
Facebook account : kinan’s account 
2 bytes team

More Related Content

What's hot (17)

Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integrais
Diego Rodrigues Vaz
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
Mohd Arif
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4
Vanishree Arun
 
Integrales
IntegralesIntegrales
Integrales
christian987654321
 
Tablas integrales
Tablas integralesTablas integrales
Tablas integrales
Paulo0415
 
Funcion cuadratica
Funcion cuadraticaFuncion cuadratica
Funcion cuadratica
karina casimir bravo
 
OOXX
OOXXOOXX
OOXX
Weihong Lee
 
PythonArtCode
PythonArtCodePythonArtCode
PythonArtCode
Quinn McFee
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
KristhyanAndreeKurtL
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
V Tripathi
 
Clase funcion cuadratica
Clase funcion cuadraticaClase funcion cuadratica
Clase funcion cuadratica
sainpereztorres
 
Ch16 11
Ch16 11Ch16 11
Ch16 11
schibu20
 
Distributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache MahoutDistributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache Mahout
Suneel Marthi
 
Tabla integrales
Tabla integralesTabla integrales
Tabla integrales
Ana Maria Tantalean Ramirez
 
Exam1 101
Exam1 101Exam1 101
Exam1 101
MuhannadSaleh
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
simpleok
 
Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrat
trisnasariasih
 
Tabela completa de derivadas e integrais
Tabela completa de derivadas e integraisTabela completa de derivadas e integrais
Tabela completa de derivadas e integrais
Diego Rodrigues Vaz
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
Mohd Arif
 
10CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 410CSL67 CG LAB PROGRAM 4
10CSL67 CG LAB PROGRAM 4
Vanishree Arun
 
Tablas integrales
Tablas integralesTablas integrales
Tablas integrales
Paulo0415
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
KristhyanAndreeKurtL
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
V Tripathi
 
Clase funcion cuadratica
Clase funcion cuadraticaClase funcion cuadratica
Clase funcion cuadratica
sainpereztorres
 
Distributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache MahoutDistributed Machine Learning with Apache Mahout
Distributed Machine Learning with Apache Mahout
Suneel Marthi
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
simpleok
 
Tugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadratTugas matematika menemukan konsep persamaan kuadrat
Tugas matematika menemukan konsep persamaan kuadrat
trisnasariasih
 

Viewers also liked (9)

2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
kinan keshkeh
 
أخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائيأخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائي
Alaa Bar Avi
 
Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714
Alaa Bar Avi
 
النشرالإلكتروني
النشرالإلكترونيالنشرالإلكتروني
النشرالإلكتروني
Alaa Bar Avi
 
تصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسطتصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسط
Alaa Bar Avi
 
مبادئ التحرير الإعلامي
مبادئ التحرير الإعلاميمبادئ التحرير الإعلامي
مبادئ التحرير الإعلامي
Alaa Bar Avi
 
التحرير الإخباري
التحرير الإخباريالتحرير الإخباري
التحرير الإخباري
Alaa Bar Avi
 
2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates2 BytesC++ course_2014_c13_ templates
2 BytesC++ course_2014_c13_ templates
kinan keshkeh
 
10 Little Tricks to Get Your Class’s Attention (and Hold It)
10 Little Tricks to Get Your  Class’s Attention (and Hold It)10 Little Tricks to Get Your  Class’s Attention (and Hold It)
10 Little Tricks to Get Your Class’s Attention (and Hold It)
kinan keshkeh
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
kinan keshkeh
 
أخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائيأخلاقيات العالم الافتراضي نهائي
أخلاقيات العالم الافتراضي نهائي
Alaa Bar Avi
 
Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714Ise rt c2_s14_nour_40714
Ise rt c2_s14_nour_40714
Alaa Bar Avi
 
النشرالإلكتروني
النشرالإلكترونيالنشرالإلكتروني
النشرالإلكتروني
Alaa Bar Avi
 
تصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسطتصميم مواقع الشرق الأوسط
تصميم مواقع الشرق الأوسط
Alaa Bar Avi
 
مبادئ التحرير الإعلامي
مبادئ التحرير الإعلاميمبادئ التحرير الإعلامي
مبادئ التحرير الإعلامي
Alaa Bar Avi
 
التحرير الإخباري
التحرير الإخباريالتحرير الإخباري
التحرير الإخباري
Alaa Bar Avi
 

Similar to 2Bytesprog2 course_2014_c9_graph (20)

Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
Abdullah Al Shiam
 
Cs580
Cs580Cs580
Cs580
Chellamuthu K
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
Amit Kapoor
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
ashikul akash
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
Dr.M.Karthika parthasarathy
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
anyacarpets
 
No3
No3No3
No3
syahronirpl
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
Mark Brandao
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Line circle draw
Line circle drawLine circle draw
Line circle draw
Praveen Kumar
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
Indira Gnadhi National Open University (IGNOU)
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSample
Peter Hammel
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
varun arora
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
fathimafancyjeweller
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
ssuser255bf1
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
Abdullah Al Shiam
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
Amit Kapoor
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
ashikul akash
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
Roziq Bahtiar
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
anyacarpets
 
Natural and Clamped Cubic Splines
Natural and Clamped Cubic SplinesNatural and Clamped Cubic Splines
Natural and Clamped Cubic Splines
Mark Brandao
 
COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
Vivek Kumar Sinha
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 
PMHMathematicaSample
PMHMathematicaSamplePMHMathematicaSample
PMHMathematicaSample
Peter Hammel
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
varun arora
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
fathimafancyjeweller
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
ssuser255bf1
 

More from kinan keshkeh (20)

Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
kinan keshkeh
 
Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods Simpson and lagranje dalambair math methods
Simpson and lagranje dalambair math methods
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
kinan keshkeh
 
GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm  GeneticAlgorithms_AND_CuttingWoodAlgorithm
GeneticAlgorithms_AND_CuttingWoodAlgorithm
kinan keshkeh
 
Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...Algorithm in discovering and correcting words errors in a dictionary or any w...
Algorithm in discovering and correcting words errors in a dictionary or any w...
kinan keshkeh
 
2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units2Bytesprog2 course_2014_c8_units
2Bytesprog2 course_2014_c8_units
kinan keshkeh
 
2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists2Bytesprog2 course_2014_c7_double_lists
2Bytesprog2 course_2014_c7_double_lists
kinan keshkeh
 
2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list2Bytesprog2 course_2014_c6_single linked list
2Bytesprog2 course_2014_c6_single linked list
kinan keshkeh
 
2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers2Bytesprog2 course_2014_c5_pointers
2Bytesprog2 course_2014_c5_pointers
kinan keshkeh
 
2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles2Bytesprog2 course_2014_c4_binaryfiles
2Bytesprog2 course_2014_c4_binaryfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles2Bytesprog2 course_2014_c3_txtfiles
2Bytesprog2 course_2014_c3_txtfiles
kinan keshkeh
 
2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records2Bytesprog2 course_2014_c2_records
2Bytesprog2 course_2014_c2_records
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets2Bytesprog2 course_2014_c1_sets
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism2 BytesC++ course_2014_c12_ polymorphism
2 BytesC++ course_2014_c12_ polymorphism
kinan keshkeh
 
2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance2 BytesC++ course_2014_c11_ inheritance
2 BytesC++ course_2014_c11_ inheritance
kinan keshkeh
 
2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces 2 BytesC++ course_2014_c10_ separate compilation and namespaces
2 BytesC++ course_2014_c10_ separate compilation and namespaces
kinan keshkeh
 
2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings 2 BytesC++ course_2014_c8_ strings
2 BytesC++ course_2014_c8_ strings
kinan keshkeh
 

Recently uploaded (20)

Welcome to QA Summit 2025.
Welcome to QA Summit 2025.Welcome to QA Summit 2025.
Welcome to QA Summit 2025.
QA Summit
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Let's Do Bad Things to Unsecured Containers
Let's Do Bad Things to Unsecured ContainersLet's Do Bad Things to Unsecured Containers
Let's Do Bad Things to Unsecured Containers
Gene Gotimer
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
iTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation KeyiTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation Key
raheemk1122g
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Welcome to QA Summit 2025.
Welcome to QA Summit 2025.Welcome to QA Summit 2025.
Welcome to QA Summit 2025.
QA Summit
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
Autodesk Inventor Crack (2025) Latest
Autodesk Inventor    Crack (2025) LatestAutodesk Inventor    Crack (2025) Latest
Autodesk Inventor Crack (2025) Latest
Google
 
Medical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk ScoringMedical Device Cybersecurity Threat & Risk Scoring
Medical Device Cybersecurity Threat & Risk Scoring
ICS
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Robotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptxRobotic Process Automation (RPA) Software Development Services.pptx
Robotic Process Automation (RPA) Software Development Services.pptx
julia smits
 
Solar-wind hybrid engery a system sustainable power
Solar-wind  hybrid engery a system sustainable powerSolar-wind  hybrid engery a system sustainable power
Solar-wind hybrid engery a system sustainable power
bhoomigowda12345
 
wAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptxwAIred_LearnWithOutAI_JCON_14052025.pptx
wAIred_LearnWithOutAI_JCON_14052025.pptx
SimonedeGijt
 
Wilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For WindowsWilcom Embroidery Studio Crack 2025 For Windows
Wilcom Embroidery Studio Crack 2025 For Windows
Google
 
How to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryErrorHow to Troubleshoot 9 Types of OutOfMemoryError
How to Troubleshoot 9 Types of OutOfMemoryError
Tier1 app
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Beyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraftBeyond the code. Complexity - 2025.05 - SwiftCraft
Beyond the code. Complexity - 2025.05 - SwiftCraft
Dmitrii Ivanov
 
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.pptPassive House Canada Conference 2025 Presentation [Final]_v4.ppt
Passive House Canada Conference 2025 Presentation [Final]_v4.ppt
IES VE
 
Let's Do Bad Things to Unsecured Containers
Let's Do Bad Things to Unsecured ContainersLet's Do Bad Things to Unsecured Containers
Let's Do Bad Things to Unsecured Containers
Gene Gotimer
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
iTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation KeyiTop VPN With Crack Lifetime Activation Key
iTop VPN With Crack Lifetime Activation Key
raheemk1122g
 
Artificial hand using embedded system.pptx
Artificial hand using embedded system.pptxArtificial hand using embedded system.pptx
Artificial hand using embedded system.pptx
bhoomigowda12345
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 

2Bytesprog2 course_2014_c9_graph

  • 1. Prog_2 course- 2014 2 bytes team Kinan keshkeh IT Engineering-Damascus University 3rd year
  • 3. Introduction In all programs we were using TXTmode (all outputs were in Text). In PASCAL there is a Graph Unit, which allow us to change into Graphicmode and draw diagrams.
  • 4. Change into Graph mode Uses Graph; procedure my_initgraph; var gd, gm, error,detect:integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error)); halt(1); end; end;
  • 5. 1- Uses Graph : to include Graph library. 2- gd:=detect : detect ,to determine the kind of display card . 3- initgraph(gd,gm,'c:evgrga.bgi') that in (2) display system : ex: gm=VGAHI , so the screen will be 2640*480*16 (16 number of colors ). 4- error:=graphresult : to insure if initgraph success in changing to Graph mode, it return a value if success or error. 5-GraphErrorMsg(error) : display an error message , if an error happens when changing into graphic mode. 6-Halt: to exit the procedure.
  • 7. Note: If we have this folder to save code file in it : C:MyFolderpro.pas Go to (Turbo Pascal) folder , open ‘BGI’ folder 1)Copy this file EGAVGA.BGI and paste it in ‘C:MyFolder’ 2)Copy this fileGRAPH.TPU’ unit from ‘Units’ folder (in Turbo Pascal folder).and paste it in the path ‘C:MyFolder’ too. 3)From pascal program , choose File -> Change dir -> C:MyFolder . * That to initialize Graph environment in pascal !
  • 8. How to paint a Normal function: 1) The function : Y= f(x) ex: (y=2x) . 2) X domain: ex: x in [ x0=-100, xn=100] . 4) Painting step dx : dx=(xn-x0)/n . 3) N number of points. 5) The Algorithm : x1=x0; y1=F(x0); For(i:=1) to (N) do begin x2 = x0+i*dx; y2 = F(x2); line(x1,y1,x2,y2); x1:=x2; y1:=y2 end;
  • 9. Example : paint ( Y=f(x) = x ) : 1- (f(x) = x ) 2- let x in [0,50] 3- n=100 4-dx=(50-0)/100 = 0.5 ; 5- Algorithm: x1=x0; y1=x0; For(i:=1) to (n) do begin x2 = x0+i*dx; y2 = x2; line(x1,y1,x2,y2); x1:=x2; y1:=y2 end; x1 y1 x2 y2 x2 y2
  • 10. How to paint a Polar function: 1) The function :R= F(u) ex: (y=cos(x) ) . 2) U domain: ex: U in [ u0=-100, un=100] . 4) Painting step du : du=(Un-U0)/n . 3) N number of points. 5) The Algorithm : x1=F(u0)*cos(u0); y1=F(u0)*sin(u0); For(i:=1) to (N) do begin U= u0+ i*du; x2=F(u)*cos(u); y2=F(u)*sin(u); line(x1,y1,x2,y2); x1:=x2; y1:=y2 end; x y U
  • 11. the Coordinates (wXb,wYb) paper bottom (wXt,wYt) top (vXb,vYb) screen bottom (vXt,vYt) top
  • 12. Coordinates appropriate - If you have On paper x in [0..460] ..it would be On Screen x in [0..230] - So each two points on screen , one point on paper . (6,0) paper -> (3,0) screen - So the Ratio: Sx = | vXb – vXt | / | wXt – wXb | Sy = | vYb – vYt | / | wYt – wYb | 0 460 230 0 vXt vXb wXb wXt 3 6 1)Increasing and decreasing coordinates:
  • 13. EX: If the paper Coordinates are 640*320 , and the screen Coordinates are 1280*640 . What are the coordinates on screen of the point (4,6) on paper ? answer : Sx=(1280-0) / (640-0) = 2 Sy=(640-0) / (320-0) = 2 the point on paper(4,6) -> (8,12) on screen
  • 14. Xv= (x-wXb)*Sx + vXt 2)Displacement coordinates: 0 200 vXt vXb -50 50 wXb wXt Ex: the point (50,0) -> Xv=(50+50)*2 + 0 = 200 (x on screen). paper Screen
  • 15. Yv= (y-wYb)*Sy + (GetMaxY – vYb) 0 0 paper wYb 100 100 vYt wYt vYb Screen GetMaxY = 100 Ex: the point (0,100) -> Yv=(100-0)*1 +(100-100) = 100 (x on screen).
  • 16. Some important functions and procedures : Line(x1,y1,x2,y2) : draw a line between the two points. Circle(x,y,radius) : draw a circle . Rectangle(x1,y1,x2,y2): draw a rectangle between the two points . Setcolor(color): change the color where the color is a number from [0..15] and each number is a color. Setviewport(x1,y1,x2,y2,clipOn/clipOff): determine a specific display window clipOn: inside it we can see, clipOff: outside it we can see. TXTout(“Hello world”) or TXToutXY(50,20,“Hello world”) : print a text on screen with Graphicmode (at specific coordinate), whereas at TXTmode we use writeln,write .
  • 17. Lets make it real :D !! What u do in Exams
  • 18. Normal functions: F(x)=1+x2 س:ارسم الخط البياني للتابع: 2+x1 F(x)= حيث x ضمن المجال ]100,+100-[ 2000 N= Program draw; const n=2000; x0=-100; xm=100; dx=0.1 ; { (xm-x0)/n= [100-(-100)]/2000=0.1} uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy , i : integer; alpha , beta :real;
  • 19. procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; function f(x:real):real begin f:=x*x+1; end;
  • 20. Begin my_initgraph; x1:=x0; y1:=f(x0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/(xm-x0); beta:=maxy/abs( f(xm) - f(x0) );; line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin x2:=x0+i*dx; y2:=f(x2); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; appropriate the coordinate Displacement Draw the axis
  • 21. Polar functions: F(u)=1+sin(u) س:ارسم منحني التابع +sin(u)1 F(u)= 0.02du=, 0 =0 U Program draw; const n=2500; u0=0; du=0.02; uses graph; var x1,x2,y1,y2:real; nx1,nx2,ny1,ny2:real; maxx , maxy,i :integer; alpha ,beta :real;
  • 22. procedure my_initgraph; {initialize screen for drawing} var gd,gm,error,detect :integer; begin gd:=detect; initgraph(gd,gm,'c:evgrga.bgi'); error:=graphresult; if error<>grok then begin writeln('graphic error',GraphErrorMsg(error) ); halt(1); end; function f(u:real):real begin f:=1+sin(u); end;
  • 23. Begin my_initgraph; x1:=f(u0)*cos(u0); y1:=f(u0)*sin(u0); maxx:=getmaxx; maxy:=getmaxy; alpha:=maxx/ ( n*du) beta:= maxy/abs( f(u0+n*du) - f(u0) ); line(0,maxy div 2,maxx,maxy div 2); line(maxx div 2,0,maxx div 2,maxy); for i:=1 to n do begin u:=u0+i*du; x2:=f(u)*cos(u); y2:=f(u)*sin(u); nx1:=round(x1*alpha)+maxx div 2; nx2:=round(x2*alpha)+maxx div 2; ny1:= -round(y1*beta)+maxy div 2; ny2:= -round(y2*beta)+maxy div 2; line(nx1,ny1,nx2,ny2); x1:=x2; y1:=y2; end; close graph; End; Draw the axis
  • 24. The End of the course !!
  • 25. Group : group link Mobile phone- Kinan : 0994385748 Facebook account : kinan’s account 2 bytes team
  翻译: