@@ -11,7 +11,6 @@ const { createCanvas, loadImage } = require(path.join(
1111) ) ;
1212const buildDir = path . join ( basePath , "/build" ) ;
1313const layersDir = path . join ( basePath , "/layers" ) ;
14- console . log ( path . join ( basePath , "/src/config.js" ) ) ;
1514const {
1615 format,
1716 baseUri,
@@ -23,6 +22,7 @@ const {
2322 shuffleLayerConfigurations,
2423 debugLogs,
2524 extraMetadata,
25+ text,
2626} = require ( path . join ( basePath , "/src/config.js" ) ) ;
2727const canvas = createCanvas ( format . width , format . height ) ;
2828const ctx = canvas . getContext ( "2d" ) ;
@@ -111,7 +111,7 @@ const genColor = () => {
111111} ;
112112
113113const drawBackground = ( ) => {
114- ctx . fillStyle = genColor ( ) ;
114+ ctx . fillStyle = background . static ? background . default : genColor ( ) ;
115115 ctx . fillRect ( 0 , 0 , format . width , format . height ) ;
116116} ;
117117
@@ -147,10 +147,32 @@ const loadLayerImg = async (_layer) => {
147147 } ) ;
148148} ;
149149
150- const drawElement = ( _renderObject ) => {
150+ const addText = ( _sig , x , y , size ) => {
151+ ctx . fillStyle = text . color ;
152+ ctx . font = `${ text . weight } ${ size } pt ${ text . family } ` ;
153+ ctx . textBaseline = text . baseline ;
154+ ctx . textAlign = text . align ;
155+ ctx . fillText ( _sig , x , y ) ;
156+ } ;
157+
158+ const drawElement = ( _renderObject , _index , _layersLen ) => {
151159 ctx . globalAlpha = _renderObject . layer . opacity ;
152160 ctx . globalCompositeOperation = _renderObject . layer . blend ;
153- ctx . drawImage ( _renderObject . loadedImage , 0 , 0 , format . width , format . height ) ;
161+ text . only
162+ ? addText (
163+ `${ _renderObject . layer . name } ${ text . spacer } ${ _renderObject . layer . selectedElement . name } ` ,
164+ text . xGap ,
165+ text . yGap * ( _index + 1 ) ,
166+ text . size
167+ )
168+ : ctx . drawImage (
169+ _renderObject . loadedImage ,
170+ 0 ,
171+ 0 ,
172+ format . width ,
173+ format . height
174+ ) ;
175+
154176 addAttributes ( _renderObject ) ;
155177} ;
156178
@@ -266,8 +288,12 @@ const startCreating = async () => {
266288 if ( background . generate ) {
267289 drawBackground ( ) ;
268290 }
269- renderObjectArray . forEach ( ( renderObject ) => {
270- drawElement ( renderObject ) ;
291+ renderObjectArray . forEach ( ( renderObject , index ) => {
292+ drawElement (
293+ renderObject ,
294+ index ,
295+ layerConfigurations [ layerConfigIndex ] . layersOrder . length
296+ ) ;
271297 } ) ;
272298 debugLogs
273299 ? console . log ( "Editions left to create: " , abstractedIndexes )
0 commit comments