GKS presantation

Embed Size (px)

Citation preview

  • 8/8/2019 GKS presantation

    1/39

    Graphical Kernel SystemGKS

    Computer GraphicsCST301-2

    Computer Science & Technology

    Group #1

    Uva Wellassa University

  • 8/8/2019 GKS presantation

    2/39

    DEFINIT

    ION

    GKS defines a common interface tointeractive computer graphics forcreating, manipulating, and displayingor printing computer graphics ondifferent types of computer graphics

    output devices

  • 8/8/2019 GKS presantation

    3/39

    Introduction

    w as the first ISO standard for lo w -level computer graphics ( ISO 10303-46)provides a set of dra w ing features fort w o-dimensional vector graphics suitable for charting and similar duties

  • 8/8/2019 GKS presantation

    4/39

    designed to be portable acrossdifferent programming languages graphics devices Hard w are

    Applications w ritten in GKS w ill bereadily portable to many platforms anddevices

  • 8/8/2019 GKS presantation

    5/39

    Historyintroduced in 1977 by Jos LuisEncarnao (Joseph Luis Incarnation )fairly common on computerw orkstations in the 1980s andearly 1990slatter w as common on the Atari ST is a home/personal computer released by Atari Corporation in 1985

  • 8/8/2019 GKS presantation

    6/39

    Standards D ata model standard - ISO 10303-46 AN SI standard - AN SI X3.124 ISO standard - ISO / IE C 7942Language bindings ISO standard - ISO 8651GKS-3D ISO standard - ISO 8805C bindings standard - ISO 8806

  • 8/8/2019 GKS presantation

    7/39

    Objectives of the GKS

    production and manipulation of picturesSuch pictures vary from simple line graphs engineering dra w ings integrated circuit layouts images representing medical data astronomical data

    E ach of these various pictures can bedescribed by GKS

  • 8/8/2019 GKS presantation

    8/39

  • 8/8/2019 GKS presantation

    9/39

    Main

    Primitives in GKS

    1. Polyline - dra w s a sequence ofconnected line segments

    2. Polymarker - marks a sequence of pointsw ith the same symbol

    3. Fill area - displays a specified area

    4. Text - dra w s a string of characters5. Cell array - displays an image composed

    of a variety of colours or grey scales

  • 8/8/2019 GKS presantation

    10/39

    Parameters

    Set of parameters are associated w itheach primitivesUsed to define particular instances ofthat primitive

    F or example, the parameters of thetext primitive : String or characters to be dra w n Starting position of that string

  • 8/8/2019 GKS presantation

    11/39

    Attributes

    A lthough the parameters define theprimitives to be specified

    additional data are necessary to describethe actual appearance of the primitivesThese additional data are kno w n asAttributes

    F or example, in text primitive height of a character string angle at w hich it is to be dra w n

    O nce a attribute is define several primitivescan be plotted using that attribute

  • 8/8/2019 GKS presantation

    12/39

    Coordinate SystemsConsists of 2-axis X axis and Y axis

    Unit length on the t w o axes can be same A lso it is possible to define differentialscaling on the t w o axes

  • 8/8/2019 GKS presantation

    13/39

    User Coordinates

    The user w ill have a preferred coordinatesystem in w hich he w ould like to w ork

    That is kno w as user coordinatesMost frequently, this coordinate system w illbe a Cartesian coordinate system

    It is also possible that the user coordinatesystem might be logarithmically scaled or

    polar coordinates But GKS only understood Cartesiancoordinate systems

  • 8/8/2019 GKS presantation

    14/39

    World Coordinates

    If the user coordinate system is notCartesian

    The user himself must map his coordinatesystem onto a Cartesian systemTo differentiate bet w een the preferreduser coordinates and the ones presentedto GKSThe term w orld coordinates (WC) is used

    to define a coordinate system used topresent graphical output to GKS

  • 8/8/2019 GKS presantation

    15/39

    PolylineThe main line dra w ing primitive of GKS

    F unction : POLYLINE(N, XPTS, YPTS)XPTS and YPTS are arrays giving the N points(XPTS(1), YPTS(1)) to (XPTS(N),

    YPTS(N))Generated consists of N - 1 line segmentsjoining adjacent points starting w ith the

    first point and endingw

    ith the last

  • 8/8/2019 GKS presantation

    16/39

    E x: P lot a graph of a set of data, usingset of ordered pairs (X, Y)

    R EAL XDK(19), YDK(19)

    DATA XDK/O.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,

    16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0/

    DATA YDK/8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,13.2/

    POLYLINE(19, XDK, YDK)

    R EAL XDK(19), YDK(19)

    DATA XDK/O.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,

    16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0/

    DATA YDK/8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,13.2/

    POLYLINE(19, XDK, YDK)

  • 8/8/2019 GKS presantation

    17/39

    Above code segment w ill produces the outputgiven belo w

  • 8/8/2019 GKS presantation

    18/39

    Ploymarker

    Instead of dra w ing lines, mark the setof pointsP olymarker places a centred marker ateach point

    F unction: POLYMAR KER (N, XPTS,

    YPTS) Arguments are the same as for thepolyline function

  • 8/8/2019 GKS presantation

    19/39

    E x: P lot a data points of set of data,using set of ordered pairs (X, Y)

    R EAL XDK(19), YDK(19)

    DATA XDK/O.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,

    16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0/

    DATA YDK/8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,13.2/

    POLYMAR KER (l9, XDK, YDK)

    R EAL XDK(19), YDK(19)

    DATA XDK/O.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,

    16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0/

    DATA YDK/8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,13.2/

    POLYMAR KER (l9, XDK, YDK)

  • 8/8/2019 GKS presantation

    20/39

  • 8/8/2019 GKS presantation

    21/39

    Fill AreaLine dra w ings are insufficient for manyapplications

    Define a fill areaWhich can completely fill an area

    w ith a single colour by repeating a pattern

    An array of points is specified w hichdefines the boundary of the area

    If the area is not close GKS join the last

    point to the first point

  • 8/8/2019 GKS presantation

    22/39

    F unction : F ILL A R EA(N, XPTS,YPTS)

    R EAL XDK(43), YDK(43)

    DATA XDK/0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0, 28.8, 27.2, 25.0, 23.0, 21.5, 21.1, 21.5,22.8, 24.1, 25.1, 25.2, 24.2, 22.1, 20.0, 18.0, 16.0,14.0, 12.0, 10.0, 8.0, 6.1, 4.2, 3.0, 1.3/

    DATA YDK/ 8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,

    13.2, 12.3, 11.5, 11.5, 11.5, 11.2, 10.5, 9.0, 8.0, 7.0,5.1, 3.6, 1.9, 1.1, 0.9, 0.7, 0.8, 1.0, 1.0, 1.2, 1.8,2.1, 2.9, 4.1, 6.0/

    SET F ILL A R EA INDEX(1)

    F ILL A R EA(43, XDK, YDK)

    R EAL XDK(43), YDK(43)

    DATA XDK/0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0,16.4, 17.0, 17.3, 17.8, 18.5, 20.0, 22.0, 24.0, 26.0,28.0, 29.0, 28.8, 27.2, 25.0, 23.0, 21.5, 21.1, 21.5,22.8, 24.1, 25.1, 25.2, 24.2, 22.1, 20.0, 18.0, 16.0,14.0, 12.0, 10.0, 8.0, 6.1, 4.2, 3.0, 1.3/

    DATA YDK/ 8.8, 7.6, 7.1, 7.4, 8.0, 8.9, 9.6, 9.9, 9.4,9.7, 12.0, 14.0, 16.1, 17.0, 17.0, 16.0, 13.9, 13.1,

    13.2, 12.3, 11.5, 11.5, 11.5, 11.2, 10.5, 9.0, 8.0, 7.0,5.1, 3.6, 1.9, 1.1, 0.9, 0.7, 0.8, 1.0, 1.0, 1.2, 1.8,2.1, 2.9, 4.1, 6.0/

    SET F ILL A R EA INDEX(1)

    F ILL A R EA(43, XDK, YDK)

  • 8/8/2019 GKS presantation

    23/39

    Above code segment w ill produces theoutput given belo w

  • 8/8/2019 GKS presantation

    24/39

    SET F ILL A R EA INDEX(2) SET F ILL A R EA INDEX(3)

    FI LLAREA INDE X() can be used to definethe fill pattern of the fill area

  • 8/8/2019 GKS presantation

    25/39

    TextGKS has a text primitive w hich is used toplace a String

    F unction : TEXT(X, Y, ST R ING) (X, Y) is the text position ST R ING is a string of characters

    E x: TEXT(6, 3, 'A Character String')

  • 8/8/2019 GKS presantation

    26/39

    Text Attributes -HEIGHT

    The character height attributedetermines the height of the

    characters in the string

    Since a character in a font w ill have a

    designed aspect ratio, the characterheight also determines the characterw idth.

  • 8/8/2019 GKS presantation

    27/39

    The character height is set by thefunction SET CHA R ACTE R HEIGHT(H)

    w here H is the character height

  • 8/8/2019 GKS presantation

    28/39

    SET CHA R ACTE R HEIGHT(1)

    TEXT(-2, 11. 'Character Height 1')

    SET CHAR

    ACTER

    HEIGHT(2)TEXT( -2. 5, 'Character Height 2')

  • 8/8/2019 GKS presantation

    29/39

    Text Attributes - C HARA C TER UP VE C TOR

    O ne of the most important text attributeMain purpose is to determine the

    orientation of the characters It also sets a reference direction w hich isused in the determination of text pathand text alignmentSET CHA R ACTE R UP VECTO R (X, Y)X and Y are the offsets from the textposition of the up direction of the

    characters

  • 8/8/2019 GKS presantation

    30/39

    SET CHA R ACTE R UP VECTO R (-1, 1)

    TEXT(6, 3, 'A Character String')

    SET CHA R ACTE R UP VECTO R (0, 1)SET TEXT PATH(DOWN)

    TEXT(10, 17, 'G R AND HOTEL')

    SET CHA R ACTE R UP VECTO R (1, 6)

    SET TEXT PATH(DOWN)

    TEXT(12, 16, 'HOTEL PISA')

  • 8/8/2019 GKS presantation

    31/39

    Acomplete GKS program

  • 8/8/2019 GKS presantation

    32/39

    Cell Arraymore specialized output primitiveallo w s images to be output

    F unction : CELL A RR AY(XL, YL, X R , Y R , DIMX,

    DIMY, SX, SY, DX, DY, CA)

  • 8/8/2019 GKS presantation

    33/39

    The t w o points in w orld coordinates(XL,YL) and (XR ,YR) specify the opposite

    corners of a rectangular area w hich is to be divided into DX cells in theX direction and DY cells in the Y direction

    Associated

    with each cell is a colourspecified by the entry in the array C A(I,J)

    w here I takes values from SX to (SX+ DX-1)and J takes values from SY to (SY+ DY-1)

  • 8/8/2019 GKS presantation

    34/39

    The corner cell at (XL,YL) correspondsto the array element C A(SX,SY) and theone at (X R ,YR) corresponds toCA(SX+DX-1 ,SY+DY-1)The entry C A(l,J) contains the position

    in the w orkstation colour table w herethe RGB values of the colour arespecified

  • 8/8/2019 GKS presantation

    35/39

  • 8/8/2019 GKS presantation

    36/39

    The area of the pixel array and the colournumbers associated w ith the cells are

    specified in the virtual side of GKSThe colour look-up table is specific to aparticular w orkstation

  • 8/8/2019 GKS presantation

    37/39

    It is quite easy to specify a cell arrayw hich can be vie w ed quite differentlyon t w o different w orkstations O ne could have a colour table

    specifying the picture as a grey scale

    image w hile a second specifies it as a pseudo

    colour one.

  • 8/8/2019 GKS presantation

    38/39

    Group Members

    UWU/CST/08/0001UWU/CST/08/0002UWU/CST/08/0003UWU/CST/08/0004UWU/CST/08/0005UWU/CST/08/0006UWU/CST/08/0007UWU/CST/08/0008UWU/CST/08/0009UWU/CST/08/0010

    12345

    D .H.G. M De SilvaG.W.S.S.K De Silva8910

  • 8/8/2019 GKS presantation

    39/39

    Thank You..!