-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from xiao-zheng233/master
添加Osu图标生成
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.laolittle.plugin.draw.meme | ||
|
||
import org.jetbrains.skia.* | ||
import org.laolittle.plugin.Fonts | ||
import org.laolittle.plugin.draw.makeFromResource | ||
import org.laolittle.plugin.usedBy | ||
|
||
private val paintText = Paint().apply { | ||
color = Color.WHITE | ||
} | ||
|
||
private val osuImage = Image.makeFromResource("/Osu/logo.png") | ||
|
||
private val font = Fonts["Aller-Bold", 112.5F] usedBy "OSU图标生成" | ||
|
||
fun osu(text: String = "osu!"): Image { | ||
val osuText: TextLine | ||
val yPos: Float | ||
val textWidth = font.measureTextWidth(text, paintText) | ||
if (textWidth <= 250) { | ||
osuText = TextLine.make(text, font) | ||
yPos = 137.5F + osuText.height / 2 | ||
}else { | ||
yPos = 210 - (textWidth - 255) / 20 | ||
osuText = TextLine.make(text, font.makeWithSize(250F / textWidth * 112.5F)) | ||
} | ||
|
||
return Surface.makeRasterN32Premul(350, 350).apply { | ||
canvas.apply { | ||
drawImage(osuImage, 0F, 0F) | ||
drawTextLine(osuText, 175F - osuText.width / 2, yPos, paintText) | ||
} | ||
}.makeImageSnapshot() | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.