Skip to content

Commit

Permalink
Example + Fixed Characters
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoneDroid committed Feb 26, 2024
1 parent fd2f956 commit 644cc53
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Example/App.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import { pixelify } from '../Source/mod.ts'


const text = `Use the search parameter 'Text' to change this text.`

const ascii = pixelify(text)

console.debug(ascii)
6 changes: 3 additions & 3 deletions Source/Characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ const Characters = {
[ 1,0,0,0,0,1 ] ,
[ 1,0,0,0,0,1 ] ,
[ 0,1,1,1,1,0 ] ,
[ 0,0,0,0,0,1 ] ,
[ 0,0,0,0,0,0 ] ,
[ 0,0,0,0,0,0 ]
],

Expand Down Expand Up @@ -1073,12 +1073,12 @@ const Characters = {
[ 0,0,0,0,0,0,0 ] ,
[ 0,0,0,0,0,0,0 ] ,
[ 0,0,0,0,0,0,0 ] ,
[ 0,0,0,0,0,0,0 ] ,
[ 1,1,1,0,1,1,0 ] ,
[ 1,0,0,1,0,0,1 ] ,
[ 1,0,0,1,0,0,1 ] ,
[ 1,0,0,1,0,0,1 ] ,
[ 1,0,0,1,0,0,1 ] ,
[ 1,0,0,1,0,0,1 ] ,
[ 0,0,0,0,0,0,0 ] ,
[ 0,0,0,0,0,0,0 ]
],
Expand All @@ -1087,12 +1087,12 @@ const Characters = {
[ 0,0,0,0,0 ] ,
[ 0,0,0,0,0 ] ,
[ 0,0,0,0,0 ] ,
[ 0,0,0,0,0 ] ,
[ 1,0,1,1,0 ] ,
[ 1,1,0,0,1 ] ,
[ 1,0,0,0,1 ] ,
[ 1,0,0,0,1 ] ,
[ 1,0,0,0,1 ] ,
[ 1,0,0,0,1 ] ,
[ 0,0,0,0,0 ] ,
[ 0,0,0,0,0 ]
],
Expand Down
13 changes: 7 additions & 6 deletions Source/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Blocks = [
'▌' ,
'▙' ,
'▀' ,
'▜' ,
'▛' ,
'█'
]
Expand All @@ -30,7 +31,7 @@ function pixelify ( text : string ){
const characters = text
.split('')
.map(( character ) => Characters[ character ] ?? Default )

const lines = Array(11)
.fill(null)
.map(() => [] as Array<number> )
Expand All @@ -42,7 +43,7 @@ function pixelify ( text : string ){

const chunks = lines
.map(( line ) => chunk(line,2) )



const rows = chunk(chunks,2)
Expand All @@ -52,15 +53,15 @@ function pixelify ( text : string ){

let [ upper , lower = [] ] = row

upper = upper.map(([ first , second = 0 ]) => [ first , second ] )
lower = lower.map(([ first , second = 0 ]) => [ first , second ] )
upper = upper.map(([ first , second ]) => [ first , second ?? 0 ] )
lower = lower.map(([ first , second ]) => [ first , second ?? 0 ] )

return upper
.map(([ first , second = 0 ]) => [ first , second ] )
.map(( pair , index ) => [ pair , lower[ index ] ?? [ 0 , 0 ] ])
.map(( block ) => (console.log(block,block[0][0] * 8 + block[0][1] * 4 + block[1][0] * 2 + block[1][1],Blocks[block[0][0] * 8 + block[0][1] * 4 + block[1][0] * 2 + block[1][1]]),block))
.map(( block ) => block[0][0] * 8 + block[0][1] * 4 + block[1][0] * 2 + block[1][1] )
.map(( index ) => Blocks[ index ] )
.join('')
.join('')
})
.join('\n')
}
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

"tasks" : {
"npm:publish" : "deno run -A .config/Tasks/NPM.ts $1 && cd npm && npm publish" ,
"dev" : "deno run Source/App.ts"
"example" : "deno run Example/App.ts"
}
}
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 644cc53

Please sign in to comment.