Sunday, January 22, 2017

Jython 5. Circle

This Example, Circle, will produce the same output as Java Example 5.


# ex05.py
# Circle

from javafx.application import Application
from javafx.scene import Scene
from javafx.scene import Group
from javafx.scene.paint import Color
from javafx.scene.shape import Circle

class Pos:
    pass

pos = Pos()
pos.cen = [200,200] # center x,y
pos.rad = [100] # radius
pos.fill = [Color.RED] # fill
pos.val = pos.cen + pos.rad + pos.fill

class Ex05(Application):
    def start(self, stage):
        stage.setTitle("Example 5. Circle")
        root = Group()
        circ = Circle(*pos.val)
        root.getChildren().add(circ)
        scene = Scene(root, 400, 400, Color.AQUA)
        stage.setScene(scene)
        stage.show()

if __name__ == '__main__':
    Application.launch(Ex05().class, [])

An empty class is created. We create an instance pos and then set its values.


No comments:

Post a Comment