Kotlin

Kotlinコードスクリーンショット生成

Kotlinのスニペットを、Macから離れることなく共有したくなる画像に。

Kotlin は簡潔なので、コードがほとんど文章のように読めます。フィードで見せるにはうってつけです。

Codeshotは貼り付けたコードからKotlinを判別するので、言語の選び間違いは起きません。付属する30種類のうち3つのテーマで同じスニペットを、アプリ自身のスタイルシートで表示しています。

data class Snapshot(
    val code: String,
    val theme: String = "xcode",
    val scale: Int = 2,
)

fun Snapshot.export(path: String): Result<String> = runCatching {
    render(code, theme).save(path, scale)
}
Atom One · ダーク
data class Snapshot(
    val code: String,
    val theme: String = "xcode",
    val scale: Int = 2,
)

fun Snapshot.export(path: String): Result<String> = runCatching {
    render(code, theme).save(path, scale)
}
GitHub · ダーク
data class Snapshot(
    val code: String,
    val theme: String = "xcode",
    val scale: Int = 2,
)

fun Snapshot.export(path: String): Result<String> = runCatching {
    render(code, theme).save(path, scale)
}
Tokyo Night · ダーク

Kotlinに合うテーマ選び

data クラスも拡張関数も正方形の枠にゆったり収まるので、ここでは 1:1 がたいてい正解です。

サイズを正しく決める

画像サイズを内容に合わせるか、比率で固定します(1:1、4:3、3:2、16:9、9:16、2:3、3:4)。そのうえで1×・2×・3×から選んで書き出せば、Retinaディスプレイでも鮮明なままです。Cでクリップボードに直接コピー、またはSで保存できます。

30種類のテーマを見比べるか、全体の流れをご覧ください。

Kotlinと、ほかの59言語のために

すべてMac上で動作します。コードが外に出ることはありません。

macOS版をダウンロード