0% found this document useful (0 votes)
17 views

Prectical File Computer Graphics

THis is related to the computer graphics. It tell us how to run

Uploaded by

Kausar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views

Prectical File Computer Graphics

THis is related to the computer graphics. It tell us how to run

Uploaded by

Kausar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 35
Experiment No. Of 0 | Aim! Psqgvam to dean 4 Line using algorithm - _ ‘Sousce Code — a —S # include a — Ht include 4h include # jnclude < dos. h> sroid_ main ©) 4 Beppie “DAA Float wy, XL Vt, x2 ,%2 dx, dy, steps int i, gd= DETECT, gms int gxaph C8ad egm roy" e:\\vs code\\ gi") Brace Entex -the starting point of Une"); scanf ("2pF (hf " Bx BYI) > printf (" Entes the ending point of Une") 5 - —_seanf ("ht sph", 8x2 eye); _K= a bs(xe-xs ffm dy - abs (¥2-94); jot BYA bec a dx -dx/step } oo dy = dy [steps — Xt wKbp _ — SC _Putpixel (x»¥.S)3 —$___— Mo xKX4dx - a _ + - yiytdy OC [— ist+t | _____ detay (100) > SSS gqetebUs el . a close graph) Output - Entes the tarting point of line | - 100 100 Entes the ending paint of Line _ — ton 400 . OC - int_ad= De . _—int_gd= DETECT, gm Source co. | * a - | # include | # include Conio-h> _| FH include < gsaphics. b> ; - Void main) Une Algorithm, Dato. 39 Dec.29 Page No......O%.... Poogram 40 draw @ line usin e iq Bxesenham ‘s de BC int xy) xt XQ yiy2,dx dy, ps initgraph (Rad, &gm,") s Cleas device () + printf (" BRES@NHAM’S LINE DRAWING ALGO\n \n")s printf C'Entes initial cooretinate:") 3 seanfl "hd thd", @xI, 2Yt) y printf C'Entex final coordinate’) 5 scanfl" thd hd", 2x2,2 N2); Ax = K2-xUG oly = ¥2-¥1; p=2* dy-dx 5 x YEyts ExQt NOs putpixel (% 94) } while ( x< X2) ; if (p 4 include # include #H Include Votd Floed (int, int, int. int) + Sousce Code — - = 4 | Void main() * i tntad = DETECT. 9m3 oO oT intQsaph (2gd, qm.) 5 sectangle (50,50, 250,250) + Flood (55, $5, 10,0) + geteh O; 4 void Plood Gntx, ioty intfillColos, intdeault Colox ) a if (getpixel Voy) == default Coles Fes 1 = delay LO) 5 putpixel L4N> Filteolos) 5 : Plood (x+h,Y> Pilleotos , defaultColes) § - Fleed (x-4, Yo fillectos, default clos) + Flood OGYtL, Fill Colors , default Color) 3 Teacher's Signature... — Date... 4t? Dec, 22. Exot. No. Page NO. en PB unesnnnnnne Floed (x,N-1, filleolor, default Golos) 5 aa Teacher's SIGMAMUFE....sseseseernres pate... pec:2.2 EN ee Aim: Puogram to implement 4-connected boundary Fill Algorithm. Source Code - # include bear cles) - 7 { I if (getpixel (4 y) | = Cay) t= = Fill-colos) - ——_ i Put pixel Coy, Fill-colos) } boundasy Filla (X+1, 9, Fill -colos, boundary ecley) s = boundary colos os 28 ge et pixel J boundary fill 4 (% Y+t, Fill-coloy, boundary aolos) § boundary fill4 (X-L,y, Fill—colov, boundary color): = | boundary Filla OG Y-L, Fillecolor Dowsing color) s | 4 int_main() { int_gd= DETECT, gm} Sv ” w initgraph (2gd. 29m," "') § int x2 250 , y=200, radius = S03 Teacher's Signature... Date... — ] ——— —— of . 1 Page No, 0%, eo 2 civele OGY ; vadtus) 3 boundary fill 4. O49, 6.15) > clelay Benoa) : getehO 5 Close graph C) 3 seturn © + Output ~ pote. 5D se:22 imi Program to fill the polygon using Sean line_ Algorithm. Sousce Code— Ht include < Std lib ch #H Include tH include temp=Xi+ XL=%X2, X2 = bemmp } } if CUy2-y1)1=0) * mx (x2-x1) / Cy2-Y1) 5 else _mx = X2- *L 5 mex se = fox (isyt 3 1g 925 i++) i if (x< (float) left) Teacher's Signature... Date..5t? pec.22 PAgE NO. nnn nen, le (iJ = Cint) x: _ | if Ce > (float) xe PIT) se [iJ = (int) x: p= mas j - Noid _dsaui_ pixel (int x, int y) t - GitolosS fU1,0, 1.6, 0.0) 3 Gi Begin LGL- POINTS) ; Qgivertex 21 Ly): gitndt) > 4 _ void scanfit, (float xt, float yt, float ¥2, Ploak¥2 float ¥3, Float ys. float x4, Float y4) 2 int te [S00], xe [S00] + int t 93 fos Liza: i 400-0} X42300.03 Y4=300+0 $ gicieas (Gl-cotor.. BurFER. BIT)s gicoles3f (0.0, 0.0, 10) Q) Begin (QL.LINE. Loop): gl vertex 2F Oxy yn; qivestex 2f (X2, y2)3 gd Qlvertex OF (x3, ¥3)5 _aivertex 2s ya): End © 5 can file (Xb YL X22, X33, X49 4) 3 ql flush 0 it void myinit i _ gicleax colos (10 1:0, 460, 1-0) 3 Teacher's Signature. Gleclor sf (t-0, 0.0, 0.0) 3 Qipoint size Cho): gl matrix Mode (GL. pPRoyect ron); gl Load Identity ©) 3 qluortho 2D (0.0, 499.0, 0.0, 499-0) } ‘int main Cint-asyc, char** argv) g } i glut Init (garde argv) ; ‘glut Telia Mode CQ@LUT_ SINGLE | GLUT-REB); glut Init Window size (S00, 500); * alut Init Window Position (0,0) 3 glut Display fune (display) 3 myinit Os glut Main Loopt)} g Teacher's SIQMAtHUTe....... secretes Outpat- ' .-\ Page NO...essse Roe g & - J fim? Psogzam to show 2D-Tsanslation of a yecugic | WN Source Code- | #f inctede < bits Jstde++-h> }-—T 2 H include using namespace sid woid translate Rectangle. Cint pLI BI, int TLI) L LU int _gd= DETECT, gm, exvox code + init_gaaph (egg. 29m." )3 | Seteotos t2) § sectangle (plej Lo], plol Od, pLOCL, pUIED § \ plol fe] = Preyfoy + T Lei; | Plertt= eforlsi+Ttss; PLiJfo] = PLiJloy + T Led ; 4 | Pomo= ev od + TOL: rectangle (P Lol Lo] elol Cy, preytel, PEMIL) s int_main O $ 7 int p (2127 = 35,8, 12,18}: | _ int TOT: 32,44 | teansiate Rectangle CP,.71)3 seturn O03 Teacher's SIQNature.....cccesssesneteie LL Original Rectangle Teansiated Rectangle —IITTTdt id Ff ra | — | —4 | — oa — POQE NO.wnnnl, oe ee | + L | 4 Or {4 Aim? © program to perform xeflection of the given 2D- image. Sousce Code— H include / include < conio-h» i Ht Include \ | # include _ \ | : yoid_main ©) | r | ¢£ Le | int weode. begin G4] = fo,0.0,0}, rf weodeend [4]: {0 00,01) | xgion code [4]; | int Wexmax ymax Wwe%Xmin, A-Ymio flag 20% | | float slope; tnt YY XLT Ke, Vee | {| |_| SE LeU |n "Cohen Su entes Xmin WW. Xmin, LA-Srmin) 5 tin first enter Xmen. Vina =”) 5 | i inte U ln ‘Now | anf Uthd hd” 8 {| printf (' | eanf Nefad tod, & We Xmax QW-Smar); I | vintf£CC\n please enjes_ initial point X andy ="); a seanf lh fd", 2% kV); - — | Teacher's Signature... — \ _ f printf ("\n Now entes final point x1 4 cant ("hd end’ &xt fyt): Cleayclevice () + si . ettangle (A Xmin, A-Ymin, WL Xmax, WY max) | line (4% Y, We Xxmax) i weodew begin omic I Right Flag 3 7 o if (x< HL_Xmin) i Teacher's SIQMature........ cece x Cohen sutpestand Une dipping algorithmny min = 100 £00 Now, entex Xmin» J ¥rmax = 450 450 first enter xmax 5 Please ente® Now, ontes final point xt and y41= 50 - Befose clipping the Line- enitial point X Andy =Sco oy - — TT jo J a fF Neode-end[0J:t; Fflag= 1+ 7 a if LYt< W_ymin) { weocte_end (t]=1: __M Bottom// Flag=ts | if (X03 Whe xmax) i seode-end [2J>15 _ _ Flag eins 4 tf (1 65 70 Translation of Object - 7 _| Aim: Program fox =the implementation ( | 4 i i 1 —o (got no. POgE NO. Pe of an object Code — | tH include te include Ht include <_math-h int _maeX , Men mid %, midy $ void axisC) Une (mid x, 0, mid, mary) Line CO, midy maxX mid) 5 void main i oy, Zang Xt. x2, SE N25 int gd.gm NG» 25 of SD- Sealing a + j detect graph (kad ogo). u gf g init graph (ag kgm," eyes setfillstyle (3, 25) maxx = gelmaxxt) 5 =J S maxy = maxsC) 5 maxy zgetmaxy 0} a mi = maxx) 2 ; midy = maxy /2 Out text xy C100, 100," ORIGINAL OBJECT"): Teacher's SIQNAture...... cere aothpec.o2 Date. 2 POQE NOs BE 3 Line (mid, 0, midx, maxy) 3 Une LO, midy, maxx, midy) 3 bar 3D (midx +100, midy ~ 20. midx+6o, midy- 60, 20,5); axis() 3 Outtext xy (100, 20 " seAtING’) 5 "yy printf ("|n Entes _-the ecaling Factor: scant Ui! thd hed “bd”, 2X ez); bay 3D (midx+ 100 midy- 20, midx+ 60, ——— midy- 60 20,5) > | bar 3D midx+ Or oo), midy= (y* 20), midet — x*60 micty (960), (20%2).523 | (ee ae ee | etchO: ——— | [ten lente : | en [2 or __ | ae eS ee a [ese A a ORIGINAL OBJECT SCALING Entes the Sealing factor: 2,2,2 Merl a

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy