+ All Categories
Home > Documents > 1rz13mca08 Cg report

1rz13mca08 Cg report

Date post: 02-Jun-2018
Category:
Upload: sandywaits4u31
View: 214 times
Download: 0 times
Share this document with a friend

of 22

Transcript
  • 8/10/2019 1rz13mca08 Cg report

    1/22

    Computer Graphics Project 2014

    I. Synopsis

    Introduction

    1. Generate a graph to analyze the up and downs of a share market

    using DDA algorithis about taking the data and showing it in chart type.

    Advantage o chart is that it wi!! be easy to understand the data dierences

    which is given by the user in terms o numbers" he can compare it with

    previous data in chart" he can see the whether there is

    improvement#deterioration over the time. Chart is used because it is a

    graphica! representation o data" where the data is represented as co!umns.

    Charts are oten used to ease understanding o !arge $uantities o data and

    the re!ationships between parts o the data. Charts can usua!!y be read

    more $uick!y than the raw data that they are produced rom. %hey are used

    in a wide variety o ie!ds" and can be created by hand &oten on graph

    paper' or by computer using a charting app!ication .%hese options are

    imp!emented using ((A !ine a!gorithm.

    2. Developement of 2D e!t screen saver with " #otation and

    ranslation .A screensaver &or screen saver' is a computer program that

    b!anks the screen or i!!s it with moving images or patterns when the

    computer is not in use. A screen saver a!so an animated image that is

    activated on a persona! computer disp!ay when no user activity has been

    sensed or a certain time or sometimes a user himse! makes the screen

    saver to run or some time .)n this app!ication test input is trans!ated and

    rotated as the screen saver app!ication.

    (ept.o *CA" +,C- Page o.1

  • 8/10/2019 1rz13mca08 Cg report

    2/22

    Computer Graphics Project 2014

    II. Design Specification

    (esign /peciication provides ep!icit inormation about the re$uirements or the

    project and how the project has been imp!emented. )t is used to design document that

    describes a!! data" architectura!" interace and component!eve! design or the

    sotware.

    1. Generate a graph to analyze the up and downs of a share market using

    DDA algorith

    ((A a!gorithm is used to design the chart" when the user provides data" the

    irst data is taken and the !ine is drawn or that data" same unctiona!ity is

    carried out or rest o the data provided by the user. ((A !ine a!gorithm is

    ca!!ed or n times" n is the number o times given by the user to draw co!umns

    with n number o datas.

    DDA line Algorithm

    ((A 3ine & 1" 51" " 5'6

    (escription6 7ere 1 and 51 denote the starting 8 coordinate and y 8

    coordinate o the !ine

    and and 5 denote the ending 8 coordinate and y 8 coordinate.

    1. /et * 9 &5 8 51' # & 8 1' :Ca!cu!ate s!ope o !ine;

    2. +epeat 9 1' %hen

    4. /et ( 9 1

    ?. /et (5 9 * @ (

    . -!se

    B. /et (5 9 1

    . /et ( 9 (5 # *

    :-nd o );

    D. /et 1 9 1 E (

    10. /et 51 9 51 E (5

    11. Ca!! PutPie!&1" 51'

    :-nd o

  • 8/10/2019 1rz13mca08 Cg report

    3/22

    Computer Graphics Project 2014

    Steps to Design $ and % a!is

    Programmer has to give " y and F coordinates or two !ines.

    ((A !ine unction has to be ca!!ed or two times with the given

    coordinates.

    %his is a predeined !ine" so programmer has set the "y and F co

    ordinates and two !ines has been drawn.

    Steps to Design a chart

    ser irst has to insert the number o co!umns he want that is Hn.

    %hen user has to enter data or n number times.

  • 8/10/2019 1rz13mca08 Cg report

    4/22

  • 8/10/2019 1rz13mca08 Cg report

    5/22

    Computer Graphics Project 2014

    Advantages o ((A A!gorithm

    1. )t is the simp!est a!gorithm and it does not re$uire specia! ski!!s or imp!ementation.

    2. )t is a aster method or ca!cu!ating pie! positions than the direct use o e$uation y

    9 m E b. )t e!iminates the mu!tip!ication in the e$uation by making use o rastercharacteristics" so that appropriate increments are app!ied in the or v direction to

    ind the pie! positions a!ong the !ine path.

    2. Developement of 2D e!t screen saver with " #otation and ranslationin

    this the users tet is ca!!ed at a speciied positions and the co!or o the tet is

    set .Ca!!ing the users tet with trans!ation"rotation and de!ay makes this

    specia! and gives the screen saver eects.

    Steps to Design te!t

    ser has to give a tet which is stored in array.

    %he tet rendered onto screen using coordinates speciied by user.

    %he tet is i!!ed with dierent co!ours.

    Steps to call te!t

    %he coordinates and y are app!ied.

    %he coordinates are passed to the drawstring unction which draws the

    tet on to screen using g!utNitmapChar&' unction.

    Delay function

    (e!ay unction is used to keep some de!ay between ca!!ing the tet

    again" so that it makes eect o screen saver.

    )nitia!iFe i 90M +epeat unti! i >9 2000000M )ncrement i by 1.

    Applying rotation

    g!+otate&ang!e" 0.0" 0.0" 1.0'M

    Applying translation

    g!%rans!ate&B?0" 0" 0'M

    (ept.o *CA" +,C- Page o.5

  • 8/10/2019 1rz13mca08 Cg report

    6/22

    Computer Graphics Project 2014

    III. Graphical 'eatures

    1. Generate a graph to analyze the up and downs of a share market using

    DDA algorith

    (ierent +GN co!ors has been set g!Co!or=&1.0"0.0"0.0' to G3OPL)%/ to

    make co!umns co!oru!.

    Gradient eect6 Gradient eect has been imp!emented with G3O3)-

    unction bygiving dierent va!ues to g!co!or or each verte in po!ygon gives

    the gradient eect.

    %he tet on the graphica! window is drawn with the he!p g!utNitmapCharacter.

    (ist of )penG( functions incorporated in this pro*ect is as follows

    g!C!ear&G3OCL3L+ON

    g!%rans!ate&B?0" 0" 0'M

    !en 9 &int' str!en&message'M

    or &i 9 0M i > !enM iEE' Q

    (ept.o *CA" +,C- Page o.6

  • 8/10/2019 1rz13mca08 Cg report

    7/22

    Computer Graphics Project 2014

    g!ut/trokeCharacter&ont" message:i;'M

    Delay & (e!ay unction is imp!emented to suspend the eecution o a program or a

    particu!ar time. 7ere unsigned int is the number o mi!!iseconds & 1 second 9 1000

    mi!!iseconds '.

    void de!ay&'

    Q

    or& int i 9 0M i >9 2000000M iEE'

    R

    Graphic (i+rary

    Sinc!ude >G3#g!ut.hK Necause a very !arge window system sotware vendor

    &who wi!! remain name!ess' has an apparent inabi!ity to appreciate that

    LpenG3Ts AP) is independent o their window system AP)" portab!e A/) C

    G3% programs shou!d not direct!y inc!ude >G3#g!.hK or >G3#g!u.hK.

    )nstead" A/) C G3% programs shou!d re!y on >G3#g!ut.hK to inc!ude the

    necessary LpenG3 and G3 re!ated header i!es.

    %he A/) C G3% !ibrary archive is typica!!y named !ibg!ut.a on ni

    systems. G3% programs need to !ink with the systemTs LpenG3 and G3%

    !ibraries &and any !ibraries these !ibraries potentia!!y depend on'.

    A set o window system dependent !ibraries may a!so be necessary or !inking

    G3% programs.

  • 8/10/2019 1rz13mca08 Cg report

    8/22

    Computer Graphics Project 2014

    returns a uni$ue identiier or the new window. %his unction sends the re$uest or

    new window to be constructed.

    gl4erte! &%he main unction &and probab!y the most used LpenG3 unction' is

    unction named g!,erte. %his unction deines a point &or a verte' in your =( wor!d

    and it can vary rom receiving 2 up to 4 coordinates.

    g!,erte2&100.0" 1?0.0'M deines a point at 9 100" y 9 1?0" F 9 0M this unction

    takes on!y 2 parameters" F is a!ways 0. g!,erte2 can be used in specia! cases and

    wonTt be used a !ot un!ess youTre working with pseudo2( sprites or triang!es and

    points that a!ways have to be constrained by the depth coordinate.

    g!,erte=&100.0" 1?0.0" 2?.0'M deines a point at 9 100" y 9 1?0" F 9 2?.0M

    this unction takes = parameters" deining a u!!y =( point in your wor!d.

    g!,erte4&100.0" 1?0.0" 2?.0" 1.0'M this is the same as g!,erte=" the on!y

    dierence is in the !ast coordinate that speciies a sca!ing actor. %he sca!ing actor is

    set to 1.0 by deau!t. )t can be used to make your =( points !ook thicker than one

    pie!.

    gl5egin and gl6nd &g!,erte a!one wonTt draw anything on the screen" it mere!y

    deines a verte" usua!!y o a more comp!e object. %o rea!!y start disp!aying

    something on the screen you wi!! have to use two additiona! unctions. %hese

    unctions are

    g!Negin&int mode'M and g!-nd& void 'M

    g!Negin and g!-nd de!imit the vertices o a primitive or a group o !ike primitives.

    Ihat this means is that everytime you want to draw a primitive on the screen you wi!!

    irst have to ca!! g!Negin" speciying what kind o primitive it is that you want to draw

    in the mode parameter o g!Negin" and then !ist a!! vertices one by one &by

    se$uentia!!y ca!!ing g!,erte' and ina!!y ca!! g!-nd to !et LpenG3 know that youTre

    done drawing a primitive. %he parameter mode o the unction g!Negin can be one o

    the o!!owing6

    G3OPL)%/

    G3O3)-/

    G3O3)-O/%+)P

    (ept.o *CA" +,C- Page o.8

  • 8/10/2019 1rz13mca08 Cg report

    9/22

    Computer Graphics Project 2014

    G3O3)-O3LLP

    )penG( 3olor effects&%he goa! o a!most a!! LpenG3 app!ications is to draw co!or

    pictures in a window on the screen. %he window is a rectangu!ar array o pie!s" each

    o which contains and disp!ays its own co!or. %hus" in a sense" the point o a!! the

    ca!cu!ations perormed by an LpenG3 imp!ementation ca!cu!ations that take into

    account LpenG3 commands" state inormation" and va!ues o parameters is to

    determine the ina! co!or o every pie! thatTs to be drawn in the window. %his chapter

    ep!ains the commands or speciying co!ors and how LpenG3 interprets them in the

    o!!owing major sections6

    UCo!or PerceptionU discusses how the eye perceives co!or.

    UComputer Co!orU describes the re!ationship between pie!s on a

    computer monitor and their co!orsM it a!so deines the two disp!ay modes" +GNA and

    co!or inde.

    U+GNA versus Co!or)nde *odeU ep!ains how the two disp!ay modes use

    graphics hardware and how to decide which mode to use.

    U/peciying a Co!or and a /hading *ode!U describes the LpenG3 commands you

    use to speciy the desired co!or or shading mode!.

    (ept.o *CA" +,C- Page o.9

  • 8/10/2019 1rz13mca08 Cg report

    10/22

    Computer Graphics Project 2014

    2. )77 S3#668

    6nter the percentage of progress in 1styear& 19

    6nter the percentage of progress in 2ndyear& :;

    6nter the percentage of progress in thyear& :9

    'igure1& Graph to analyze the up and downs of a share market using DDA

    algorith.

    (ept.o *CA" +,C- Page o.10

  • 8/10/2019 1rz13mca08 Cg report

    11/22

    Computer Graphics Project 2014

    6nter the te!t& ?6(() #436

    'igure 2& 2D e!t screen saver with " #otation and ranslation.

    (ept.o *CA" +,C- Page o.11

  • 8/10/2019 1rz13mca08 Cg report

    12/22

    Computer Graphics Project 2014

    3onclusion

    A chart visua!iFes the numeric data in a graphica! ormat.Charts are oten used to ease

    understanding o !arge $uantities o data and the re!ationships between parts o the

    data. Charts can usua!!y be read more $uick!y than the raw data that they are produced

    rom.

    %hey are used in a wide variety o ie!ds" and can be created by hand &oten on graph

    paper' or by computer using a charting app!ication. Certain types o charts are more

    useu! or presenting a given data set than others.

  • 8/10/2019 1rz13mca08 Cg report

    13/22

    Computer Graphics Project 2014

    #eferences

    1. (ona!d (. 7earn" * Pau!ine Naker" Iarren Carthers" VComputer Graphics

    output primitivesW in Computer Graphics with LpenG3" 4thedition" Pearson"

    2014" Chapter =" Page no. 4?.

    2. (ona!d (. 7earn" * Pau!ine Naker" Iarren Carthers" VAttributes o Graphics

    primitivesW in Computer Graphics with LpenG3" 4thedition" Pearson" 2014"

    Chapter 4" Page no. DD.

    =. (ona!d (. 7earn" * Pau!ine Naker" Iarren Carthers" V)mp!ementation

    A!gorithms or Graphics primitives and attributesW in Computer Graphics with

    LpenG3" 4thedition" Pearson" 2014" Chapter ?" Page no. 1=1.

    (ept.o *CA" +,C- Page o.13

  • 8/10/2019 1rz13mca08 Cg report

    14/22

    Computer Graphics Project 2014

    Source 3ode

    @@1.Generate a graph to analyze the up and downs of a share market using DDA

    algorith

    Sinc!ude>iostreamK

    Sinc!ude>cstdioK

    Sinc!ude>G3#g!.hK

    Sinc!ude>G3#g!u.hK

    Sinc!ude>G3#g!ut.hK

    Sinc!ude>math.hK

    using namespace stdM

    void initia!iFe&'M

    void disp!ay&'M

    void d!&int"int"int"int'M

    void i!!&int"int'M

    int a:20;"nM

    !oat 90.2"e91.0M

    int main&int argc"char@@ argv'Q

    cout>>Uenter the number o bar chartsXnUM

    cinKKnM

    cout>>Uenter user va!uesXnUM

    or&int i90Mi>nMiEE'

    Q

    cinKKa:i;M

    R

    or&int i90Mi>nMiEE'

    (ept.o *CA" +,C- Page o.14

  • 8/10/2019 1rz13mca08 Cg report

    15/22

    Computer Graphics Project 2014

    Q

    a:i;9?0E&a:i;@?'M

    R

    g!ut)nit&Yargc"argv'M

    g!ut)nit(isp!ay*ode&G3%O/)G3-JG3%O+GN'M

    g!ut)nitIindow/iFe&D00"D00'M

    g!ut)nitIindowPosition&00"00'M

    g!utCreateIindow&Uchess boardU'M

    g!ut(isp!ay

  • 8/10/2019 1rz13mca08 Cg report

    16/22

    Computer Graphics Project 2014

    Q

    or&int i9Mi>E?0MiEE'

    d!&i"y"i"yE?0'M

    R

    void draw/tring1&!oat " !oat y'Q

    g!Co!or=&1.0" 0.0" 0.0'M

    g!+asterPos2&" y'M

    char scoreArr:=00;M

    sprint&scoreArr" UProgress in percentageU'M

    or &const char@ c9scoreArrM @c Z9 TX0TM cEE'Q

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12" @c'M ## pdates the

    position

    R

    R

    void draw/tring&!oat " !oat y'

    Q

    g!Co!or=&1.0" 0.0" 0.0'M

    g!+asterPos2&" y'M

    char scoreArr:=00;M

    sprint&scoreArr" U 2010 2011 2012 201= 2014

    >work in yearU'M

    or &const char@ c9scoreArrM @c Z9 TX0TM cEE'

    Q

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12" @c'M ##

    pdates the position

    (ept.o *CA" +,C- Page o.16

  • 8/10/2019 1rz13mca08 Cg report

    17/22

    Computer Graphics Project 2014

    R

    R

    void disp!ay&'

    Q

    int c90M

    d!&=0"?0"=0"?B0'M

    d!&=0"?0"4?0"?0'M

    draw/tring1&B"00'M

    draw/tring&20"=0'M

    g!+asterPos2i&10"?0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"100'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T1T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"1?0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T2T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"200'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T=T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"2?0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T4T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"=00'M

    (ept.o *CA" +,C- Page o.17

  • 8/10/2019 1rz13mca08 Cg report

    18/22

    Computer Graphics Project 2014

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T?T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"=?0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"TT'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"400'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"TBT'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"4?0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"TT'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"?00'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"TDT'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!+asterPos2i&10"??0'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T1T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    g!utNitmapCharacter&G3%ON)%*APO7-3,-%)CAO12"T0T'M

    ##draw/tring&10.0"4?.0"0.0'M

    or&int F90MF>nMFEE'

    Q

    g!Co!or=&0.?"0.?"'M

    or&int i9??Mi>a:F;MiEE'

    d!&?0@FE40"i"?0@&FE1'"i'M

    9E0.=M

    (ept.o *CA" +,C- Page o.18

  • 8/10/2019 1rz13mca08 Cg report

    19/22

    Computer Graphics Project 2014

    i&K1'

    91M

    g!

    R

    void d!&int 1"int y1"int 2"int y2'

    Q

    int s"d"dy"mM

    !oat i"yi""yM

    d921M

    dy9y2y1M

    i&abs&d'Kabs&dy''

    s9abs&d'M

    e!se

    s9abs&dy'M

    i9d#!oat&s'M

    yi9dy#!oat&s'M

    91M

    y9y1M

    g!Negin&G3OPL)%/'M

    g!,erte2&"y'M

    g!-nd&'M

    or&m90Mm>sMmEE'

    Q

    (ept.o *CA" +,C- Page o.19

  • 8/10/2019 1rz13mca08 Cg report

    20/22

    Computer Graphics Project 2014

    E9iM

    yE9yiM

    g!Negin&G3OPL)%/'M

    g!,erte2&"y'M

    g!-nd&'M

    R

    R

    ##2. Develop 2D e!t screen saver with " #otation and ranslation'

    Sinc!ude >string.hK

    Sinc!ude >G3#g!ut.hK

    void @ont 9 G3%ON)%*APO%)*-/O+L*AO24M

    void @onts:; 9QG3%O/%+L[-O+L*A" G3%O/%+L[-O*LLO+L*ARM

    char deau!t*essage:; 9 Uee!endu /hekharUM

    char deau!t*essage1:; 9 U/hekharUM

    char @message 9 deau!t*essageM

    int ang!e 9 0M

    void tick&void'

    Q

    ang!e 9 ?M

    g!utPost+edisp!ay&'M

    R

    void tick1&void'

    Q

    ang!e E9 ?M

    g!utPost+edisp!ay&'M

    (ept.o *CA" +,C- Page o.20

  • 8/10/2019 1rz13mca08 Cg report

    21/22

    Computer Graphics Project 2014

    R

    void disp!ay&void'

    Q

    int !en" iM

    g!C!ear&G3OCL3L+ON9200000MiEE'

    R

    int main&int argc" char @@argv'

    Q

    int i" submenuM

    g!ut)nit&Yargc" argv'M

    g!ut)nit(isp!ay*ode&G3%O(LN3- J G3%O+GN'M

    g!ut)nitIindow/iFe&00" 00'M

    (ept.o *CA" +,C- Page o.21

  • 8/10/2019 1rz13mca08 Cg report

    22/22

    Computer Graphics Project 2014

    g!utCreateIindow&Utet rotation screen saverU'M

    g!*atri*ode&G3OP+L-C%)L'M

    g!3oad)dentity&'M

    g!uLrtho2(&0" 2000" 0" 2000'M

    g!*atri*ode&G3O*L(-3,)-I'M

    g!-nab!e&G3O3)-O/*LL%7'M

    g!-nab!e&G3ON3-('M

    g!N!end


Recommended