Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,62 @@
|
|||
def ASCII3D = {
|
||||
|
||||
val name = """
|
||||
*
|
||||
** ** * * *
|
||||
* * * * * * *
|
||||
* * * * * * *
|
||||
* * *** * ***
|
||||
* * * * * * *
|
||||
* * * * * * *
|
||||
** ** * * *** * *
|
||||
*
|
||||
*
|
||||
"""
|
||||
|
||||
// Create Array
|
||||
|
||||
def getMaxSize(s: String): (Int, Int) = {
|
||||
var width = 0
|
||||
var height = 0
|
||||
|
||||
val nameArray = s.split("\n")
|
||||
height = nameArray.size
|
||||
nameArray foreach { i => width = (i.size max width) }
|
||||
|
||||
(width, height)
|
||||
}
|
||||
|
||||
val size = getMaxSize(name)
|
||||
var arr = Array.fill(size._2 + 1, (size._1 * 3) + (size._2 + 1))(' ')
|
||||
|
||||
//
|
||||
// Map astrisk to 3D cube
|
||||
//
|
||||
val cubeTop = """///\""" //"
|
||||
val cubeBottom = """\\\/""" //"
|
||||
|
||||
val nameArray = name.split("\n")
|
||||
|
||||
for (j <- (0 until nameArray.size)) {
|
||||
for (i <- (0 until nameArray(j).size)) {
|
||||
if (nameArray(j)(i) == '*') {
|
||||
val indent = nameArray.size - j
|
||||
arr(j) = arr(j) patch ((i * 3 + indent), cubeTop, cubeTop.size)
|
||||
arr(j + 1) = arr(j + 1) patch ((i * 3 + indent), cubeBottom, cubeBottom.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Map Array to String
|
||||
//
|
||||
var name3D = ""
|
||||
|
||||
for (j <- (0 until arr.size)) {
|
||||
for (i <- (0 until arr(j).size)) { name3D += arr(j)(i) }
|
||||
name3D += "\n"
|
||||
}
|
||||
name3D
|
||||
}
|
||||
|
||||
println(ASCII3D)
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import scala.collection.mutable.ArraySeq
|
||||
|
||||
object Ascii3D extends App {
|
||||
def ASCII3D = {
|
||||
val picture = """ *
|
||||
** ** * * *
|
||||
* * * * * * *
|
||||
* * * * * * *
|
||||
* * *** * ***
|
||||
* * * * * * *
|
||||
* * * * * * *
|
||||
** ** * * *** * *
|
||||
*
|
||||
*""".split("\n")
|
||||
|
||||
var arr = {
|
||||
val (x, y) = // Get maximal format and create a 2-D array with it.
|
||||
(picture.foldLeft(0)((i, s) => i max s.length), picture.size)
|
||||
ArraySeq.fill(y + 1, (x * 3) + (y + 1))(' ')
|
||||
}
|
||||
|
||||
//
|
||||
// Map asterisks to 3D cube
|
||||
//
|
||||
val (cubeTop, cubeBottom) = ("""///\""", """\\\/""") // "
|
||||
|
||||
for {
|
||||
y <- 0 until picture.size
|
||||
x <- 0 until picture(y).size
|
||||
if picture(y)(x) == '*'
|
||||
indent = picture.size - y
|
||||
} {
|
||||
arr(y) = arr(y) patch ((x * 3 + indent), cubeTop, cubeTop.size)
|
||||
arr(y + 1) = arr(y + 1) patch ((x * 3 + indent), cubeBottom, cubeBottom.size)
|
||||
}
|
||||
// Transform array to String
|
||||
arr.map(_.mkString).mkString("\n")
|
||||
}
|
||||
|
||||
println(ASCII3D)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue