Help us understand the problem. What is going on with this article?

ProcessingをIntelliJ IDEA+Kotlinで書く

More than 3 years have passed since last update.

Processingでぬるぽに腹がたったのがきっかけで、JavaじゃなくてKotlinで書きたくなったので、IntelliJ IDEAとKotlinでProcessing書きます。
参考記事: Processing 3 を Eclipse で使う方法

IntelliJ IDEAでプロジェクトを作る

  1. まずは普通にKotlin(JVM)のプロジェクトを作ります。
  2. Processingの"core/library/core.jar"をGlobal Libraryとして追加します(ここはJavaでも同じです)。
    1. メニューバーのFile->Project Structure...を選択。
    2. "Project Structure"ウィンドウの左の"Global Libraries"を選択。
    3. 上の"+"を押し、"New Global Library"の直後の"Java"をクリック。
    4. "core/library/core.jar"を選ぶ。

"core/library/core.jar"の場所は上述記事を参考にしてください。

書く

srcの中に適当にprocessing.core.PAppletを継承したKotlinのクラスファイルを作って下さい。そのクラスの継承元のmain関数を呼び出すことで、アプリケーションとして起動します。

ProcessingKt.kt
import processing.core.*

class ProcessingKt : PApplet () {
    override fun settings() : Unit {
        size(400, 300)
    }
    override fun setup() : Unit {
        background(0.0f)
    }

    override fun draw() : Unit {
        fill(255)
        noStroke()
        ellipse(mouseX.toFloat(), mouseY.toFloat(), 10.0f, 10.0f)
    }

    fun run(args: Array<String>) : Unit
            = PApplet.main("ProcessingKt")
}

fun main(args : Array<String>) : Unit = ProcessingKt().run(args)

Kotlinかわいい。超かわいい。

追記 (16/08/28)

MavenやGradleを使うと言う方法もあるっぽいです。
MavenやGradleでProcessingを依存関係に追加する

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした