@@ -33,6 +33,16 @@ export class SSD1306Element extends LitElement {
3333
3434 static get styles ( ) {
3535 return css `
36+ .container {
37+ position: relative;
38+ }
39+
40+ .container > canvas {
41+ position: absolute;
42+ left: 11.5px;
43+ top: 27px;
44+ }
45+
3646 .pixelated {
3747 image-rendering: crisp-edges; /* firefox */
3848 image-rendering: pixelated; /* chrome/webkit */
@@ -70,10 +80,9 @@ export class SSD1306Element extends LitElement {
7080 }
7181
7282 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 ">
7786 < rect stroke ="#BE9B72 " fill ="#025CAF " x =".5 " y =".5 " width ="148 " height ="114 " rx ="13 " />
7887
7988 < g transform ="translate(6 6) " fill ="#59340A " stroke ="#BE9B72 " stroke-width ="0.6px ">
@@ -83,23 +92,8 @@ export class SSD1306Element extends LitElement {
8392 < circle cx ="6 " cy ="96 " r ="5.5 " />
8493 </ g >
8594
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 } " />
10397
10498 <!-- All texts -->
10599 < text
@@ -138,7 +132,8 @@ export class SSD1306Element extends LitElement {
138132 < circle stroke ="#B4AEAB " cx ="12.5 " cy ="3.5 " r ="3.5 " />
139133 < circle stroke ="#E7DBDB " cx ="3.5 " cy ="3.5 " r ="3.5 " />
140134 </ g >
141- </ g >
142- </ svg > ` ;
135+ </ svg >
136+ < canvas width ="${ screenWidth } " height ="${ screenHeight } " class ="pixelated "> </ canvas >
137+ </ div > ` ;
143138 }
144139}
0 commit comments