Created
June 18, 2016 11:08
-
-
Save pedrozath/b08c1cf4d1d49c637d33ec4c5fcfcb66 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $LOAD_PATH.unshift(File.dirname(__FILE__)) | |
| require "java" | |
| require "jrubyfx" | |
| require "forest_generator" | |
| fxml_root File.dirname(__FILE__) | |
| class Main < JRubyFX::Application | |
| def start(stage) | |
| $stage = stage | |
| ForestGenerator.new x: 0, y:0 | |
| with(stage, title:"Entrama Árvores", width: 800, height: 600) do | |
| @root = fxml PanelController | |
| show | |
| end | |
| end | |
| def open_export_dialog | |
| stage.set_scene | |
| end | |
| end | |
| class PanelController | |
| include JRubyFX::Controller | |
| fxml "panel.fxml" | |
| def initialize | |
| @foreground_color.set_value(Color.web "000") | |
| change_settings | |
| end | |
| def change_settings | |
| $app.settings = { | |
| iterations: @iterations.get_value.round, | |
| number_of_trees: @number_of_trees.get_value.round, | |
| size: @size.get_value, | |
| girth: @girth.get_value, | |
| ramifications: @ramifications.get_value, | |
| spreadness: @spreadness.get_value, | |
| size_variation: @size_variation.get_value, | |
| hue_start: @foreground_color.get_value.get_hue, | |
| sat_start: @foreground_color.get_value.get_saturation * 100, | |
| val_start: @foreground_color.get_value.get_brightness * 100, | |
| hue_evolution: @hue_evolution.get_value, | |
| sat_evolution: @sat_evolution.get_value, | |
| val_evolution: @val_evolution.get_value, | |
| background_hue: @background_color.get_value.hue, | |
| background_sat: @background_color.get_value.saturation * 100, | |
| background_bri: @background_color.get_value.brightness * 100 | |
| } | |
| if @automatic_mode.is_selected | |
| render | |
| end | |
| new_tree | |
| end | |
| def set_path | |
| file_chooser = FileChooser.new | |
| file_chooser.setTitle("Onde você quer que os arquivos sejam salvos"); | |
| file_chooser.showSaveDialog($stage); | |
| end | |
| def export_gif | |
| # $app.export "gif" | |
| end | |
| def export_jpeg | |
| # $app.export "jpeg" | |
| end | |
| def export_png | |
| # $app.export "png" | |
| end | |
| def export_mp4 | |
| # $app.export "mp4" | |
| end | |
| def new_tree | |
| $app.new_tree | |
| end | |
| def render | |
| $app.render | |
| end | |
| end | |
| Main.launch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment