-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env jruby | ||
# frozen_string_literal: true | ||
require 'propane' | ||
|
||
class BasicExample < Propane::App | ||
|
||
load_library :VideoExport | ||
include_package 'com.hamoid' | ||
|
||
# Press 'q' to finish saving the movie and exit. | ||
|
||
# In some systems, if you close your sketch by pressing ESC, | ||
# by closing the window, or by pressing STOP, the resulting | ||
# movie might be corrupted. If that happens to you, use | ||
# video_export.end_movie like you see in this example. | ||
|
||
# In some systems pressing ESC produces correct movies | ||
# and .end_movie is not necessary. | ||
attr_reader :video_export | ||
|
||
def settings | ||
size(600, 600) | ||
end | ||
|
||
def setup | ||
sketch_title 'Basic Example' | ||
@video_export = VideoExport.new(self) | ||
video_export.start_movie | ||
end | ||
|
||
def draw | ||
background(color('#224488')) | ||
rect(frame_count * frame_count % width, 0, 40, height) | ||
video_export.save_frame | ||
end | ||
|
||
def key_pressed | ||
return unless (key == 'q') | ||
video_export.end_movie | ||
exit | ||
end | ||
end | ||
|
||
BasicExample.new |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env jruby | ||
# frozen_string_literal: true | ||
require 'propane' | ||
|
||
class CreateGraphicsExample < Propane::App | ||
|
||
load_library :VideoExport | ||
include_package 'com.hamoid' | ||
|
||
VideoExport | ||
attr_reader :pg, :video_export | ||
|
||
def settings | ||
size(600, 600) | ||
end | ||
|
||
def setup | ||
sketch_title 'Create Graphics' | ||
@pg = createGraphics(640, 480) | ||
@video_export = VideoExport.new(self, data_path('pgraphics.mp4'), pg) | ||
video_export.start_movie | ||
end | ||
|
||
def draw | ||
background(0) | ||
text(format('exporting video %d', frame_count), 50, 50) | ||
pg.begin_draw | ||
pg.background(color('#224488')) | ||
pg.rect(pg.width * noise(frame_count * 0.01), 0, 40, pg.height) | ||
pg.end_draw | ||
video_export.save_frame | ||
end | ||
|
||
def key_pressed | ||
return unless (key == 'q') | ||
video_export.end_movie | ||
exit | ||
end | ||
end | ||
|
||
CreateGraphicsExample.new |