Flashing short duration images in a window
I want to write code to flash a color image of a person in a window for a short period of time. The duration of the flash is important, not the frequency of the flashes, which will be low and probably controlled by pressing a key. Ideally, the duration should be an integral number of frames, starting from 1 and increasing to a much larger number. With a 60 Hz monitor, one frame would be 0.0167 seconds. The images would be low to moderate resolution, e.g. 70K to 1 Mb Can this be done entirely in Pharo or would it be necessary to use the Unified FFI with operating system commands? If it can be done in Pharo, what are the classes needed to display an image filed in from the hard drive? I am using a 27 inch iMAC (10.11.6) with 4GHz, 8 GB ram, and AMD Radeon R9 M395X 4096 MB video card. Pharos is new to me but I wrote Smalltalk code with VisualWorks a few years back. Thanks very much. Lou Cleveland
| image morph | image := Form fromFileNamed: 'path/(.jpg|.png)'. morph := image asMorph. morph openCenteredInWorld. morph addAlarm: #delete after: 2000 "ms". ---------------------------- Ps. Pharo UI runs at 50Hz Best regards, Henrik From: Pharo-users [mailto:pharo-users-bounces@lists.pharo.org] On Behalf Of William L. Cleveland Sent: Monday, November 28, 2016 9:43 PM To: pharo-users@lists.pharo.org Subject: [Pharo-users] Flashing short duration images in a window I want to write code to flash a color image of a person in a window for a short period of time. The duration of the flash is important, not the frequency of the flashes, which will be low and probably controlled by pressing a key. Ideally, the duration should be an integral number of frames, starting from 1 and increasing to a much larger number. With a 60 Hz monitor, one frame would be 0.0167 seconds. The images would be low to moderate resolution, e.g. 70K to 1 Mb Can this be done entirely in Pharo or would it be necessary to use the Unified FFI with operating system commands? If it can be done in Pharo, what are the classes needed to display an image filed in from the hard drive? I am using a 27 inch iMAC (10.11.6) with 4GHz, 8 GB ram, and AMD Radeon R9 M395X 4096 MB video card. Pharos is new to me but I wrote Smalltalk code with VisualWorks a few years back. Thanks very much. Lou Cleveland
WorldState MinCycleLapse: 16 will make it 60 FPS. Much smoother on Windows. Ok, some CPU is used. Phil On Mon, Nov 28, 2016 at 9:53 PM, Henrik Nergaard <henrik.nergaard@uia.no> wrote:
| image morph |
image := Form fromFileNamed: 'path/(.jpg|.png)'.
morph := image asMorph.
morph openCenteredInWorld.
morph addAlarm: #delete after: 2000 "ms".
----------------------------
Ps. Pharo UI runs at 50Hz
Best regards,
Henrik
*From:* Pharo-users [mailto:pharo-users-bounces@lists.pharo.org] *On Behalf Of *William L. Cleveland *Sent:* Monday, November 28, 2016 9:43 PM *To:* pharo-users@lists.pharo.org *Subject:* [Pharo-users] Flashing short duration images in a window
I want to write code to flash a color image of a person in a window for a short period of time. The duration of the flash is important, not the frequency of the flashes, which will be low and probably controlled by pressing a key.
Ideally, the duration should be an integral number of frames, starting from 1 and increasing to a much larger number. With a 60 Hz monitor, one frame would be 0.0167 seconds. The images would be low to moderate resolution, e.g. 70K to 1 Mb
Can this be done entirely in Pharo or would it be necessary to use the Unified FFI with operating system commands? If it can be done in Pharo, what are the classes needed to display an image filed in from the hard drive?
I am using a 27 inch iMAC (10.11.6) with 4GHz, 8 GB ram, and AMD Radeon R9 M395X 4096 MB video card. Pharos is new to me but I wrote Smalltalk code with VisualWorks a few years back.
Thanks very much.
Lou Cleveland
If you need fullscreen show: Form setBackgroundFromImageFileNamed:'path/(.jpg|.png)'.
Flashing is basically animation. All you need is an ImageMorph and to add stepping using the step method. step is the method that does the animation loop (step = frame) stepTime you return how much time will be spend be spend per step this is my step method from my project ChronosManager which basically does the seconds indicator animation, each second basically display a different image that is appropriate for that second. step "super step." self managerModel mode = 'clock' ifTrue: [ time := DateAndTime current. timeStr color: Color white ]. self managerModel mode = 'timer' | (self managerModel mode = 'stopwatch') ifTrue: [ time := ('0:' , self managerModel timeDisplay) asDuration minutes asDuration. self managerModel phase = 'work' ifTrue: [ timeStr color: Color green ]. self managerModel phase = 'break' ifTrue: [ timeStr color: Color red ] ]. secondsTimer form: (self secondsTimerForm at: time seconds + 1). self setTimeLabel. World submorphs do: [ :each| (each isKindOf: TaskbarMorph) ifTrue: [each updateTaskButtons]] stepTime ^ 1000 you use the form: message to change the image of the morph form is create like this Form fromFileNamed: wp / ('images/panels/mainPanel/secondsTimer/secondsTimer0001.png') wd here references the pharo directory (working directory) which you can assign like this wd := FileSystem disk workingDirectory . On Mon, Nov 28, 2016 at 10:43 PM William L. Cleveland <wlc1@columbia.edu> wrote:
I want to write code to flash a color image of a person in a window for a short period of time. The duration of the flash is important, not the frequency of the flashes, which will be low and probably controlled by pressing a key.
Ideally, the duration should be an integral number of frames, starting from 1 and increasing to a much larger number. With a 60 Hz monitor, one frame would be 0.0167 seconds. The images would be low to moderate resolution, e.g. 70K to 1 Mb
Can this be done entirely in Pharo or would it be necessary to use the Unified FFI with operating system commands? If it can be done in Pharo, what are the classes needed to display an image filed in from the hard drive?
I am using a 27 inch iMAC (10.11.6) with 4GHz, 8 GB ram, and AMD Radeon R9 M395X 4096 MB video card. Pharos is new to me but I wrote Smalltalk code with VisualWorks a few years back.
Thanks very much.
Lou Cleveland
participants (5)
-
Denis Kudriashov -
Dimitris Chloupis -
Henrik Nergaard -
phil@highoctane.be -
William L. Cleveland