pixelflut 1.0.4 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/pxf +27 -35
- data/bin/pxf-info +32 -0
- data/lib/pixelflut/version.rb +1 -1
- data/lib/pixelflut.rb +16 -13
- data/pixelflut.gemspec +28 -0
- metadata +16 -14
- data/LICENSE +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e6890a9d13b0f4b2149dd49c8add1decaaa6876a62c1f9200d4c1b2d6f36ced
|
|
4
|
+
data.tar.gz: 7364299d22932c514afea765f5cb13a3c4d85d8b6c649330d1761ce6733126d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be62c10bdbbb3f5e316e48143da7b5d9a2c3be7bebab0a33d8728df5d6459f254e69a83f99e93d18068f31835ca8bc25adf5356ba345c46dabb926faf08b367c
|
|
7
|
+
data.tar.gz: 4210b816ff0cb3ed146c95e4301fc242d399b3d3065dbd9c9e1ebb829b9ab50ef683f95188ba5f7e6db927916eaace45061753b77ca19d7165d1001a366adb2d
|
data/bin/pxf
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
$stdout.sync = $stderr.sync = true
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if ARGV.index('-h') || ARGV.index('--help')
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
HELP
|
|
24
|
-
exit
|
|
25
|
-
end
|
|
5
|
+
def me = Process.setproctitle(File.basename(Process.argv0))
|
|
6
|
+
|
|
7
|
+
puts(<<~HELP) || exit if ARGV.index('-h') || ARGV.index('--help')
|
|
8
|
+
Usage: #{me} [options] <png_image>
|
|
9
|
+
|
|
10
|
+
Options:
|
|
11
|
+
--host <address> target host address (default 127.0.0.1)
|
|
12
|
+
-p, --port <port> target port (default 1234)
|
|
13
|
+
-c, --connections <count> count of connections (default 4)
|
|
14
|
+
-x, --transpose-x <x> transpose image <x> pixels
|
|
15
|
+
-y, --transpose-y <y> transpose image <y> pixels
|
|
16
|
+
--encode-text encode pixel in text format (default)
|
|
17
|
+
--encode-bin encode pixel in binary format
|
|
18
|
+
--use-processes use seperate processes (default)
|
|
19
|
+
--use-threads use threads instead of processes
|
|
20
|
+
-h, --help print this help
|
|
21
|
+
-v, --version print version information
|
|
22
|
+
HELP
|
|
26
23
|
|
|
27
24
|
if ARGV.index('-v') || ARGV.index('--version')
|
|
28
25
|
require_relative('../lib/pixelflut/version')
|
|
29
|
-
puts("#{
|
|
30
|
-
exit
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def die!(msg, code: 1)
|
|
34
|
-
$stderr.puts("#{$name}: #{msg}")
|
|
35
|
-
exit(code)
|
|
26
|
+
puts("#{me} - Pixelflut v#{Pixelflut::VERSION}") || exit
|
|
36
27
|
end
|
|
37
28
|
|
|
38
|
-
die!(
|
|
29
|
+
def die!(msg, code: 1) = $stderr.puts("#{me}: #{msg}") || exit(code)
|
|
30
|
+
die!("argument missing - try `#{me} --help`") if ARGV.empty?
|
|
39
31
|
|
|
40
32
|
require_relative('../lib/pixelflut')
|
|
41
33
|
|
|
@@ -52,7 +44,7 @@ module Configuration
|
|
|
52
44
|
|
|
53
45
|
def invalid(value, name)
|
|
54
46
|
die!("value for #{name} missing") if value.nil?
|
|
55
|
-
die!("invalid value for #{name} -
|
|
47
|
+
die!("invalid value for #{name} - #{value.inspect}")
|
|
56
48
|
end
|
|
57
49
|
|
|
58
50
|
def as_str(value, name)
|
|
@@ -95,7 +87,7 @@ module Configuration
|
|
|
95
87
|
end
|
|
96
88
|
|
|
97
89
|
def use_threads(address, data)
|
|
98
|
-
puts("#{
|
|
90
|
+
puts("#{me}: start #{data.size} threads for #{data.sum(&:size)} bytes")
|
|
99
91
|
Thread.report_on_exception = false
|
|
100
92
|
data.map! { Thread.start { Pixelflut::Sender.send(address, it) } }
|
|
101
93
|
GC.start
|
|
@@ -103,13 +95,13 @@ def use_threads(address, data)
|
|
|
103
95
|
end
|
|
104
96
|
|
|
105
97
|
def use_processes(address, data)
|
|
106
|
-
puts("#{
|
|
98
|
+
puts("#{me}: start #{data.size} processes for #{data.sum(&:size)} bytes")
|
|
107
99
|
data.size.times do |i|
|
|
108
100
|
next unless fork
|
|
109
101
|
data = data[i]
|
|
110
102
|
GC.start
|
|
111
|
-
|
|
112
|
-
Pixelflut::Sender.send(address, data) { puts("#{
|
|
103
|
+
me = Process.setproctitle("#{me}-#{'0' if i < 9}#{i + 1}")
|
|
104
|
+
Pixelflut::Sender.send(address, data) { puts("#{me}: #{it} bytes") }
|
|
113
105
|
end
|
|
114
106
|
GC.start
|
|
115
107
|
end
|
data/bin/pxf-info
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#! /bin/sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
if [ "$1" = '--help' ]
|
|
6
|
+
then
|
|
7
|
+
echo "Usage: ${0##*/} [-p|--port PORT] ADDRESS
|
|
8
|
+
|
|
9
|
+
Requests screen size of Pixelflut server at ADDRESS.
|
|
10
|
+
"
|
|
11
|
+
exit 0
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
PORT="1234"
|
|
15
|
+
ADDRESS=""
|
|
16
|
+
|
|
17
|
+
while [ $# -gt 0 ]
|
|
18
|
+
do
|
|
19
|
+
key="$1"
|
|
20
|
+
case $key in
|
|
21
|
+
-p|--port)
|
|
22
|
+
PORT="$2"
|
|
23
|
+
shift; shift
|
|
24
|
+
;;
|
|
25
|
+
*)
|
|
26
|
+
ADDRESS="$key"
|
|
27
|
+
shift
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
printf "SIZE\nQUIT\n" | nc "$ADDRESS" "$PORT"
|
data/lib/pixelflut/version.rb
CHANGED
data/lib/pixelflut.rb
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module Pixelflut
|
|
4
4
|
class << self
|
|
5
|
-
attr_accessor :file_name, :
|
|
5
|
+
attr_accessor :file_name, :encoding, :delta_x, :delta_y
|
|
6
|
+
attr_writer :count
|
|
6
7
|
|
|
7
|
-
def data
|
|
8
|
-
|
|
9
|
-
end
|
|
8
|
+
def data = sliced(convert(*load).shuffle!, count).map!(&:join)
|
|
9
|
+
def count = (@count ||= find_suggested_thread_count)
|
|
10
10
|
|
|
11
11
|
private
|
|
12
12
|
|
|
@@ -55,13 +55,7 @@ module Pixelflut
|
|
|
55
55
|
width.times do |x|
|
|
56
56
|
next if (a = blob.getbyte(pos += 4)) == 0
|
|
57
57
|
ret << format(
|
|
58
|
-
|
|
59
|
-
if a == 255
|
|
60
|
-
"PX %d %d %02x%02x%02x\n"
|
|
61
|
-
else
|
|
62
|
-
"PX %d %d %02x%02x%02x%02x\n"
|
|
63
|
-
end
|
|
64
|
-
),
|
|
58
|
+
"PX %d %d %02x%02x%02x#{'%02x' if a != 255}\n",
|
|
65
59
|
x + @delta_x,
|
|
66
60
|
y + @delta_y,
|
|
67
61
|
blob.getbyte(pos - 3),
|
|
@@ -87,10 +81,19 @@ module Pixelflut
|
|
|
87
81
|
end
|
|
88
82
|
ret
|
|
89
83
|
end
|
|
84
|
+
|
|
85
|
+
def find_suggested_thread_count
|
|
86
|
+
count = ENV['TC'].to_i
|
|
87
|
+
return count if count > 0
|
|
88
|
+
begin
|
|
89
|
+
require('etc') unless defined?(Etc)
|
|
90
|
+
Etc.nprocessors
|
|
91
|
+
rescue LoadError
|
|
92
|
+
4
|
|
93
|
+
end
|
|
94
|
+
end
|
|
90
95
|
end
|
|
91
96
|
|
|
92
|
-
@count = ENV['TC'].to_i
|
|
93
|
-
@count = 4 unless @count.positive?
|
|
94
97
|
@encoding = 'text'
|
|
95
98
|
@delta_x = @delta_y = 0
|
|
96
99
|
end
|
data/pixelflut.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/pixelflut/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'pixelflut'
|
|
7
|
+
spec.version = Pixelflut::VERSION
|
|
8
|
+
spec.summary = 'A fast Pixelflut client written in Ruby.'
|
|
9
|
+
spec.description = <<~DESCRIPTION.tr("\n", '')
|
|
10
|
+
Based on the idea of a simple server protocol to collaborate on a shared
|
|
11
|
+
canvas named [Pixelflut](https://cccgoe.de/wiki/Pixelflut) this gem
|
|
12
|
+
implements a fast Ruby client version.
|
|
13
|
+
DESCRIPTION
|
|
14
|
+
spec.author = 'Mike Blumtritt'
|
|
15
|
+
spec.licenses = %w[MIT Ruby]
|
|
16
|
+
spec.homepage = 'https://codeberg.org/mblumtritt/pixelflut'
|
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
|
|
19
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
20
|
+
|
|
21
|
+
spec.required_ruby_version = '> 3.0'
|
|
22
|
+
|
|
23
|
+
spec.add_dependency 'chunky_png'
|
|
24
|
+
|
|
25
|
+
spec.executables = %w[pxf pxf-info]
|
|
26
|
+
spec.files = Dir['lib/**/*.rb'] + %w[pixelflut.gemspec]
|
|
27
|
+
spec.extra_rdoc_files = %w[README.md]
|
|
28
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pixelflut
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Blumtritt
|
|
@@ -23,44 +23,46 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
-
description:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
implements a fast Ruby client version.
|
|
26
|
+
description: Based on the idea of a simple server protocol to collaborate on a sharedcanvas
|
|
27
|
+
named [Pixelflut](https://cccgoe.de/wiki/Pixelflut) this gemimplements a fast Ruby
|
|
28
|
+
client version.
|
|
30
29
|
executables:
|
|
31
30
|
- pxf
|
|
31
|
+
- pxf-info
|
|
32
32
|
extensions: []
|
|
33
33
|
extra_rdoc_files:
|
|
34
|
-
- LICENSE
|
|
35
34
|
- README.md
|
|
36
35
|
files:
|
|
37
|
-
- LICENSE
|
|
38
36
|
- README.md
|
|
39
37
|
- bin/pxf
|
|
38
|
+
- bin/pxf-info
|
|
40
39
|
- lib/pixelflut.rb
|
|
41
40
|
- lib/pixelflut/sender.rb
|
|
42
41
|
- lib/pixelflut/version.rb
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
- pixelflut.gemspec
|
|
43
|
+
homepage: https://codeberg.org/mblumtritt/pixelflut
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
- Ruby
|
|
45
47
|
metadata:
|
|
46
|
-
source_code_uri: https://
|
|
47
|
-
bug_tracker_uri: https://
|
|
48
|
+
source_code_uri: https://codeberg.org/mblumtritt/pixelflut
|
|
49
|
+
bug_tracker_uri: https://codeberg.org/mblumtritt/pixelflut/issues
|
|
48
50
|
rubygems_mfa_required: 'true'
|
|
49
51
|
rdoc_options: []
|
|
50
52
|
require_paths:
|
|
51
53
|
- lib
|
|
52
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
55
|
requirements:
|
|
54
|
-
- - "
|
|
56
|
+
- - ">"
|
|
55
57
|
- !ruby/object:Gem::Version
|
|
56
|
-
version:
|
|
58
|
+
version: '3.0'
|
|
57
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
60
|
requirements:
|
|
59
61
|
- - ">="
|
|
60
62
|
- !ruby/object:Gem::Version
|
|
61
63
|
version: '0'
|
|
62
64
|
requirements: []
|
|
63
|
-
rubygems_version:
|
|
65
|
+
rubygems_version: 4.0.11
|
|
64
66
|
specification_version: 4
|
|
65
67
|
summary: A fast Pixelflut client written in Ruby.
|
|
66
68
|
test_files: []
|
data/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2025 Mike Blumtritt
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|