-
Notifications
You must be signed in to change notification settings - Fork 1
/
star.cpp
41 lines (31 loc) · 924 Bytes
/
star.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* star.cpp
* 4/19/2016
*
* CS 372 Sp16
* Group Project 2: Postscript Generator
*/
#include "star.h"
string Star::draw() const{
return draw(x_,y_);
}
string Star::draw(int x, int y) const{
stringstream ss;
ss << psHeader(x,y);
double oVertX = getConvexX(0,numOfPoints_,outerRadius_);
double oVertY = getConvexY(0,numOfPoints_,outerRadius_);
ss << psMove(oVertX,oVertY);
double iVertX = getConcaveX(0,numOfPoints_,innerRadius_);
double iVertY = getConcaveY(0,numOfPoints_,innerRadius_);
ss << psLine(iVertX,iVertY);
for(int i = 1; i < numOfPoints_; i++){
double oVertX = getConvexX(i,numOfPoints_,outerRadius_);
double oVertY = getConvexY(i,numOfPoints_,outerRadius_);
ss << psLine(oVertX,oVertY);
double iVertX = getConcaveX(i,numOfPoints_,innerRadius_);
double iVertY = getConcaveY(i,numOfPoints_,innerRadius_);
ss << psLine(iVertX,iVertY);
}
ss << psFooter();
return ss.str();
}