Skip to content

Commit 53b31e9

Browse files
committed
VideoExport examples
1 parent 8577db7 commit 53b31e9

File tree

2 files changed

+67
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)