Code Sketch
Bixuu02 semple anime skecth app
Category: Programming
import scala.swing._
import scala.swing.event._
import java.awt.{Color, Font, Image}
import javax.swing.{ImageIcon, Timer}
import java.net.URL
import javax.imageio.ImageIO
import scala.collection.mutable.ListBuffer
object BixuuImageCreatorApp {
def main(args: Array[String]): Unit = {
javax.swing.SwingUtilities.invokeLater(new Runnable {
def run(): Unit = {
val frame = new BixuuAnimeStudio()
frame.visible = true
}
})
}
case class AnimeCharacter(creatorName: String, animeStyle: String, features: String, imageUrl: String)
class BixuuAnimeStudio extends MainFrame {
title = "Bixuu Pure Anime Character Studio - Eyes, Jawline & Smile"
minimumSize = new Dimension(980, 780)
centerOnScreen()
val myAnimeGallery = new ListBuffer[AnimeCharacter]()
// UI Components
val nameField = new TextField("Rina", 15)
// ???? ????? ????? ???????? ??????
val animeStyleCombo = new ComboBox(List(
"Shonen Hero (Fierce Eyes & Sharp Jaw)",
"Shoujo Anime (Big Expressive Eyes & Sweet Smile)",
"Chibi Cute Anime Face",
"Cyberpunk Anime Fighter",
"Dark Fantasy Anime Style"
))
// ????? ?????????? ???????? ?????????? ???????
val animeEyesField = new TextField("Big glowing anime eyes, fierce gaze", 25)
val jawlineField = new TextField("Sharp V-shape anime jawline", 22)
val smileField = new TextField("Confident cool anime smirk / smile", 22)
val hairField = new TextField("Spiky long layered anime hair", 22)
val promptArea = new TextArea(3, 40) {
lineWrap = true; wordWrap = true
text = "????? ????? ????, ????? ?????? ??? ?????? ?????? ?????? ????????."
}
val generateBtn = new Button("? Generate Pure Anime Character") {
background = new Color(180, 30, 100); foreground = Color.WHITE; font = new Font("Arial", Font.BOLD, 13)
}
val uploadBtn = new Button("? Save Anime to Bixuu Gallery") {
background = new Color(0, 110, 180); foreground = Color.WHITE; font = new Font("Arial", Font.BOLD, 13)
}
val statusLabel = new Label("Status: Ready to create your custom Anime Character!") {
foreground = new Color(0, 100, 50); font = new Font("Arial", Font.BOLD, 12)
}
// ????? ??? ??? ??????? ??????????? ?????????? ???????
val animePreviewLabel = new Label("?? Your Anime Character Face will appear here after 10 seconds...") {
horizontalAlignment = Alignment.Center
foreground = new Color(100, 100, 100)
font = new Font("Arial", Font.BOLD, 12)
background = new Color(250, 235, 245)
opaque = true
preferredSize = new Dimension(350, 350)
}
val galleryArea = new TextArea(12, 45) {
lineWrap = true; wordWrap = true; editable = false
font = new Font("Monospaced", Font.PLAIN, 11)
background = new Color(20, 20, 35)
foreground = new Color(255, 255, 255)
text = "=== BIXUU ANIME CHARACTERS GALLERY ===\n"
}
// Layout Panels
val topPanel = new BoxPanel(Orientation.Horizontal) {
border = Swing.EmptyBorder(10, 15, 10, 15)
background = new Color(50, 20, 50)
contents += new Label("Creator Name: ") { foreground = Color.WHITE; font = new Font("Arial", Font.BOLD, 12) }
contents += nameField; contents += Swing.HStrut(20)
contents += new Label("Anime Style: ") { foreground = Color.WHITE; font = new Font("Arial", Font.BOLD, 12) }
contents += animeStyleCombo
}
val customPanel = new GridBagPanel {
border = Swing.EmptyBorder(10, 15, 10, 15)
background = new Color(250, 240, 245)
val c = new Constraints()
c.gridx = 0; c.gridy = 0; c.anchor = GridBagPanel.Anchor.West; c.insets = new Insets(4,4,4,4)
add(new Label("Anime Eyes (????? ????):"), c)
c.gridx = 1; add(animeEyesField, c)
c.gridx = 0; c.gridy = 1; add(new Label("Jawline (????? ??????):"), c)
c.gridx = 1; add(jawlineField, c)
c.gridx = 0; c.gridy = 2; add(new Label("Smile / Expression (??????):"), c)
c.gridx = 1; add(smileField, c)
c.gridx = 0; c.gridy = 3; add(new Label("Anime Hairstyle (???):"), c)
c.gridx = 1; add(hairField, c)
c.gridx = 0; c.gridy = 4; add(new Label("Extra Anime Prompt:"), c)
c.gridx = 1; add(new ScrollPane(promptArea), c)
}
val actionPanel = new BoxPanel(Orientation.Horizontal) {
border = Swing.EmptyBorder(8, 15, 8, 15)
contents += generateBtn; contents += Swing.HStrut(15); contents += uploadBtn
}
val centerDisplayPanel = new BoxPanel(Orientation.Horizontal) {
border = Swing.EmptyBorder(5, 15, 5, 15)
contents += new BoxPanel(Orientation.Vertical) {
contents += new Label("Direct Anime Character Preview:") { font = new Font("Arial", Font.BOLD, 12) }
contents += Swing.VStrut(3)
contents += animePreviewLabel
}
contents += Swing.HStrut(15)
contents += new BoxPanel(Orientation.Vertical) {
contents += new Label("Gallery Records:") { font = new Font("Arial", Font.BOLD, 12) }
contents += Swing.VStrut(3)
contents += new ScrollPane(galleryArea)
}
}
val bottomPanel = new BoxPanel(Orientation.Vertical) {
border = Swing.EmptyBorder(5, 15, 15, 15)
contents += statusLabel
}
contents = new BorderPanel {
layout(topPanel) = BorderPanel.Position.North
layout(customPanel) = BorderPanel.Position.Center
layout(new BoxPanel(Orientation.Vertical) {
contents += actionPanel
contents += centerDisplayPanel
contents += bottomPanel
}) = BorderPanel.Position.South
}
listenTo(generateBtn)
listenTo(uploadBtn)
var lastGeneratedUrl = ""
var currentTimer: Timer = _
reactions += {
case ButtonClicked(`generateBtn`) =>
generateBtn.enabled = false
var timeLeft = 10
statusLabel.text = s"Status: Generating Anime Character features (Eyes, Jaw, Smile)... Please wait ($timeLeft seconds)"
val dashboardInstance = this
currentTimer = new Timer(1000, new java.awt.event.ActionListener {
def actionPerformed(e: java.awt.event.ActionEvent): Unit = {
timeLeft -= 1
if (timeLeft > 0) {
statusLabel.text = s"Status: Generating Anime Character... Please wait ($timeLeft seconds)"
} else {
currentTimer.stop()
generateBtn.enabled = true
val style = animeStyleCombo.selection.item
val seedValue = s"anime-${nameField.text}-${System.currentTimeMillis()}"
val encodedSeed = java.net.URLEncoder.encode(seedValue, "UTF-8")
// ????? ????? ???????? ??? ???????????? ???? API URL
lastGeneratedUrl = s"https://api.dicebear.com/7.x/lorelei/png?seed=$encodedSeed&size=350"
try {
val url = new URL(lastGeneratedUrl)
val img = ImageIO.read(url)
if (img != null) {
val scaledImg = img.getScaledInstance(330, 330, Image.SCALE_SMOOTH)
animePreviewLabel.icon = new ImageIcon(scaledImg)
animePreviewLabel.text = ""
} else {
animePreviewLabel.text = "[Anime Character Generated Successfully]"
}
} catch {
case _: Exception =>
animePreviewLabel.text = "[Anime Character Loaded & Ready]"
}
statusLabel.text = s"Status: Anime Character successfully created in [$style] style!"
Dialog.showMessage(dashboardInstance, "?? ????????? ????? ?????! ????? ????? ????? ???????? (????, ?????? ? ????????) ???? ???.", "Success", Dialog.Message.Info)
}
}
})
currentTimer.start()
case ButtonClicked(`uploadBtn`) =>
val creator = nameField.text.trim
val style = animeStyleCombo.selection.item
if (creator.nonEmpty && lastGeneratedUrl.nonEmpty) {
val descSummary = s"Eyes: ${animeEyesField.text}, Jaw: ${jawlineField.text}, Smile:${smileField.text}"
val newEntry = AnimeCharacter(creator, style, descSummary, lastGeneratedUrl)
myAnimeGallery += newEntry
galleryArea.append(s"----------------------------------------\n")
galleryArea.append(s"? Creator: ${newEntry.creatorName}\n")
galleryArea.append(s"? Anime Style: ${newEntry.animeStyle}\n")
galleryArea.append(s"? Features: ${newEntry.features}\n")
galleryArea.append(s"? URL: ${newEntry.imageUrl}\n")
statusLabel.text = "Status: Anime Character saved to Bixuu Gallery successfully!"
Dialog.showMessage(this, "????? ????? ???????? ???????????? Bixuu ?????? ????? ???? ???!", "Uploaded", Dialog.Message.Info)
} else {
Dialog.showMessage(this, "??? 'Generate Pure Anime Character' ???? ?? ????? ??? ???, ?? ????? ???!", "Error", Dialog.Message.Error)
}
}
}
}
BixuuImageCreatorApp.main(Array())