Drkcore

12 01 2010 Python jython processing Tweet

jythonでprocessing

Built with Processing [改訂版]が到着したので、これを手本にjythonで書いていく。

ProductName Built with Processing [改訂版]
前川 峻志,田中 孝太郎
ビー・エヌ・エヌ新社 / ¥ 3,570 ()


  • jython + p5#2
  • Processing: .. with Jython

を参考にして、step 04-aを。

step 04-a

ソース。jythonだとswing呼んだりしないといけない。

from javax.swing import JFrame
from processing.core import PApplet

class Sketch(PApplet):
    def __init__(self):
        pass

    def setup(self):
        self.size(200, 200)

    def getField(self, name):
        return self.class.superclass.getDeclaredField(name).get(self)

    def draw(self):
        self.rectMode(PApplet.CENTER)
        self.colorMode(PApplet.HSB, 100)
        self.background(99)
        self.noStroke()
        self.smooth()

        self.fill(45, 60, 99)
        self.rect(100, 100, 100, 100)

        self.fill(45, 40, 99)
        self.rect(100, 100, 60, 60)

        self.fill(45, 20, 99)
        self.rect(100, 100, 20, 20)

        self.noFill()
        self.strokeWeight(60)

        self.stroke(80, 99, 99, 30)
        self.ellipse(50, 50, 200, 200)
        self.ellipse(150, 50, 200, 200)
        self.ellipse(50, 150, 200, 200)
        self.ellipse(150, 150, 200, 200)

def run(applet):
    frame = JFrame(title="Processing",
                   resizable = 0,
                   defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
    frame.contentPane.add(applet)
    applet.init()
    frame.pack()
    frame.visible = 1

if __name__ == '__main__':
    run(Sketch())

video入力いじりたいからUSBカメラ買わなきゃ。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021