@@ -44,6 +44,44 @@ export default class XPgPocoBasic extends HTMLElement {
4444 this . $code . value = extractBody ( demos [ 0 ] . run ) ;
4545 this . $run . addEventListener ( 'click' , this . handleRun . bind ( this ) ) ;
4646 this . $error . style . display = 'none' ;
47+ // Load testing resources
48+ this . $poco . setResource ( 'colorBitmap.bmp' , 40 , 40 , ( ctx , w , h ) => {
49+ ctx . fillStyle = "#fff" ; ctx . fillRect ( 0 , 0 , w , h ) ;
50+ ctx . fillStyle = "#000" ; ctx . fillRect ( 4 , 4 , 32 , 32 ) ;
51+ ctx . fillStyle = "#fff" ; ctx . fillRect ( 8 , 8 , 24 , 24 ) ;
52+ ctx . fillStyle = "#000" ; ctx . fillRect ( 12 , 12 , 16 , 16 ) ;
53+ ctx . fillStyle = "#fff" ; ctx . fillRect ( 16 , 16 , 8 , 8 ) ;
54+ } ) ;
55+ this . $poco . setResource ( 'monoBitmap.bmp' , 32 , 32 , ( ctx , w , h ) => {
56+ ctx . fillStyle = "#fff" ; ctx . fillRect ( 0 , 0 , w , h ) ;
57+ ctx . strokeStyle = "#000" ; ctx . lineWidth = 1 ;
58+ ctx . strokeRect ( 0.5 , 0.5 , w - 1 , h - 1 ) ;
59+ ctx . beginPath ( ) ; ctx . moveTo ( 0 , 0 ) ; ctx . lineTo ( w / 2 , h / 2 ) ; ctx . lineTo ( w , 0 ) ; ctx . stroke ( ) ;
60+ ctx . beginPath ( ) ; ctx . moveTo ( 0 , h ) ; ctx . lineTo ( w / 2 , h / 2 ) ; ctx . lineTo ( w , h ) ; ctx . stroke ( ) ;
61+ } ) ;
62+ this . $poco . setResource ( 'grayBitmap.bmp' , 32 , 32 , ( ctx , w , h ) => {
63+ const grad = ctx . createRadialGradient ( w / 2 , h / 2 , 2 , w / 2 , h / 2 , w / 2 ) ;
64+ grad . addColorStop ( 0 , "#fff" ) ;
65+ grad . addColorStop ( 1 , "#000" ) ;
66+ ctx . fillStyle = grad ;
67+ ctx . fillRect ( 0 , 0 , w , h ) ;
68+ } ) ;
69+ this . $poco . setResource ( 'circleMask.bmp' , 40 , 40 , ( ctx , w , h ) => {
70+ ctx . fillStyle = "#000" ; ctx . fillRect ( 0 , 0 , w , h ) ;
71+ const grad = ctx . createRadialGradient ( w / 2 , h / 2 , 0 , w / 2 , h / 2 , w / 2 ) ;
72+ grad . addColorStop ( 0 , "#fff" ) ;
73+ grad . addColorStop ( 1 , "#000" ) ;
74+ ctx . fillStyle = grad ;
75+ ctx . beginPath ( ) ; ctx . arc ( w / 2 , h / 2 , w / 2 , 0 , Math . PI * 2 ) ; ctx . fill ( ) ;
76+ } ) ;
77+ this . $poco . setResource ( 'patternBitmap.bmp' , 30 , 30 , ( ctx , w , h ) => {
78+ const size = 10 ;
79+ for ( let r = 0 ; r < h ; r += size )
80+ for ( let c = 0 ; c < w ; c += size ) {
81+ ctx . fillStyle = ( ( r + c ) / size % 2 === 0 ) ? "#000" : "#fff" ;
82+ ctx . fillRect ( c , r , size , size ) ;
83+ }
84+ } ) ;
4785 }
4886
4987 handleRun ( ) {
0 commit comments