-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindowclass.cs
More file actions
105 lines (102 loc) · 4 KB
/
Copy pathwindowclass.cs
File metadata and controls
105 lines (102 loc) · 4 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
namespace graphicsengine
{
static class frame{
const char usedchar='*';
const char emptychar=' ';
private static int logline;
static char[,] display;
static char[,] todisplay;
public static void initialze(int width , int height){
display=new char[width,height]; // Noncompliant
todisplay = new char[width,height]; // Noncompliant
for(int i=0; i<width;i++){
for(int j = 0;j<height;j++){
display[i,j]=emptychar;
todisplay[i,j]=emptychar;
}
}
}
public static void fullflip(){
Console.Clear();
for(int x=0; x<display.GetLength(0);x++){
for(int y=0;y<display.GetLength(1);y++){
Console.SetCursorPosition(x,y);
display[x,y]=todisplay[x,y];
Console.Write(display[x,y]); // Noncompliant
}
}
}
public static void Clear(){
for(int i =0; i <todisplay.GetLength(0);i++){
for(int j=0; j<todisplay.GetLength(1);j++){
todisplay[i,j]=emptychar;
}
}
}
public static void fill(char filler){
for(int i =0; i <todisplay.GetLength(0);i++){
for(int j=0; j<todisplay.GetLength(1);j++){
todisplay[i,j]=filler;
}
}
}
public static void sidelog(string txt, int xoffset=0, int yoffset=-1,int extrapadding=10){
if(yoffset==-1){yoffset=logline;logline++;if(logline>todisplay.GetLength(1)){logline=0;}}
Console.SetCursorPosition(todisplay.GetLength(0)+xoffset,yoffset);
Console.Write(txt.PadRight(extrapadding));
}
public static void renderline(line li){
char thechar = usedchar;
if(li.spcecialchar!=' '){
thechar = li.spcecialchar;
}
if ((li.getuper().Y-li.getlower().Y)>(li.getrightmost().X-li.getleftmost().X)){
for( double i = li.getlower().Y; i<li.getuper().Y; i++){
double x = li.gethorizontalintersection(i);
int y = (int)(i);
int xx = (int)(x);
if( xx>=0 && xx<todisplay.GetLength(0) && y>=0 && y<todisplay.GetLength(1)){
todisplay[xx,y]=thechar;
}
}
}else {
for( double i = li.getleftmost().X; i<li.getrightmost().X; i++){
double y = li.getverticalintersection(i);
int yy = (int)(y);
int x = (int)(i);
if( x>=0 && x<todisplay.GetLength(0) && yy>=0 && yy<todisplay.GetLength(1)){
todisplay[x,yy]=thechar;
}
}
}
}
public static void renderpolygons(){
foreach( polygon poly in polygon.allthePolygon){
foreach(line li in poly.lines){
renderline(li);
}
}
}
public static void drawcircle(int xcenter, int ycenter, int radius, char fillchar='*'){
for(int x=0; x<todisplay.GetLength(0);x++){
for(int y=0;y<todisplay.GetLength(1);y++){
if(Math.Sqrt((x-xcenter)*(x-xcenter)+(y-ycenter)*(y-ycenter))<radius){
todisplay[x,y]=fillchar;
}
}
}
}
public static void flip(){
for(int x=0; x<display.GetLength(0);x++){
for(int y=0;y<display.GetLength(1);y++){
if(display[x,y]!=todisplay[x,y]){
Console.SetCursorPosition(x,y);
Console.Write(todisplay[x,y]);
display[x,y]=todisplay[x,y]; // Noncompliant
}
}
}
}
}
}