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
|
package coffee.liz.abstractionengine.ui
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
@Composable
fun PCBBackground(modifier: Modifier = Modifier) {
val pcbGreen = Color(0xFF0D5F0D)
val traceColor = Color(0xFF1A7F1A)
val padColor = Color(0xFFD4AF37)
Canvas(modifier = modifier.fillMaxSize().background(pcbGreen)) {
val width = size.width
val height = size.height
// Draw circuit traces (horizontal and vertical lines)
val pathEffect = PathEffect.dashPathEffect(floatArrayOf(10f, 5f), 0f)
// Horizontal traces
for (i in 0..15) {
val y = (i * height / 15)
drawLine(
color = traceColor,
start = Offset(0f, y),
end = Offset(width, y),
strokeWidth = 2f,
pathEffect = pathEffect
)
}
// Vertical traces
for (i in 0..10) {
val x = (i * width / 10)
drawLine(
color = traceColor,
start = Offset(x, 0f),
end = Offset(x, height),
strokeWidth = 2f,
pathEffect = pathEffect
)
}
// Draw pads/components (small circles at intersections)
for (i in 0..10 step 2) {
for (j in 0..15 step 3) {
val x = i * width / 10
val y = j * height / 15
drawCircle(
color = padColor,
radius = 4f,
center = Offset(x, y)
)
}
}
// Draw some resistor-like rectangles
for (i in 1..9 step 4) {
val x = i * width / 10
val y = height / 2
drawRect(
color = Color(0xFF2A4A2A),
topLeft = Offset(x - 15f, y - 8f),
size = androidx.compose.ui.geometry.Size(30f, 16f)
)
// Resistor contacts
drawCircle(
color = padColor,
radius = 3f,
center = Offset(x - 15f, y)
)
drawCircle(
color = padColor,
radius = 3f,
center = Offset(x + 15f, y)
)
}
}
}
|