0% found this document useful (0 votes)
41 views14 pages

VISHAL CHAVARE PROJECT Wall Watch Application Computer Graphics

This micro project report describes the development of an analog wall clock program. The code calculates the positions on the clock face for the hour, minute, and second hands based on the current time. It draws the clock face, including the numbered markings, and updates the positions of the hands each second to display the current time. The program uses trigonometric functions to calculate the x and y coordinates for each time interval. The clock is displayed using graphics mode in a loop, with a one-second delay to continuously update the time.

Uploaded by

71Vishal Chavare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views14 pages

VISHAL CHAVARE PROJECT Wall Watch Application Computer Graphics

This micro project report describes the development of an analog wall clock program. The code calculates the positions on the clock face for the hour, minute, and second hands based on the current time. It draws the clock face, including the numbered markings, and updates the positions of the hands each second to display the current time. The program uses trigonometric functions to calculate the x and y coordinates for each time interval. The clock is displayed using graphics mode in a loop, with a one-second delay to continuously update the time.

Uploaded by

71Vishal Chavare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

MADE BY : -- VISHAL CHAVARE

Pragramme Name :Wall watch Academic Year : 2018-


2019
Subject Name:Computer graphics Semester : Third

A STYDY ON

The

MICRO PROJECT REPORT


Submitted in Nov 2018 by the group of……3….students
Sr. Roll Enrollment Seat
Full name of Student
No No No No
(Sem3)
1
2
3

Under the Guidance of


Your guide name
in
Three Years Diploma Programme in Engineering & Technology of
Maharashtra State Board of Technical Education, Mumbai
(Autonomous)
ISO 9001:2008 (ISO/IEC-27001:2013)

at
[ your college name ]

MAHARASHTRA STATE BOARD OF


TECHNICAL EDUCATION, MUMBAI

Certificate
This is to certify that Mr. /Mrs

Roll No: of Third Semester of Diploma Pro

& Technology at 1734–Trinity Polytechnic Pune, has completed the

Micro Project satisfactorily in Subject computer graphics in the academic

year2018-2019 as per the MSBTE prescribed curriculum of I Scheme.

Place:Pune EnrollmentNo:

Date: / /2018 Exam. SeatNo:


ProjectGuide Head ofthe Department Principal

Index…

Sr. No Title Page No


1 Introduction
2 System requirement specificate(SRS)
3 Implementaion Details(Code)
4 Result/Analysis
5 Conclusion
6 Reference
Introduction:
I’ve used this function to print the clock layout i.e. clock dial and the markings on the clock. If we
observe clearly, the clock has hours marking each separated by 30 degrees and each hour is
divided into 5 markings each making an angle of 6 degrees. So, iterating the markings for every
30 degrees gives hours and iterating markings with 6 degrees give minutes markings on the
clock. The clock would look like this after executing this function.
1

Implementaion Details(code):
  #include <stdio.h>
  #include <conio.h>
  #include <string.h>
  #include <math.h>
  #include <time.h>
  #include <graphics.h>
  #include <dos.h>

  /*
   * find the points at 0, 30, 60,.., 360 degrees
   * on the given circle.  x value correponds to
   * radius * cos(angle) and y value corresponds
   * to radius * sin(angle).  Numbers in the clock
   * are written using the above manipulated x and
   * y values.  And the hour needle movement
   * is based on this
   */

  void calcPoints(int radius, int midx, int midy, int x[12], int y[12]) {
        int x1, y1;

        /* 90, 270, 0, 180 degrees */


        x[0] = midx, y[0] = midy - radius;
        x[6] = midx, y[6] = midy + radius;
        x[3] = midx + radius, y[3] = midy;
        x[9] = midx - radius, y[9] = midy;

        /* 30, 150, 210, 330 degrees */


        x1 = (int) ((radius / 2) * sqrt(3));
        y1 = (radius / 2);
        x[2] = midx + x1, y[2] = midy - y1;
        x[4] = midx + x1, y[4] = midy + y1;
        x[8] = midx - x1, y[8] = midy + y1;
        x[10] = midx - x1, y[10] = midy - y1;

        /* 60, 120, 210, 300 degrees */


        x1 = radius / 2;
        y1 = (int) ((radius / 2)  * sqrt(3));
        x[1] = midx + x1, y[1] = midy - y1;
        x[5] = midx + x1, y[5] = midy + y1;
        x[7] = midx - x1, y[7] = midy + y1;
        x[11] = midx - x1, y[11] = midy - y1;

        return;
 }
2
  /*
   * Calculates position for minute and second needle movement
   * Each quadrant has 90 degrees.  So, we need to split each
   * quadrant into 15 parts(6 degree each) to get the minute
   * and second needle movement
   */
2
 
void minSecCalc(int radius, int midx, int midy, int secx[60], int secy[60]) {
        int i, j = 0, x, y;
        char str[32];

        /* 15 position(min/sec - 12 to 3) in first quadrant of clock  */


        secx[j] = midx, secy[j++] = midy - radius;

        for (i = 96; i < 180; i = i + 6) {


                secx[j] = midx - (radius * cos((i * 3.14) / 180));
                secy[j++] = midy - (radius * sin((i * 3.14) / 180));
    }

        /* 15 positions(min or sec - 3 to 6) in second quadrant of clock */


        secx[j] = midx + radius, secy[j++] = midy;
        for (i = 186; i < 270; i = i + 6) {
                secx[j] = midx - (radius * cos((i * 3.14) / 180));
                secy[j++] = midy - (radius * sin((i * 3.14) / 180));
    }

        /* 15 positions(min or sec - 6 to 9) in third quadrant of clock */


        secx[j] = midx, secy[j++] = midy + radius;
        for (i = 276; i < 360; i = i + 6) {
                secx[j] = midx - (radius * cos((i * 3.14) / 180));
                secy[j++] = midy - (radius * sin((i * 3.14) / 180));
    }

        /* 15 positions(min or sec - 9 to 12) in fourth quadrant of clock */


        secx[j] = midx - radius, secy[j++] = midy;
        for (i = 6; i < 90; i = i + 6) {
                secx[j] = midx - (radius * cos((i * 3.14) / 180));
                secy[j++] = midy - (radius * sin((i * 3.14) / 180));
    }

        return;
 }

  int main() {
        /* request auto detection */
        int gdriver = DETECT, gmode, err, tmp;
        int i, j, midx, midy, radius, hr, min, sec;
        int x[12], y[12], minx[60], miny[60];
        int hrx[12], hry[12], secx[60], secy[60]; 3
        int secx1, secy1;
        char str[256];
        time_t t1;
        struct tm *data;

        /* initialize graphic mode */


        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
        err = graphresult();
        if (err != grOk) {
                /* error occurred */
                printf("Graphics Error: %s",
                                grapherrormsg(err));
                return 0;
3
    }

        /* mid position in x and y -axis */


        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        radius = 200;

        /* position to locate numbers in clock */


        calcPoints(radius - 30, midx, midy, x, y);

        /* gets position for hour needle */


        calcPoints(radius - 90, midx, midy, hrx, hry);

        /* gets position for minute needle */


        minSecCalc(radius - 50, midx, midy, minx, miny);

        /* gets position for second needle */


        minSecCalc(radius - 70, midx, midy, secx, secy);

        while (!kbhit()) {
                setlinestyle(SOLID_LINE, 1, 3);
                settextstyle(TRIPLEX_FONT, 0, 3);

                /* draws frame of the clock */


                circle(midx, midy, radius);

                /* place the numbers  in clock */


                for (j = 0; j < 12; j++) {
                        if (j == 0) {
                                sprintf(str, "%d", 12);
                        } else {
                                sprintf(str, "%d", j);
            }
                        settextjustify(CENTER_TEXT, CENTER_TEXT); 4
                        moveto(x[j], y[j]);
                        outtext(str);
        }

                /* get the current time using time() API */


                t1 = time(NULL);
                data = localtime(&t1);

                /* draw the second needle in clock */


                sec = data->tm_sec % 60;
                line(midx, midy, secx[sec], secy[sec]);

                /* draw the minute needle in clock */


                min = data->tm_min % 60;
                line(midx, midy, minx[min], miny[min]);

                /* draw the hour needle in clock */


                hr = data->tm_hour % 12;
                line(midx, midy, hrx[hr], hry[hr]);

       

  /* sleep for a second */


        
delay(1000);
                cleardevice();
   
 }

        getch();

        /* deallocate memory allocated for graphic screen */


        closegraph();
        return 0;
 }

Result/Analysis:
6

Conclusion:
Thus we have understand that how to create a analog wall watch and represented the time in it.

REFRENCE:
Techamax book of computer graphics.

Technical book of computer graphics.

http://see-programming.blogspot.com/2013/09/c-program-to-implement-analog-
clock.html.

Weekly Work / Progress Report …


Details of 16 Engagement Hours of the
Student Regarding Completion
of the Project
Timing
WeekNo. Sign
Date Duration Work or activity
From To of the
in hours Performed
Guide
Discussion and
1 / /2018 One hour
Finalization of the
Project Title
Two Preparation and
2 / /2018
hours Submission of
Abstracts
Two
3 / /2018 Literature Review
hours
Two
4 / /2018 Collection of Data
hours
Two
5 / /2018 Collection of Data
hours

6 / /2018 One hour Discussion and Outline of


Content

7 / /2018 Two hour Rough Writing of the Projects


Contents
Editing and Proof Reading of
8 / /2018 One hour
the Contents

9 / /2018 Two hour Final Completion of the


Project
Seminar Presentation, viva-
10 / /2018 One hour
vice, Assessment and
Submission of Report

Name of Project Guide:

You might also like