diff --git a/.scalafmt.conf b/.scalafmt.conf index f77a401..bf2c140 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,3 +1,3 @@ -version="3.5.0" +version="3.5.1" maxColumn = 120 runner.dialect = scala3 diff --git a/src/main/scala/lc/background/taskThread.scala b/src/main/scala/lc/background/taskThread.scala index 6477207..3a0f114 100644 --- a/src/main/scala/lc/background/taskThread.scala +++ b/src/main/scala/lc/background/taskThread.scala @@ -46,7 +46,7 @@ class BackgroundTask(config: Config, captchaManager: CaptchaManager) { (captcha.allowedLevels).flatMap { level => (captcha.allowedMedia).flatMap { media => (captcha.allowedInputType).flatMap { inputType => - (captcha.allowedSizes).map {size => + (captcha.allowedSizes).map { size => Parameters(level, media, inputType, size) } } diff --git a/src/main/scala/lc/captchas/FilterChallenge.scala b/src/main/scala/lc/captchas/FilterChallenge.scala index 2944cb1..e657c1b 100644 --- a/src/main/scala/lc/captchas/FilterChallenge.scala +++ b/src/main/scala/lc/captchas/FilterChallenge.scala @@ -43,16 +43,16 @@ class FilterChallenge extends ChallengeProvider { val height = size2D(1) val canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB) val g = canvas.createGraphics() - val fontHeight = (height*0.6).toInt + val fontHeight = (height * 0.6).toInt g.setColor(Color.WHITE) g.fillRect(0, 0, canvas.getWidth, canvas.getHeight) g.setColor(Color.BLACK) val font = new Font("Serif", Font.BOLD, fontHeight) g.setFont(font) val stringWidth = g.getFontMetrics().stringWidth(secret) - val scaleX = if (stringWidth > width) width/(stringWidth.toDouble) else 1d + val scaleX = if (stringWidth > width) width / (stringWidth.toDouble) else 1d val margin = if (stringWidth > width) 0 else (width - stringWidth) - val xOffset = (margin*r.nextDouble).toInt + val xOffset = (margin * r.nextDouble).toInt g.scale(scaleX, 1d) g.drawString(secret, xOffset, fontHeight) g.dispose() diff --git a/src/main/scala/lc/captchas/RainDropsCaptcha.scala b/src/main/scala/lc/captchas/RainDropsCaptcha.scala index 40cd217..8611004 100644 --- a/src/main/scala/lc/captchas/RainDropsCaptcha.scala +++ b/src/main/scala/lc/captchas/RainDropsCaptcha.scala @@ -128,13 +128,13 @@ class RainDropsCP extends ChallengeProvider { val textX = if (textWidth > width) 0 else ((width - textWidth) / 2) // this will be overlapped by the following text to show the top outline because of the offset - val yOffset = (fontHeight*0.01).ceil.toInt + val yOffset = (fontHeight * 0.01).ceil.toInt g.setColor(textHighlightColor) - g.drawString(secret, textX, (fontHeight*1.1).toInt - yOffset) + g.drawString(secret, textX, (fontHeight * 1.1).toInt - yOffset) // paint the text g.setColor(textColor) - g.drawString(secret, textX, (fontHeight*1.1).toInt) + g.drawString(secret, textX, (fontHeight * 1.1).toInt) g.dispose() writer.writeToSequence(canvas)