@@ -21,88 +21,87 @@ const samePixels = require('./util/pixels');
2121 const backgroundPattern = await Image . renderSVG ( backgroundSVG ) ;
2222 for ( let xOffset = 0 ; xOffset < image . width ; xOffset += backgroundPattern . width ) {
2323 for ( let yOffset = 0 ; yOffset < image . height ; yOffset += backgroundPattern . height ) {
24- image . composite ( backgroundPattern , xOffset , yOffset ) ;
24+ image . composite ( backgroundPattern , { x : xOffset , y : yOffset } ) ;
2525 }
2626 }
2727
2828 const avatarBG = new Image ( 200 + 16 , 200 + 16 ) ;
2929 const avatarGradient = Image . gradient ( { 0 : 0x00ffffff , 1 : 0x0080ffff } ) ;
3030 avatarBG . fill ( ( x , y ) => avatarGradient ( ( x + y ) / ( avatarBG . width + avatarBG . height ) ) ) ;
31- image . composite ( avatarBG . cropCircle ( ) , 0.05 * image . width , 0.05 * image . height ) ;
31+ image . composite ( avatarBG . cropCircle ( ) , { x : 0.05 * image . width , y : 0.05 * image . height } ) ;
3232
3333 const avatar = await Image . decode ( avatarBinary ) ;
34- image . composite ( avatar . resize ( 200 , 200 ) . cropCircle ( ) , 0.05 * image . width + 8 , 0.05 * image . height + 8 ) ;
34+ image . composite ( avatar . resize ( 200 , 200 ) . cropCircle ( ) , { x : 0.05 * image . width + 8 , y : 0.05 * image . height + 8 } ) ;
3535
36- const username = await Image . renderText ( font , 64 , 'matmen' , 0xffffffff ) ;
37- image . composite ( username , 0.3 * image . width , 0.05 * image . height ) ;
36+ const username = await Image . renderText ( font , 64 , 'matmen' , { color : 0xffffffff } ) ;
37+ image . composite ( username , { x : 0.3 * image . width , y : 0.05 * image . height } ) ;
3838
3939 image . drawBox ( 0.3 * image . width , 0.05 * image . height + username . height , username . width , 3 , 0x808080ff ) ;
4040
41- const discriminator = await Image . renderText ( font , 48 , '#9984' , 0xd0d0d0ff ) ;
42- image . composite ( discriminator , 0.3 * image . width , 0.05 * image . height + username . height ) ;
41+ const discriminator = await Image . renderText ( font , 48 , '#9984' , { color : 0xd0d0d0ff } ) ;
42+ image . composite ( discriminator , { x : 0.3 * image . width , y : 0.05 * image . height + username . height } ) ;
4343
4444 // Global XP
4545 {
4646 const xpBarBackground = new Image ( 0.9 * image . width , 0.05 * image . height ) ;
4747 xpBarBackground . fill ( 0xa0a0a0ff ) ;
48- image . composite ( xpBarBackground . roundCorners ( 16 ) , 0.05 * image . width , 0.5 * image . height ) ;
48+ image . composite ( xpBarBackground . roundCorners ( 16 ) , { x : 0.05 * image . width , y : 0.5 * image . height } ) ;
4949
5050 const xpBar = new Image ( 69 / 420 * xpBarBackground . width , 0.05 * image . height ) ;
5151 const xpGradient = Image . gradient ( { 0 : 0x0080ffff , .8 : 0x00ffffff , 1 : 0x00ff80ff } ) ;
5252 xpBar . fill ( x => xpGradient ( x / xpBarBackground . width ) ) ;
53- image . composite ( xpBar . roundCorners ( 16 ) , 0.05 * image . width , 0.5 * image . height ) ;
53+ image . composite ( xpBar . roundCorners ( 16 ) , { x : 0.05 * image . width , y : 0.5 * image . height } ) ;
5454
55- const xpText = await Image . renderText ( font , 32 , '69/420' , 0xff ) ;
56- image . composite ( xpText , 0.05 * image . width + xpBarBackground . width / 2 - xpText . width / 2 , 0.5 * image . height + xpBarBackground . height / 2 - xpText . height / 2 ) ;
55+ const xpText = await Image . renderText ( font , 32 , '69/420' , { color : 0xff } ) ;
56+ image . composite ( xpText , { x : 0.05 * image . width + xpBarBackground . width / 2 - xpText . width / 2 , y : 0.5 * image . height + xpBarBackground . height / 2 - xpText . height / 2 } ) ;
5757
58- const levelText = await Image . renderText ( font , 32 , 'Level 3' , 0xffffffff ) ;
59- image . composite ( levelText , 0.05 * image . width + xpBarBackground . width - levelText . width , 0.5 * image . height - levelText . height ) ;
58+ const levelText = await Image . renderText ( font , 32 , 'Level 3' , { color : 0xffffffff } ) ;
59+ image . composite ( levelText , { x : 0.05 * image . width + xpBarBackground . width - levelText . width , y : 0.5 * image . height - levelText . height } ) ;
6060
61- const xpKindText = await Image . renderText ( font , 32 , 'Global XP' , 0xffffffff ) ;
62- image . composite ( xpKindText , 0.05 * image . width , 0.5 * image . height - levelText . height ) ;
61+ const xpKindText = await Image . renderText ( font , 32 , 'Global XP' , { color : 0xffffffff } ) ;
62+ image . composite ( xpKindText , { x : 0.05 * image . width , y : 0.5 * image . height - levelText . height } ) ;
6363 }
6464
6565 // Server XP
6666 {
6767 const xpBarBackground = new Image ( 0.9 * image . width , 0.05 * image . height ) ;
6868 xpBarBackground . fill ( 0xa0a0a0ff ) ;
69- image . composite ( xpBarBackground . roundCorners ( 16 ) , 0.05 * image . width , 0.65 * image . height ) ;
69+ image . composite ( xpBarBackground . roundCorners ( 16 ) , { x : 0.05 * image . width , y : 0.65 * image . height } ) ;
7070
7171 const xpBar = new Image ( 75 / 100 * xpBarBackground . width , 0.05 * image . height ) ;
7272 const xpGradient = Image . gradient ( { 0 : 0x0080ffff , .8 : 0x00ffffff , 1 : 0x00ff80ff } ) ;
7373 xpBar . fill ( x => xpGradient ( x / xpBarBackground . width ) ) ;
74- image . composite ( xpBar . roundCorners ( 16 ) , 0.05 * image . width , 0.65 * image . height ) ;
74+ image . composite ( xpBar . roundCorners ( 16 ) , { x : 0.05 * image . width , y : 0.65 * image . height } ) ;
7575
76- const xpText = await Image . renderText ( font , 32 , '75/100' , 0xff ) ;
77- image . composite ( xpText , 0.05 * image . width + xpBarBackground . width / 2 - xpText . width / 2 , 0.65 * image . height + xpBarBackground . height / 2 - xpText . height / 2 ) ;
76+ const xpText = await Image . renderText ( font , 32 , '75/100' , { color : 0xff } ) ;
77+ image . composite ( xpText , { x : 0.05 * image . width + xpBarBackground . width / 2 - xpText . width / 2 , y : 0.65 * image . height + xpBarBackground . height / 2 - xpText . height / 2 } ) ;
7878
79- const levelText = await Image . renderText ( font , 32 , 'Level 1' , 0xffffffff ) ;
80- image . composite ( levelText , 0.05 * image . width + xpBarBackground . width - levelText . width , 0.65 * image . height - levelText . height ) ;
79+ const levelText = await Image . renderText ( font , 32 , 'Level 1' , { color : 0xffffffff } ) ;
80+ image . composite ( levelText , { x : 0.05 * image . width + xpBarBackground . width - levelText . width , y : 0.65 * image . height - levelText . height } ) ;
8181
82- const xpKindText = await Image . renderText ( font , 32 , 'Server XP' , 0xffffffff ) ;
83- image . composite ( xpKindText , 0.05 * image . width , 0.65 * image . height - levelText . height ) ;
82+ const xpKindText = await Image . renderText ( font , 32 , 'Server XP' , { color : 0xffffffff } ) ;
83+ image . composite ( xpKindText , { x : 0.05 * image . width , y : 0.65 * image . height - levelText . height } ) ;
8484 }
8585
8686 const badgeBackground = new Image ( ...Array ( 2 ) . fill ( Math . sqrt ( 64 ** 2 * 2 ) ) ) ;
8787 badgeBackground . fill ( 0xa0a0a080 ) ;
8888 badgeBackground . cropCircle ( ) ;
8989 for ( let i = 0 ; i < badges . length ; i ++ ) {
90- image . composite ( badgeBackground , 0.05 * image . width + 0.9 * image . width / badges . length * i , 0.8 * image . height ) ;
90+ image . composite ( badgeBackground , { x : 0.05 * image . width + 0.9 * image . width / badges . length * i , y : 0.8 * image . height } ) ;
9191
92- const badge = await Image . renderSVG ( badges [ i ] , 64 , Image . SVG_MODE_WIDTH ) ;
92+ const badge = await Image . renderSVG ( badges [ i ] , { size : 64 , mode : Image . SVG_MODE_WIDTH } ) ;
9393 if ( i >= 3 )
9494 badge . saturation ( 0 ) ;
9595
96- image . composite (
97- badge ,
98- 0.05 * image . width + 0.9 * image . width / badges . length * i + ( badgeBackground . width - badge . width ) / 2 ,
99- 0.8 * image . height + ( badgeBackground . height - badge . height ) / 2
100- ) ;
96+ image . composite ( badge , {
97+ x : 0.05 * image . width + 0.9 * image . width / badges . length * i + ( badgeBackground . width - badge . width ) / 2 ,
98+ y : 0.8 * image . height + ( badgeBackground . height - badge . height ) / 2
99+ } ) ;
101100 }
102101
103102 image . roundCorners ( 32 ) ;
104103
105- const encoded = await image . encode ( 1 , { creationTime : 0 , software : '' } ) ;
104+ const encoded = await image . encode ( { metadata : { creationTime : 0 , software : '' } } ) ;
106105
107106 if ( process . env . OVERWRITE_TEST )
108107 await fs . writeFile ( './tests/targets/readme.png' , encoded ) ;
0 commit comments