pixelflow_canvas 0.7.4 → 0.7.6
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/LICENSE +674 -0
- data/README.md +3 -41
- data/docs/.gitignore +15 -0
- data/docs/Gemfile +7 -0
- data/docs/Gemfile.lock +92 -0
- data/{LICENSE.txt → docs/LICENSE} +6 -6
- data/docs/README.md +174 -0
- data/docs/_config.yml +11 -0
- data/docs/advanced_use.md +37 -0
- data/docs/drawing_things.md +296 -0
- data/docs/images/4x6.png +0 -0
- data/docs/images/6x10.png +0 -0
- data/docs/images/7x13.png +0 -0
- data/docs/images/7x13B.png +0 -0
- data/docs/images/8x13.png +0 -0
- data/docs/images/8x13B.png +0 -0
- data/docs/images/9x15.png +0 -0
- data/docs/images/9x15B.png +0 -0
- data/docs/images/code/0ba813cd6b7e0ae0.png +0 -0
- data/docs/images/code/30c5ac94e5fa22ba.png +0 -0
- data/docs/images/code/3871051301832e44.png +0 -0
- data/docs/images/code/40acf0284459aa0e.png +0 -0
- data/docs/images/code/4eb9d4f97e05c739.png +0 -0
- data/docs/images/code/584e2ee3b7526718.png +0 -0
- data/docs/images/code/7fa15cea8c83a542.png +0 -0
- data/docs/images/code/809d9ce7d7a8ce6c.png +0 -0
- data/docs/images/code/85abc3576f6d78b1.png +0 -0
- data/docs/images/code/ec32331b354119d2.png +0 -0
- data/docs/images/code/ef667cfe7ff65c27.png +0 -0
- data/docs/index.md +126 -0
- data/docs/palettes.md +3192 -0
- data/docs/render-docs.rb +98 -0
- data/lib/pixelflow_canvas/palettes.yaml +257 -0
- data/lib/pixelflow_canvas/version.rb +1 -1
- data/lib/pixelflow_canvas.rb +28 -12
- metadata +33 -9
- data/sig/pixelflow_canvas.rbs +0 -4
- data/test-anaglyph.rb +0 -15
- data/test-sirds.rb +0 -46
- data/test-triangle.rb +0 -25
- data/test-turtle.rb +0 -14
- data/test.rb +0 -36
data/docs/render-docs.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
require 'yaml'
|
5
|
+
require '../lib/pixelflow_canvas'
|
6
|
+
require 'digest'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
palettes = YAML.load(File.read('../lib/pixelflow_canvas/palettes.yaml'))
|
10
|
+
|
11
|
+
s = StringIO.open do |io|
|
12
|
+
palettes.each do |name, palette|
|
13
|
+
io.puts
|
14
|
+
io.puts "#### #{name}"
|
15
|
+
io.puts
|
16
|
+
io.puts "<div class='swatches'>"
|
17
|
+
palette.each.with_index do |color, i|
|
18
|
+
io.puts "<span style='background-color: #{color}'><span>#{i}</span></span>"
|
19
|
+
end
|
20
|
+
io.puts "</div>"
|
21
|
+
end
|
22
|
+
io.string
|
23
|
+
end
|
24
|
+
|
25
|
+
readme = File.read('palettes.md')
|
26
|
+
readme.sub!(/<!-- palettes start -->(.*?)<!-- palettes end -->/m, "<!-- palettes start -->\n#{s}\n<!-- palettes end -->")
|
27
|
+
File.write('palettes.md', readme)
|
28
|
+
|
29
|
+
s = StringIO.open do |io|
|
30
|
+
Dir['../lib/pixelflow_canvas/fonts/*.bdf'].sort.each do |path|
|
31
|
+
font = File.basename(path).split('.').first
|
32
|
+
width = font.split('x').first.to_i
|
33
|
+
height = font.split('x').last.to_i + 1
|
34
|
+
scale = 8
|
35
|
+
png_path = "images/#{font}.png"
|
36
|
+
unless File.exist?(png_path)
|
37
|
+
Pixelflow::Canvas.new(width * 26 * scale + 2 * scale, height * 4 * scale + 2 * scale, :palette) do
|
38
|
+
set_draw_mode(:buffered)
|
39
|
+
set_color(15)
|
40
|
+
fill_rect(0, 0, width * 26 * scale + 2 * scale, height * 4 * scale + 2 * scale)
|
41
|
+
set_color(0)
|
42
|
+
draw_text(scale, scale, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', font, 8)
|
43
|
+
draw_text(scale, height * 8 + scale, 'abcdefghijklmnopqrstuvwxyz', font, 8)
|
44
|
+
draw_text(scale, height * 8 * 2 + scale, '`1234567890-=~!@#$%^&*()_+', font, 8)
|
45
|
+
draw_text(scale, height * 8 * 3 + scale, ',./<>?;\':"[]{}|\\äöüÄÖÜß°éµ', font, 8)
|
46
|
+
flip()
|
47
|
+
save_as_png(png_path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
io.puts
|
51
|
+
io.puts "#### #{font}"
|
52
|
+
io.puts
|
53
|
+
io.puts "<img src='#{png_path}' alt='#{font}'>"
|
54
|
+
end
|
55
|
+
io.string
|
56
|
+
end
|
57
|
+
|
58
|
+
readme = File.read('drawing_things.md')
|
59
|
+
readme.sub!(/<!-- fonts start -->(.*?)<!-- fonts end -->/m, "<!-- fonts start -->\n#{s}\n<!-- fonts end -->")
|
60
|
+
File.write('drawing_things.md', readme)
|
61
|
+
|
62
|
+
Dir['*.md'].each do |path|
|
63
|
+
s = File.read(path)
|
64
|
+
i = 0
|
65
|
+
loop do
|
66
|
+
i0 = s.index('<!-- code begin', i)
|
67
|
+
break unless i0
|
68
|
+
i = i0 + 1
|
69
|
+
i1 = s.index('code end -->', i0)
|
70
|
+
snippet = s[i0+15..i1-1]
|
71
|
+
snippet.strip!
|
72
|
+
sha1 = Digest::SHA1.hexdigest(snippet)[0, 16]
|
73
|
+
png_path = "images/code/#{sha1}.png"
|
74
|
+
code = StringIO.open do |io|
|
75
|
+
io.puts "require 'pixelflow_canvas'"
|
76
|
+
io.print "canvas = "
|
77
|
+
io.puts snippet
|
78
|
+
io.puts "canvas.save_as_png('#{png_path}')"
|
79
|
+
io.string
|
80
|
+
end
|
81
|
+
puts '-' * 20
|
82
|
+
puts code
|
83
|
+
puts '-' * 20
|
84
|
+
unless File.exist?(png_path)
|
85
|
+
FileUtils.mkpath(File.dirname(png_path))
|
86
|
+
puts "CREATING #{png_path}"
|
87
|
+
puts code
|
88
|
+
IO.popen('ruby', 'r+') do |io|
|
89
|
+
io.write(code)
|
90
|
+
io.close_write
|
91
|
+
io.read
|
92
|
+
end
|
93
|
+
end
|
94
|
+
newline_index = s.index("\n", i1)
|
95
|
+
s[i1+12..newline_index] = "<img class='full' src='#{png_path}'>\n"
|
96
|
+
end
|
97
|
+
File.open(path, 'w') { |f| f.write(s) }
|
98
|
+
end
|
@@ -2419,6 +2419,263 @@
|
|
2419
2419
|
- "#85c448"
|
2420
2420
|
- "#439d40"
|
2421
2421
|
- "#29694e"
|
2422
|
+
:vga:
|
2423
|
+
- "#000000"
|
2424
|
+
- "#0000aa"
|
2425
|
+
- "#00aa00"
|
2426
|
+
- "#00aaaa"
|
2427
|
+
- "#aa0000"
|
2428
|
+
- "#aa00aa"
|
2429
|
+
- "#aa5500"
|
2430
|
+
- "#aaaaaa"
|
2431
|
+
- "#555555"
|
2432
|
+
- "#5555ff"
|
2433
|
+
- "#55ff55"
|
2434
|
+
- "#55ffff"
|
2435
|
+
- "#ff5555"
|
2436
|
+
- "#ff55ff"
|
2437
|
+
- "#ffff55"
|
2438
|
+
- "#ffffff"
|
2439
|
+
- "#000000"
|
2440
|
+
- "#141414"
|
2441
|
+
- "#202020"
|
2442
|
+
- "#2c2c2c"
|
2443
|
+
- "#383838"
|
2444
|
+
- "#454545"
|
2445
|
+
- "#515151"
|
2446
|
+
- "#616161"
|
2447
|
+
- "#717171"
|
2448
|
+
- "#828282"
|
2449
|
+
- "#929292"
|
2450
|
+
- "#a2a2a2"
|
2451
|
+
- "#b6b6b6"
|
2452
|
+
- "#cbcbcb"
|
2453
|
+
- "#e3e3e3"
|
2454
|
+
- "#ffffff"
|
2455
|
+
- "#0000ff"
|
2456
|
+
- "#4100ff"
|
2457
|
+
- "#7d00ff"
|
2458
|
+
- "#be00ff"
|
2459
|
+
- "#ff00ff"
|
2460
|
+
- "#ff00be"
|
2461
|
+
- "#ff007d"
|
2462
|
+
- "#ff0041"
|
2463
|
+
- "#ff0000"
|
2464
|
+
- "#ff4100"
|
2465
|
+
- "#ff7d00"
|
2466
|
+
- "#ffbe00"
|
2467
|
+
- "#ffff00"
|
2468
|
+
- "#beff00"
|
2469
|
+
- "#7dff00"
|
2470
|
+
- "#41ff00"
|
2471
|
+
- "#00ff00"
|
2472
|
+
- "#00ff41"
|
2473
|
+
- "#00ff7d"
|
2474
|
+
- "#00ffbe"
|
2475
|
+
- "#00ffff"
|
2476
|
+
- "#00beff"
|
2477
|
+
- "#007dff"
|
2478
|
+
- "#0041ff"
|
2479
|
+
- "#7d7dff"
|
2480
|
+
- "#9e7dff"
|
2481
|
+
- "#be7dff"
|
2482
|
+
- "#df7dff"
|
2483
|
+
- "#ff7dff"
|
2484
|
+
- "#ff7ddf"
|
2485
|
+
- "#ff7dbe"
|
2486
|
+
- "#ff7d9e"
|
2487
|
+
- "#ff7d7d"
|
2488
|
+
- "#ff9e7d"
|
2489
|
+
- "#ffbe7d"
|
2490
|
+
- "#ffdf7d"
|
2491
|
+
- "#ffff7d"
|
2492
|
+
- "#dfff7d"
|
2493
|
+
- "#beff7d"
|
2494
|
+
- "#9eff7d"
|
2495
|
+
- "#7dff7d"
|
2496
|
+
- "#7dff9e"
|
2497
|
+
- "#7dffbe"
|
2498
|
+
- "#7dffdf"
|
2499
|
+
- "#7dffff"
|
2500
|
+
- "#7ddfff"
|
2501
|
+
- "#7dbeff"
|
2502
|
+
- "#7d9eff"
|
2503
|
+
- "#b6b6ff"
|
2504
|
+
- "#c7b6ff"
|
2505
|
+
- "#dbb6ff"
|
2506
|
+
- "#ebb6ff"
|
2507
|
+
- "#ffb6ff"
|
2508
|
+
- "#ffb6eb"
|
2509
|
+
- "#ffb6db"
|
2510
|
+
- "#ffb6c7"
|
2511
|
+
- "#ffb6b6"
|
2512
|
+
- "#ffc7b6"
|
2513
|
+
- "#ffdbb6"
|
2514
|
+
- "#ffebb6"
|
2515
|
+
- "#ffffb6"
|
2516
|
+
- "#ebffb6"
|
2517
|
+
- "#dbffb6"
|
2518
|
+
- "#c7ffb6"
|
2519
|
+
- "#b6ffb6"
|
2520
|
+
- "#b6ffc7"
|
2521
|
+
- "#b6ffdb"
|
2522
|
+
- "#b6ffeb"
|
2523
|
+
- "#b6ffff"
|
2524
|
+
- "#b6ebff"
|
2525
|
+
- "#b6dbff"
|
2526
|
+
- "#b6c7ff"
|
2527
|
+
- "#000071"
|
2528
|
+
- "#1c0071"
|
2529
|
+
- "#380071"
|
2530
|
+
- "#550071"
|
2531
|
+
- "#710071"
|
2532
|
+
- "#710055"
|
2533
|
+
- "#710038"
|
2534
|
+
- "#71001c"
|
2535
|
+
- "#710000"
|
2536
|
+
- "#711c00"
|
2537
|
+
- "#713800"
|
2538
|
+
- "#715500"
|
2539
|
+
- "#717100"
|
2540
|
+
- "#557100"
|
2541
|
+
- "#387100"
|
2542
|
+
- "#1c7100"
|
2543
|
+
- "#007100"
|
2544
|
+
- "#00711c"
|
2545
|
+
- "#007138"
|
2546
|
+
- "#007155"
|
2547
|
+
- "#007171"
|
2548
|
+
- "#005571"
|
2549
|
+
- "#003871"
|
2550
|
+
- "#001c71"
|
2551
|
+
- "#383871"
|
2552
|
+
- "#453871"
|
2553
|
+
- "#553871"
|
2554
|
+
- "#613871"
|
2555
|
+
- "#713871"
|
2556
|
+
- "#713861"
|
2557
|
+
- "#713855"
|
2558
|
+
- "#713845"
|
2559
|
+
- "#713838"
|
2560
|
+
- "#714538"
|
2561
|
+
- "#715538"
|
2562
|
+
- "#716138"
|
2563
|
+
- "#717138"
|
2564
|
+
- "#617138"
|
2565
|
+
- "#557138"
|
2566
|
+
- "#457138"
|
2567
|
+
- "#387138"
|
2568
|
+
- "#387145"
|
2569
|
+
- "#387155"
|
2570
|
+
- "#387161"
|
2571
|
+
- "#387171"
|
2572
|
+
- "#386171"
|
2573
|
+
- "#385571"
|
2574
|
+
- "#384571"
|
2575
|
+
- "#515171"
|
2576
|
+
- "#595171"
|
2577
|
+
- "#615171"
|
2578
|
+
- "#695171"
|
2579
|
+
- "#715171"
|
2580
|
+
- "#715169"
|
2581
|
+
- "#715161"
|
2582
|
+
- "#715159"
|
2583
|
+
- "#715151"
|
2584
|
+
- "#715951"
|
2585
|
+
- "#716151"
|
2586
|
+
- "#716951"
|
2587
|
+
- "#717151"
|
2588
|
+
- "#697151"
|
2589
|
+
- "#617151"
|
2590
|
+
- "#597151"
|
2591
|
+
- "#517151"
|
2592
|
+
- "#517159"
|
2593
|
+
- "#517161"
|
2594
|
+
- "#517169"
|
2595
|
+
- "#517171"
|
2596
|
+
- "#516971"
|
2597
|
+
- "#516171"
|
2598
|
+
- "#515971"
|
2599
|
+
- "#000041"
|
2600
|
+
- "#100041"
|
2601
|
+
- "#200041"
|
2602
|
+
- "#300041"
|
2603
|
+
- "#410041"
|
2604
|
+
- "#410030"
|
2605
|
+
- "#410020"
|
2606
|
+
- "#410010"
|
2607
|
+
- "#410000"
|
2608
|
+
- "#411000"
|
2609
|
+
- "#412000"
|
2610
|
+
- "#413000"
|
2611
|
+
- "#414100"
|
2612
|
+
- "#304100"
|
2613
|
+
- "#204100"
|
2614
|
+
- "#104100"
|
2615
|
+
- "#004100"
|
2616
|
+
- "#004110"
|
2617
|
+
- "#004120"
|
2618
|
+
- "#004130"
|
2619
|
+
- "#004141"
|
2620
|
+
- "#003041"
|
2621
|
+
- "#002041"
|
2622
|
+
- "#001041"
|
2623
|
+
- "#202041"
|
2624
|
+
- "#282041"
|
2625
|
+
- "#302041"
|
2626
|
+
- "#382041"
|
2627
|
+
- "#412041"
|
2628
|
+
- "#412038"
|
2629
|
+
- "#412030"
|
2630
|
+
- "#412028"
|
2631
|
+
- "#412020"
|
2632
|
+
- "#412820"
|
2633
|
+
- "#413020"
|
2634
|
+
- "#413820"
|
2635
|
+
- "#414120"
|
2636
|
+
- "#384120"
|
2637
|
+
- "#304120"
|
2638
|
+
- "#284120"
|
2639
|
+
- "#204120"
|
2640
|
+
- "#204128"
|
2641
|
+
- "#204130"
|
2642
|
+
- "#204138"
|
2643
|
+
- "#204141"
|
2644
|
+
- "#203841"
|
2645
|
+
- "#203041"
|
2646
|
+
- "#202841"
|
2647
|
+
- "#2c2c41"
|
2648
|
+
- "#302c41"
|
2649
|
+
- "#342c41"
|
2650
|
+
- "#3c2c41"
|
2651
|
+
- "#412c41"
|
2652
|
+
- "#412c3c"
|
2653
|
+
- "#412c34"
|
2654
|
+
- "#412c30"
|
2655
|
+
- "#412c2c"
|
2656
|
+
- "#41302c"
|
2657
|
+
- "#41342c"
|
2658
|
+
- "#413c2c"
|
2659
|
+
- "#41412c"
|
2660
|
+
- "#3c412c"
|
2661
|
+
- "#34412c"
|
2662
|
+
- "#30412c"
|
2663
|
+
- "#2c412c"
|
2664
|
+
- "#2c4130"
|
2665
|
+
- "#2c4134"
|
2666
|
+
- "#2c413c"
|
2667
|
+
- "#2c4141"
|
2668
|
+
- "#2c3c41"
|
2669
|
+
- "#2c3441"
|
2670
|
+
- "#2c3041"
|
2671
|
+
- "#000000"
|
2672
|
+
- "#000000"
|
2673
|
+
- "#000000"
|
2674
|
+
- "#000000"
|
2675
|
+
- "#000000"
|
2676
|
+
- "#000000"
|
2677
|
+
- "#000000"
|
2678
|
+
- "#000000"
|
2422
2679
|
:vines_flexible_linear_ramps:
|
2423
2680
|
- "#150a1f"
|
2424
2681
|
- "#280b26"
|
data/lib/pixelflow_canvas.rb
CHANGED
@@ -23,9 +23,10 @@ module Pixelflow
|
|
23
23
|
:buffered => 1
|
24
24
|
}
|
25
25
|
COMPOSE_MODES = {
|
26
|
-
:
|
26
|
+
:copy => 0,
|
27
27
|
:add => 1,
|
28
|
-
:subtract => 2
|
28
|
+
:subtract => 2,
|
29
|
+
:multiply => 3,
|
29
30
|
}
|
30
31
|
INTERPOLATION_MODES = {
|
31
32
|
:nearest => 0,
|
@@ -43,7 +44,7 @@ module Pixelflow
|
|
43
44
|
@color_mode = :rgb
|
44
45
|
@advance_mode = :right
|
45
46
|
@draw_mode = :direct
|
46
|
-
@compose_mode = :
|
47
|
+
@compose_mode = :copy
|
47
48
|
@palette = VGA_PALETTE.dup
|
48
49
|
@socket = TCPSocket.new('127.0.0.1', 19223)
|
49
50
|
set_size(width, height)
|
@@ -107,7 +108,7 @@ module Pixelflow
|
|
107
108
|
unless COMPOSE_MODES.keys.include?(mode)
|
108
109
|
raise "Invalid compose mode: #{mode}"
|
109
110
|
end
|
110
|
-
if mode != :
|
111
|
+
if mode != :copy && @color_mode != :rgb
|
111
112
|
raise "Cannot switch compose mode to #{mode} in palette color mode!"
|
112
113
|
end
|
113
114
|
@compose_mode = mode
|
@@ -132,8 +133,12 @@ module Pixelflow
|
|
132
133
|
def ensure_max_fps(fps)
|
133
134
|
fps1 = 1.0 / fps
|
134
135
|
t = Time.now.to_f
|
135
|
-
|
136
|
-
|
136
|
+
if @last_timestamp
|
137
|
+
loop do
|
138
|
+
sleep 0.01
|
139
|
+
break if (Time.now.to_f - @last_timestamp) >= fps1
|
140
|
+
end
|
141
|
+
end
|
137
142
|
@last_timestamp = t
|
138
143
|
end
|
139
144
|
|
@@ -276,6 +281,17 @@ module Pixelflow
|
|
276
281
|
r = 255 if r > 255
|
277
282
|
g = 255 if g > 255
|
278
283
|
b = 255 if b > 255
|
284
|
+
elsif @compose_mode == :subtract
|
285
|
+
r = @screen[offset + 0] - r
|
286
|
+
g = @screen[offset + 1] - g
|
287
|
+
b = @screen[offset + 2] - b
|
288
|
+
r = 0 if r < 0
|
289
|
+
g = 0 if g < 0
|
290
|
+
b = 0 if b < 0
|
291
|
+
elsif @compose_mode == :multiply
|
292
|
+
r = (@screen[offset + 0] * r) / 255
|
293
|
+
g = (@screen[offset + 1] * g) / 255
|
294
|
+
b = (@screen[offset + 2] * b) / 255
|
279
295
|
end
|
280
296
|
@screen[offset + 0] = r
|
281
297
|
@screen[offset + 1] = g
|
@@ -447,7 +463,7 @@ module Pixelflow
|
|
447
463
|
fa2 = 4 * a2
|
448
464
|
fb2 = 4 * b2
|
449
465
|
x0 = 0
|
450
|
-
y0 =
|
466
|
+
y0 = rb
|
451
467
|
sigma = 2 * b2 + a2 * (1 - 2 * rb)
|
452
468
|
while b2 * x0 <= a2 * y0
|
453
469
|
set_pixel(x + x0, y + y0)
|
@@ -461,7 +477,7 @@ module Pixelflow
|
|
461
477
|
sigma += b2 * ((4 * x0) + 6)
|
462
478
|
x0 += 1
|
463
479
|
end
|
464
|
-
x0 =
|
480
|
+
x0 = ra
|
465
481
|
y0 = 0
|
466
482
|
sigma = 2 * a2 + b2 * (1 - 2 * ra)
|
467
483
|
while a2 * y0 <= b2 * x0
|
@@ -488,7 +504,7 @@ module Pixelflow
|
|
488
504
|
fa2 = 4 * a2
|
489
505
|
fb2 = 4 * b2
|
490
506
|
x0 = 0
|
491
|
-
y0 =
|
507
|
+
y0 = rb
|
492
508
|
sigma = 2 * b2 + a2 * (1 - 2 * rb)
|
493
509
|
while b2 * x0 <= a2 * y0
|
494
510
|
(x - x0..x + x0).each do |i|
|
@@ -502,7 +518,7 @@ module Pixelflow
|
|
502
518
|
sigma += b2 * ((4 * x0) + 6)
|
503
519
|
x0 += 1
|
504
520
|
end
|
505
|
-
x0 =
|
521
|
+
x0 = ra
|
506
522
|
y0 = 0
|
507
523
|
sigma = 2 * a2 + b2 * (1 - 2 * ra)
|
508
524
|
while a2 * y0 <= b2 * x0
|
@@ -743,13 +759,13 @@ module Pixelflow
|
|
743
759
|
end
|
744
760
|
end
|
745
761
|
|
746
|
-
def
|
762
|
+
def text_width(s, font, scale = 1)
|
747
763
|
Canvas.load_font(font)
|
748
764
|
width = 0
|
749
765
|
s.each_char do |c|
|
750
766
|
glyph = @@cypher_fonts[font][c.ord]
|
751
767
|
if glyph
|
752
|
-
width += glyph[:width]
|
768
|
+
width += glyph[:width] * scale
|
753
769
|
end
|
754
770
|
end
|
755
771
|
width
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixelflow_canvas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Specht
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|
@@ -32,9 +32,39 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- LICENSE
|
35
|
+
- LICENSE
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
|
+
- docs/.gitignore
|
39
|
+
- docs/Gemfile
|
40
|
+
- docs/Gemfile.lock
|
41
|
+
- docs/LICENSE
|
42
|
+
- docs/README.md
|
43
|
+
- docs/_config.yml
|
44
|
+
- docs/advanced_use.md
|
45
|
+
- docs/drawing_things.md
|
46
|
+
- docs/images/4x6.png
|
47
|
+
- docs/images/6x10.png
|
48
|
+
- docs/images/7x13.png
|
49
|
+
- docs/images/7x13B.png
|
50
|
+
- docs/images/8x13.png
|
51
|
+
- docs/images/8x13B.png
|
52
|
+
- docs/images/9x15.png
|
53
|
+
- docs/images/9x15B.png
|
54
|
+
- docs/images/code/0ba813cd6b7e0ae0.png
|
55
|
+
- docs/images/code/30c5ac94e5fa22ba.png
|
56
|
+
- docs/images/code/3871051301832e44.png
|
57
|
+
- docs/images/code/40acf0284459aa0e.png
|
58
|
+
- docs/images/code/4eb9d4f97e05c739.png
|
59
|
+
- docs/images/code/584e2ee3b7526718.png
|
60
|
+
- docs/images/code/7fa15cea8c83a542.png
|
61
|
+
- docs/images/code/809d9ce7d7a8ce6c.png
|
62
|
+
- docs/images/code/85abc3576f6d78b1.png
|
63
|
+
- docs/images/code/ec32331b354119d2.png
|
64
|
+
- docs/images/code/ef667cfe7ff65c27.png
|
65
|
+
- docs/index.md
|
66
|
+
- docs/palettes.md
|
67
|
+
- docs/render-docs.rb
|
38
68
|
- lib/pixelflow_canvas.rb
|
39
69
|
- lib/pixelflow_canvas/fonts/4x6.bdf
|
40
70
|
- lib/pixelflow_canvas/fonts/6x10.bdf
|
@@ -47,12 +77,6 @@ files:
|
|
47
77
|
- lib/pixelflow_canvas/palettes.yaml
|
48
78
|
- lib/pixelflow_canvas/version.rb
|
49
79
|
- lib/pixelflow_canvas/vga_palette.rb
|
50
|
-
- sig/pixelflow_canvas.rbs
|
51
|
-
- test-anaglyph.rb
|
52
|
-
- test-sirds.rb
|
53
|
-
- test-triangle.rb
|
54
|
-
- test-turtle.rb
|
55
|
-
- test.rb
|
56
80
|
homepage: https://github.com/specht/pixelflow_canvas_ruby
|
57
81
|
licenses:
|
58
82
|
- GPL-3.0-only
|
data/sig/pixelflow_canvas.rbs
DELETED
data/test-anaglyph.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require './lib/pixelflow_canvas.rb'
|
2
|
-
|
3
|
-
width = 256
|
4
|
-
height = 256
|
5
|
-
|
6
|
-
canvas = Pixelflow::Canvas.new(width, height, :rgb)
|
7
|
-
canvas.set_compose_mode(:add)
|
8
|
-
|
9
|
-
canvas.set_color(255, 0, 0)
|
10
|
-
canvas.draw_line(10, 10, 100, 200)
|
11
|
-
|
12
|
-
canvas.set_color(0, 255, 0)
|
13
|
-
canvas.draw_line(20, 10, 90, 200)
|
14
|
-
|
15
|
-
canvas.save_as_png('anaglyph.png')
|
data/test-sirds.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require './lib/pixelflow_canvas.rb'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
def depth(x, y)
|
5
|
-
r = (x - 128) ** 2 + (y - 128) ** 2
|
6
|
-
return 10 if r < 5000
|
7
|
-
r * 0.001
|
8
|
-
end
|
9
|
-
|
10
|
-
width = 256
|
11
|
-
height = 256
|
12
|
-
|
13
|
-
canvas = Pixelflow::Canvas.new(width, height, :palette)
|
14
|
-
(0...64).each { |i| canvas.set_palette(i, i * 4, i * 4, i * 4) }
|
15
|
-
(0...height).each do |y|
|
16
|
-
(0...48).each do |x|
|
17
|
-
canvas.set_pixel(x, y, rand(64))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
(0...height).each do |y|
|
21
|
-
sx = 0
|
22
|
-
dx = 48
|
23
|
-
while dx < width
|
24
|
-
c = canvas.get_pixel(sx, y)
|
25
|
-
canvas.set_pixel(dx, y, c)
|
26
|
-
dx += 1
|
27
|
-
sx = dx - 48 + depth(dx - 24, y)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# (0...height).each do |y|
|
32
|
-
# (0...width).each do |x|
|
33
|
-
# d = depth(x, y)
|
34
|
-
# canvas.set_pixel(x, y, d)
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
|
38
|
-
i = 0
|
39
|
-
loop do
|
40
|
-
canvas.fetch_events do |event|
|
41
|
-
STDERR.puts event.to_json
|
42
|
-
end
|
43
|
-
canvas.ensure_max_fps(30)
|
44
|
-
i += 1
|
45
|
-
# STDERR.puts "\r #{i}"
|
46
|
-
end
|
data/test-triangle.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require './lib/pixelflow_canvas.rb'
|
2
|
-
|
3
|
-
width = 256
|
4
|
-
height = 256
|
5
|
-
|
6
|
-
canvas = Pixelflow::Canvas.new(width, height, :palette)
|
7
|
-
turtle = Pixelflow::Turtle.new(canvas)
|
8
|
-
turtle.set_color(13)
|
9
|
-
|
10
|
-
def draw(canvas, x0, y0, x1, y1, x2, y2, level)
|
11
|
-
canvas.draw_triangle(x0, y0, x1, y1, x2, y2)
|
12
|
-
mx0 = (x0 + x1) / 2
|
13
|
-
my0 = (y0 + y1) / 2
|
14
|
-
mx1 = (x1 + x2) / 2
|
15
|
-
my1 = (y1 + y2) / 2
|
16
|
-
mx2 = (x2 + x0) / 2
|
17
|
-
my2 = (y2 + y0) / 2
|
18
|
-
if level > 0
|
19
|
-
draw(canvas, x0, y0, mx0, my0, mx2, my2, level - 1)
|
20
|
-
draw(canvas, x1, y1, mx1, my1, mx0, my0, level - 1)
|
21
|
-
draw(canvas, x2, y2, mx2, my2, mx1, my1, level - 1)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
draw(canvas, 128, 10, 10, 186, 246, 246, 5)
|
data/test-turtle.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require './lib/pixelflow_canvas.rb'
|
2
|
-
|
3
|
-
width = 256
|
4
|
-
height = 256
|
5
|
-
|
6
|
-
canvas = Pixelflow::Canvas.new(width, height, :palette)
|
7
|
-
turtle = Pixelflow::Turtle.new(canvas)
|
8
|
-
turtle.set_color(13)
|
9
|
-
|
10
|
-
turtle.forward(10)
|
11
|
-
turtle.turn_right(90)
|
12
|
-
turtle.forward(10)
|
13
|
-
turtle.turn_right(90)
|
14
|
-
turtle.forward(10)
|
data/test.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require './lib/pixelflow_canvas.rb'
|
2
|
-
|
3
|
-
def depth(x, y)
|
4
|
-
r = (x - 128) ** 2 + (y - 128) ** 2
|
5
|
-
return 10 if r < 5000
|
6
|
-
r * 0.001
|
7
|
-
end
|
8
|
-
|
9
|
-
width = 256
|
10
|
-
height = 256
|
11
|
-
|
12
|
-
canvas = Pixelflow::Canvas.new(width, height, :palette)
|
13
|
-
(0...64).each { |i| canvas.set_palette(i, i, i, i) }
|
14
|
-
(0...height).each do |y|
|
15
|
-
(0...48).each do |x|
|
16
|
-
canvas.set_pixel(x, y, rand(64))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
(0...height).each do |y|
|
20
|
-
sx = 0
|
21
|
-
dx = 48
|
22
|
-
while dx < width
|
23
|
-
c = canvas.get_pixel(sx, y)
|
24
|
-
canvas.set_pixel(dx, y, c)
|
25
|
-
dx += 1
|
26
|
-
sx = dx - 48 + depth(dx - 24, y)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# (0...height).each do |y|
|
31
|
-
# (0...width).each do |x|
|
32
|
-
# d = depth(x, y)
|
33
|
-
# canvas.set_pixel(x, y, d)
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
|