Skip to content

Commit

Permalink
add video export examples
Browse files Browse the repository at this point in the history
  • Loading branch information
monkstone committed Jan 31, 2017
1 parent 3859792 commit 2f63ee8
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
44 changes: 44 additions & 0 deletions external_library/java/video_export/basic.rb
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
41 changes: 41 additions & 0 deletions external_library/java/video_export/using_pgraphics.rb
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

0 comments on commit 2f63ee8

Please sign in to comment.