-
Notifications
You must be signed in to change notification settings - Fork 2
/
pcb_design_020.pde
149 lines (128 loc) · 4.8 KB
/
pcb_design_020.pde
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
PCBArt
------
ver 0.2.5
Program by: Alon Gruss.
Last Edited in: 21/11/16.
The app works in following manner:
image > brightness layers > [BITWISE COMPOSE BRD LAYERS] > export to xml polygons
(while constantly giving back visual feedback)
///////////////////////safe-zone-start/////////////////////////////
/*
UI
--------------
*/
import g4p_controls.*;
GButton b_open;
GButton b_quadtree;
GButton b_export;
GCustomSlider[] slider_array;
String status_msg = "";
boolean loading=false;
float loading_percent = 0.5;
/*
DEBUG CONTROLS
--------------
*/
boolean DEBUG_NO_IMAGE_MODE = true;
/*
DEFAULTS
--------------
*/
int DEFAULT_IMAGE_WIDTH = 500;
int DEFAULT_IMAGE_HEIGHT = 500;
int DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH = 167;
int DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT = 167;
int DEFAULT_IMAGE_BRD_LAYER_PREVIEW_WIDTH = 84;
int DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT = 84;
int DEFAULT_WINDOW_WIDTH = 2*DEFAULT_IMAGE_WIDTH+3*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH+DEFAULT_IMAGE_BRD_LAYER_PREVIEW_WIDTH;
int DEFAULT_WINDOW_HEIGHT = 530;
int DEFAULT_STATUS_BAR_WIDTH = DEFAULT_WINDOW_WIDTH-1;
int DEFAULT_STATUS_BAR_HEIGHT = 30;
/*
IMAGES
--------------
*/
PImage input_image;
PImage resized_input_image;
PImage[] brightness_layer_images = new PImage[8];
PImage[] BRD_layer_images = new PImage[6];
PImage output_preview_image;
/*
IO
--------------
*/
boolean image_loaded = false;
PrintWriter BRD_writer;
String file_location = "";
float BRD_scalar = 0.14;
/*
QUADTREE
--------------
*/
Quad_Class_Thread outer_thread;
int number_of_iterations = 7;
Rect_Class[][] rect_array;
int qt_count = 0;
int full_pixel_count = 1;
void settings() {
size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
noSmooth();
}
void setup() {
surface.setTitle("PCB as ART ver.0.2.2");
setup_UI();
rect_array = new Rect_Class[6][0];
//for (int i=0;i<rect_array.length;i++){
// rect_array[i] = new Rect_Class[0];
//}
}
void draw() {
//loading_percent = mouseX/float(width);
background(200);
stroke(0);
fill(100);
if (image_loaded) {
if (resized_input_image!=null) {
image(resized_input_image, 0, 0, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
}
for (int i=0; i<brightness_layer_images.length; i++) {
if (brightness_layer_images[i]!=null) {
image(brightness_layer_images[i], DEFAULT_IMAGE_WIDTH+(i%3)*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, floor(i/3)*DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT, DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT);
noFill();
rect(DEFAULT_IMAGE_WIDTH+(i%3)*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, floor(i/3)*DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT, DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT);
} else {
//fill(255,0,0);
//rect(DEFAULT_IMAGE_WIDTH+(i%3)*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, floor(i/3)*DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT, DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, DEFAULT_IMAGE_SCREEN_PREVIEW_HEIGHT);
}
}
for (int i=0; i<BRD_layer_images.length; i++) {
if (BRD_layer_images[i]!=null) {
image(BRD_layer_images[i], DEFAULT_IMAGE_WIDTH+3*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, i*DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_WIDTH, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT);
noFill();
rect(DEFAULT_IMAGE_WIDTH+3*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, i*DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_WIDTH, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT);
} else {
//fill(255,0,0);
//rect(DEFAULT_IMAGE_WIDTH+3*DEFAULT_IMAGE_SCREEN_PREVIEW_WIDTH, i*DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_WIDTH, DEFAULT_IMAGE_BRD_LAYER_PREVIEW_HEIGHT);
}
}
//for (int i=0; i<rect_array.length; i++) {
if (rect_array[3]!=null) {
for (int j=0; j<rect_array[3].length; j++) {
rect_array[3][j].display();
}
}
//}
if (output_preview_image!=null) {
image(output_preview_image, DEFAULT_WINDOW_WIDTH-DEFAULT_IMAGE_WIDTH, 0, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
noFill();
rect(DEFAULT_WINDOW_WIDTH-DEFAULT_IMAGE_WIDTH, 0, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
} else {
//fill(255,0,0);
//rect(DEFAULT_WINDOW_WIDTH-DEFAULT_IMAGE_WIDTH, 0, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT);
}
}
draw_status_bar(300, DEFAULT_WINDOW_HEIGHT-DEFAULT_STATUS_BAR_HEIGHT, (DEFAULT_STATUS_BAR_WIDTH-300)*0.5, DEFAULT_STATUS_BAR_HEIGHT-1);
draw_loading_bar(300+(DEFAULT_STATUS_BAR_WIDTH-300)*0.5, DEFAULT_WINDOW_HEIGHT-DEFAULT_STATUS_BAR_HEIGHT, (DEFAULT_STATUS_BAR_WIDTH-300)*0.5, DEFAULT_STATUS_BAR_HEIGHT-1);
}
/////////////////////////safe-zone-finish/////////////////////////////