Skip to content

Commit 2f63ee8

Browse files
committed
add video export examples
1 parent 3859792 commit 2f63ee8

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env jruby
2+
# frozen_string_literal: true
3+
require 'propane'
4+
5+
class BasicExample < Propane::App
6+
7+
load_library :VideoExport
8+
include_package 'com.hamoid'
9+
10+
# Press 'q' to finish saving the movie and exit.
11+
12+
# In some systems, if you close your sketch by pressing ESC,
13+
# by closing the window, or by pressing STOP, the resulting
14+
# movie might be corrupted. If that happens to you, use
15+
# video_export.end_movie like you see in this example.
16+
17+
# In some systems pressing ESC produces correct movies
18+
# and .end_movie is not necessary.
19+
attr_reader :video_export
20+
21+
def settings
22+
size(600, 600)
23+
end
24+
25+
def setup
26+
sketch_title 'Basic Example'
27+
@video_export = VideoExport.new(self)
28+
video_export.start_movie
29+
end
30+
31+
def draw
32+
background(color('#224488'))
33+
rect(frame_count * frame_count % width, 0, 40, height)
34+
video_export.save_frame
35+
end
36+
37+
def key_pressed
38+
return unless (key == 'q')
39+
video_export.end_movie
40+
exit
41+
end
42+
end
43+
44+
BasicExample.new
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env jruby
2+
# frozen_string_literal: true
3+
require 'propane'
4+
5+
class CreateGraphicsExample < Propane::App
6+
7+
load_library :VideoExport
8+
include_package 'com.hamoid'
9+
10+
VideoExport
11+
attr_reader :pg, :video_export
12+
13+
def settings
14+
size(600, 600)
15+
end
16+
17+
def setup
18+
sketch_title 'Create Graphics'
19+
@pg = createGraphics(640, 480)
20+
@video_export = VideoExport.new(self, data_path('pgraphics.mp4'), pg)
21+
video_export.start_movie
22+
end
23+
24+
def draw
25+
background(0)
26+
text(format('exporting video %d', frame_count), 50, 50)
27+
pg.begin_draw
28+
pg.background(color('#224488'))
29+
pg.rect(pg.width * noise(frame_count * 0.01), 0, 40, pg.height)
30+
pg.end_draw
31+
video_export.save_frame
32+
end
33+
34+
def key_pressed
35+
return unless (key == 'q')
36+
video_export.end_movie
37+
exit
38+
end
39+
end
40+
41+
CreateGraphicsExample.new

0 commit comments

Comments
 (0)