Skip to content

Commit

Permalink
Yay found my old C++ work!
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteriouspants committed Jun 8, 2011
1 parent d0951e7 commit 54497f9
Show file tree
Hide file tree
Showing 406 changed files with 67,650 additions and 0 deletions.
79 changes: 79 additions & 0 deletions CS116/AnalogClock/AnalogClock.1
@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 9/1/09 \" DATE
.Dt CSDefaultTemplate 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm CSDefaultTemplate,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner
86 changes: 86 additions & 0 deletions CS116/AnalogClock/AnalogClock.cpp
@@ -0,0 +1,86 @@
/*! Chris Miller (cmiller@fsdev.net), CS116
*! Copyright (C) 2009 FSDEV. Aw richts pitten by.
*! Academic endorsement. This code is not licensed for commercial use.
*! 20091130, Chapter 16 Extra Credit
*/

#include "AnalogClock.h"

namespace fsdev {
Point point_for_minute(int minute, int r, int a, int b) {
Point p;
double t = ( 2.0 * 3.14159265 / 60.0 ) * (double)minute - ( 3.14159265 / 2.0 );
p.x = (int)((double)a + (double)r * cos(t));
p.y = (int)((double)b + (double)r * sin(t));
return p;
}
AnalogClock::AnalogClock(Point _origin,
Point _dimensions)
: origin(_origin), dimensions(_dimensions), hour(3), minute(35), second(50) {
add(_origin);
if(dimensions.x!=dimensions.y)
error("Please, an ovular clock? Get a life. Use a circular clock instead.");
}
AnalogClock::AnalogClock(int origin_x,
int origin_y,
int dimensions_x,
int dimensions_y)
: origin(origin_x, origin_y), dimensions(dimensions_x, dimensions_y), hour(3), minute(35), second(50) {
add(Point(origin_x, origin_y));
if(dimensions.x!=dimensions.y)
error("Please, an ovular clock? Get a life. Use a circular clock instead.");
}
void AnalogClock::draw_lines() const {
fl_color(color().as_int());
Point d(dimensions.x, dimensions.y);
Point o((origin.x+dimensions.x)/2,(origin.y+dimensions.y)/2);
// draw sixty tick marks
for(int m=0; m != 60; ++m) {
Point p0 = point_for_minute(m, d.x/2, o.x, o.y);
Point p1 = point_for_minute(m, (d.x-10)/2, o.x, o.y);
fl_line(p0.x, p0.y, p1.x, p1.y);
}
// draw twelve labels
char label[3];
for(int m=1; m!=13; ++m) {
Point p0 = point_for_minute(m*5, d.x/2+10, o.x, o.y);
sprintf(label, "%d", m);
fl_draw(label, p0.x, p0.y);
}
// draw the hour hand
fl_color(Graph_lib::Color(Graph_lib::Color::red).as_int());
int rhand_r = (int)(((double)d.x/2.0)*0.666666666);
Point rhand_p = point_for_minute(hour*5, rhand_r, o.x, o.y);
fl_line(o.x, o.y, rhand_p.x, rhand_p.y);
// draw the minute hand
fl_color(Graph_lib::Color(Graph_lib::Color::blue).as_int());
int mhand_r = (int)(((double)d.x/2.0)*(3.0/5.0));
Point mhand_p = point_for_minute(minute, mhand_r, o.x, o.y);
fl_line(o.x, o.y, mhand_p.x, mhand_p.y);
// draw the second hand
fl_color(Graph_lib::Color(Graph_lib::Color::black).as_int());
int shand_r = (int)(((double)d.x/2.0)*(4.0/5.0));
Point shand_p = point_for_minute(second, shand_r, o.x, o.y);
fl_line(o.x, o.y, shand_p.x, shand_p.y);
}
void AnalogClock::set_minute(int m) {
minute = m;
}
void AnalogClock::set_second(int s) {
second = s;
}
void AnalogClock::set_hour(int h) {
hour = h;
}

int AnalogClock::get_minute() const {
return minute;
}
int AnalogClock::get_second() const {
return second;
}
int AnalogClock::get_hour() const {
return hour;
}

}
44 changes: 44 additions & 0 deletions CS116/AnalogClock/AnalogClock.h
@@ -0,0 +1,44 @@
/*! Chris Miller (cmiller@fsdev.net), CS116
*! Copyright (C) 2009 FSDEV. Aw richts pitten by.
*! Academic endorsement. This code is not licensed for commercial use.
*! 20091130, Chapter 16 Extra Credit
*/

#ifndef __ANALOG_CLOCK_H_
#define __ANALOG_CLOCK_H_

#include "Graph.h"
#include <cmath>
#include <cstdio>
#include <iostream>

namespace fsdev {
Point point_for_minute(int minute, int r, int a, int b);

class AnalogClock : public Graph_lib::Shape {
protected:
Point origin;
Point dimensions;
int minute;
int second;
int hour;
public:
AnalogClock(Point _origin,
Point _dimensions);
AnalogClock(int origin_x,
int origin_y,
int dimensions_x,
int dimensions_y);
void draw_lines() const;

void set_minute(int m);
void set_second(int s);
void set_hour(int h);

int get_minute() const;
int get_second() const;
int get_hour() const;
};
}

#endif

0 comments on commit 54497f9

Please sign in to comment.