@@ -33,6 +33,16 @@ export class SSD1306Element extends LitElement {
33
33
34
34
static get styles ( ) {
35
35
return css `
36
+ .container {
37
+ position: relative;
38
+ }
39
+
40
+ .container > canvas {
41
+ position: absolute;
42
+ left: 11.5px;
43
+ top: 27px;
44
+ }
45
+
36
46
.pixelated {
37
47
image-rendering: crisp-edges; /* firefox */
38
48
image-rendering: pixelated; /* chrome/webkit */
@@ -70,10 +80,9 @@ export class SSD1306Element extends LitElement {
70
80
}
71
81
72
82
render ( ) : SVGTemplateResult {
73
- const { width, height, screenWidth, screenHeight, imageData } = this ;
74
- const visibility = imageData ? 'visible' : 'hidden' ;
75
- return html `< svg width ="${ width } " height ="${ height } " xmlns ="http://www.w3.org/2000/svg ">
76
- < g >
83
+ const { width, height, screenWidth, screenHeight } = this ;
84
+ return html ` < div class ="container ">
85
+ < svg width ="${ width } " height ="${ height } " xmlns ="http://www.w3.org/2000/svg ">
77
86
< rect stroke ="#BE9B72 " fill ="#025CAF " x =".5 " y =".5 " width ="148 " height ="114 " rx ="13 " />
78
87
79
88
< g transform ="translate(6 6) " fill ="#59340A " stroke ="#BE9B72 " stroke-width ="0.6px ">
@@ -83,23 +92,8 @@ export class SSD1306Element extends LitElement {
83
92
< circle cx ="6 " cy ="96 " r ="5.5 " />
84
93
</ g >
85
94
86
- < g transform ="translate(11.4 26) ">
87
- <!-- 128 x 64 screen -->
88
- < rect fill ="#1A1A1A " width ="${ screenWidth } " height ="${ screenHeight } " />
89
- <!-- image holder -->
90
- < foreignObject
91
- ?visibility ="${ visibility } "
92
- width ="${ screenWidth } "
93
- height ="${ screenHeight } "
94
- >
95
- < canvas
96
- width ="${ screenWidth } "
97
- height ="${ screenHeight } "
98
- style ="position: fixed "
99
- class ="pixelated "
100
- > </ canvas >
101
- </ foreignObject >
102
- </ g >
95
+ <!-- 128 x 64 screen -->
96
+ < rect x ="11.4 " y ="26 " fill ="#1A1A1A " width ="${ screenWidth } " height ="${ screenHeight } " />
103
97
104
98
<!-- All texts -->
105
99
< text
@@ -138,7 +132,8 @@ export class SSD1306Element extends LitElement {
138
132
< circle stroke ="#B4AEAB " cx ="12.5 " cy ="3.5 " r ="3.5 " />
139
133
< circle stroke ="#E7DBDB " cx ="3.5 " cy ="3.5 " r ="3.5 " />
140
134
</ g >
141
- </ g >
142
- </ svg > ` ;
135
+ </ svg >
136
+ < canvas width ="${ screenWidth } " height ="${ screenHeight } " class ="pixelated "> </ canvas >
137
+ </ div > ` ;
143
138
}
144
139
}
0 commit comments