CacaANSICam: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Astro (Diskussion | Beiträge) (Die Seite wurde neu angelegt: <source lang="ruby">#!/usr/bin/env ruby require 'cucul' require 'V4l' require 'socket' SHRINK_X = 5 SHRINK_Y = 10 Thread::abort_on_exception = true current = '' curren...) |
Astro (Diskussion | Beiträge) (This page must use the Rübÿ Spëëd Mëtäl Cödïng template!!!111) |
||
Zeile 6: | Zeile 6: | ||
SHRINK_Y = 10 | SHRINK_Y = 10 | ||
Thread::abort_on_exception = true | Thread::abort_on_exception = true | ||
current = '' | current = '' | ||
current_lock = Mutex.new | current_lock = Mutex.new | ||
Zeile 17: | Zeile 16: | ||
d.brightness = 0.5 | d.brightness = 0.5 | ||
d.gamma = 1.2 | d.gamma = 1.2 | ||
loop do | loop do | ||
f = vid.get_frame | f = vid.get_frame | ||
Zeile 26: | Zeile 24: | ||
end | end | ||
} | } | ||
s = TCPServer.new(2323) | s = TCPServer.new(2323) | ||
while (c = s.accept) | while (c = s.accept) | ||
Zeile 45: | Zeile 42: | ||
end | end | ||
</source> | </source> | ||
[[Category:Ruby]] | |||
{{Rübÿ Spëëd Mëtäl Cödïng}} |
Version vom 28. Juni 2008, 15:03 Uhr
#!/usr/bin/env ruby
require 'cucul'
require 'V4l'
require 'socket'
SHRINK_X = 5
SHRINK_Y = 10
Thread::abort_on_exception = true
current = ''
current_lock = Mutex.new
Thread.new {
vid = V4l.new('/dev/video')
cucul = Cucul::Canvas.new(vid.width / SHRINK_X, vid.height / SHRINK_Y)
d = Cucul::Dither::new(24, vid.width, vid.height, 3 * vid.width, 0xff, 0xff00, 0xff0000, 0)
d.antialias = 'prefilter'
d.algorithm = 'fstein'
d.brightness = 0.5
d.gamma = 1.2
loop do
f = vid.get_frame
cucul.dither_bitmap(0, 0, vid.width / SHRINK_X, vid.height / SHRINK_Y, d, f)
current_lock.synchronize {
current = cucul.export_memory('ansi')
}
end
}
s = TCPServer.new(2323)
while (c = s.accept)
puts "accepted #{c.peeraddr.inspect}"
Thread.new {
begin
loop do
current_lock.synchronize {
c.puts "\e[2J#{current}"
c.flush
sleep 0.5
}
end
rescue Errno::EPIPE
rescue Errno::ECONNRESET
end
}
end
Rübÿ Spëëd Mëtäl Cödïng
Projects: CacaANSICam | Date Determinator | DVB-Scraping | Filmnächte-Scraping | GeeKal | Gruntmaster | Harvester | Hirn | Irb | Jargon-File | Ruby-MediaWiki | Miniwebserver | Momomoto | Pentabarf | Podcast-fetching | Ruby | Ruby-Geekend | Ruby und Ruby on Rails | Sedusa | VDS-Badges | Xmotoctl | Youtube-Scraping