embroidery


License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.github.wi101
ArtifactId

ArtifactId

embroidery_2.12
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

embroidery
embroidery
Project URL

Project URL

https://github.com/wi101/embroidery
Project Organization

Project Organization

com.github.wi101
Source Code Management

Source Code Management

https://github.com/wi101/embroidery

Download embroidery_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.wi101/embroidery_2.12/ -->
<dependency>
    <groupId>com.github.wi101</groupId>
    <artifactId>embroidery_2.12</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.wi101/embroidery_2.12/
implementation 'com.github.wi101:embroidery_2.12:0.1.1'
// https://jarcasting.com/artifacts/com.github.wi101/embroidery_2.12/
implementation ("com.github.wi101:embroidery_2.12:0.1.1")
'com.github.wi101:embroidery_2.12:jar:0.1.1'
<dependency org="com.github.wi101" name="embroidery_2.12" rev="0.1.1">
  <artifact name="embroidery_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.wi101', module='embroidery_2.12', version='0.1.1')
)
libraryDependencies += "com.github.wi101" % "embroidery_2.12" % "0.1.1"
[com.github.wi101/embroidery_2.12 "0.1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.10

Project Modules

There are no modules declared in this project.

embroidery

You can add an artistic touch to your console.

To use embroidery, add the following line in your build.sbt file:

libraryDependencies += "com.github.wi101" %% "embroidery" % "0.1.1"

Usage

  1. Convert your text to ASCII Art: title.asciiArt returns a String that you can display or use in your project. Or you can use the syntax title.toAsciiArt.
import embroidery.title

title.asciiArt("Hello world")

Or:

import embroidery._

"Hello".toAsciiArt

Output:

 #     #         #  #           #    #    #            #      #
 #     #         #  #           #   # #   #            #      #
 #     #   ###   #  #   ###     #   # #  #   ###   # # #   ## #
 #     #  #   #  #  #  #   #     #  # #  #  #   #  ##  #  #  ##
 #######  #   #  #  #  #   #     # #   # #  #   #  #   #  #   #
 #     #  #####  #  #  #   #     # #   # #  #   #  #   #  #   #
 #     #  #      #  #  #   #     # #   # #  #   #  #   #  #   #
 #     #  #   #  #  #  #   #      #     #   #   #  #   #  #  ##
 #     #   ###   #  #   ###       #     #    ###   #   #   ## #

You can specify the spaces between the character. For example, if you would like to display S c a l a, you can call:

import embroidery.title

title.asciiArt("Scala", art = 'S', spaces = 1)

Or

import embroidery._

"Scala".toAsciiArt(art = 'S', spaces = 1)

Output:

                                SS                            
                                SS                            
 SSSS      SSSSS     SSSSS      SS     SSSSS                  
SSSSS     SSSSSS     SSSSS      SS     SSSSS                  
 SSS      SSS           SS      SS        SS                  
 SSSS     SSS        SSSSS      SS     SSSSS                  
  SSSS    SSS       SSS SS      SS    SSS SS                  
SS SSS    SSSSSS    SSSSSS      SS    SSSSSS                  
SSSSS      SSSSS    SSSSSSS     SS    SSSSSSS                 
  SS         SS       S  S              S  S                  
                                                    

WARNNG: The title should be short to be able to display it in your screen (maximum 20 characters including spaces).

  1. Convert your LOGO to ASCII Art:

You can get the Ascii Art of your icons using logo.asciiArt method. Or you can use the syntax logoPath.toAsciiArt.

import embroidery.logo

logo.asciiArt("src/test/scala/embroidery/asciiArt/logos/images/pikachu.png")

OR

import embroidery._

ImagePath("src/test/scala/embroidery/asciiArt/logos/images/pikachu.png").toAsciiArt
pikachu.png result with ASCII Art
pikachu pikachu
import embroidery.logo

logo.asciiArt("src/test/scala/embroidery/asciiArt/logos/images/zio.png")

OR

import embroidery._

ImagePath("src/test/scala/embroidery/asciiArt/logos/images/zio.png").toAsciiArt
zio.png result with ASCII Art
zio zio
import embroidery.logo

logo.asciiArt("src/test/scala/embroidery/asciiArt/logos/images/scala.jpg")

OR

import embroidery._

ImagePath("src/test/scala/embroidery/asciiArt/logos/images/scala.jpg").toAsciiArt
scala.jpg result with ASCII Art
scala scala

You can also decide which characters to use on each brightness level:

import embroidery._

 val pixelsWithArt: List[PixelAsciiArt] = List(
    PixelAsciiArt(Pixel(255), Art(' ')),
    PixelAsciiArt(Pixel(0), Art('#'))
  )

  val img: String = ImagePath("src/test/scala/embroidery/asciiArt/images/zio.png").toAsciiArt(pixelsWithArt)
  val s = img.flatMap(
    c =>
      if (c != ' ' && c != '\n')
        Console.RED + c.toString + Console.RESET
      else c.toString
  )
  println(s)

Output:

Screen Shot 2020-07-25 at 3 52 02 PM

You can also control the size of your logo:

import embroidery._

  val pixelsWithArt: List[PixelAsciiArt] = List(
      PixelAsciiArt(Pixel(255), Art(' ')),
      PixelAsciiArt(Pixel(230), Art('.')),
      PixelAsciiArt(Pixel(220), Art(',')),
      PixelAsciiArt(Pixel(210), Art('°')),
      PixelAsciiArt(Pixel(200), Art('²')),
      PixelAsciiArt(Pixel(190), Art('*')),
      PixelAsciiArt(Pixel(180), Art('^')),
      PixelAsciiArt(Pixel(170), Art('~')),
      PixelAsciiArt(Pixel(150), Art('/')),
      PixelAsciiArt(Pixel(140), Art('|')),
      PixelAsciiArt(Pixel(130), Art('s')),
      PixelAsciiArt(Pixel(120), Art('q')),
      PixelAsciiArt(Pixel(90), Art('µ')),
      PixelAsciiArt(Pixel(70), Art('@')),
      PixelAsciiArt(Pixel(0), Art('#'))
    )

  val img = logo.asciiArt(
    "src/test/scala/embroidery/asciiArt/images/scala.jpg",
    pixelsWithArt,
    100,
    50
  )
// The same as: ImagePath("...").toAsciiArt(pixelsWithArt, 100, 50)
  val scala = img.flatMap(
    c =>
      if (c != ' ' && c != '\n')
        Console.RED + c.toString + Console.RESET
      else c.toString
  )
  println(scala)

Output:

Screen Shot 2020-07-25 at 4 29 18 PM

Note: The valid format of the pictures are: jpg, jpeg, png, bmp

Versions

Version
0.1.1