ordinals 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e10555694ad5291381edc71af98ba868a6f1f51a42236445873a27e4afbcd177
4
- data.tar.gz: a751e7a56a4437d162f055fcf838acbf926a8ab0d89ac7559e99ec2a6f312882
3
+ metadata.gz: fec9f519a6abfabeae1243ccd48ab0abdd0b03db8cf1f58256fbea7346673a8b
4
+ data.tar.gz: 7633ca1833fbbe8a41fc31608c9c084c983342a3abe33a2dda08422ae65eb3a1
5
5
  SHA512:
6
- metadata.gz: f40f08b9217c1b85a45b3310f21b5acdd14a01d051b989d8abc78cdd88198ec76184b35488fc1f4f5f849224c1793b8e6b23b3ac38b4f36e723b5518b6db8fd6
7
- data.tar.gz: bf8d701dd8d75045dc049a7aad636328f616c3a07a5d2a14781b4ac1953dd8a29dfdbea830693ba3e75390fc598e5aa2e06f58d8e6d209e65a19058c5e18b901
6
+ metadata.gz: e89f0c5897973530ccabc577f4e055645ae428abbe35430252131992a95a4058e31c4e31a40717c24dbf1237067b153669a7e2a25b0e688f1c2495c58c73b476
7
+ data.tar.gz: f225b18511b8eea28e0f8068198ad5076a6632cdab4850cf1f70a7f712b1476b66c8990b88f809f93fb2588d3fb6ac7960785e7db744ef23800467b0b2ce252f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ### 1.1.0
2
+
1
3
  ### 0.0.1 / 2023-03-23
2
4
 
3
5
  * Everything is new. First release
data/Manifest.txt CHANGED
@@ -4,4 +4,6 @@ README.md
4
4
  Rakefile
5
5
  lib/ordinals.rb
6
6
  lib/ordinals/api.rb
7
+ lib/ordinals/recursive/composite.rb
8
+ lib/ordinals/recursive/image.rb
7
9
  lib/ordinals/stats.rb
data/Rakefile CHANGED
@@ -3,14 +3,14 @@ require 'hoe'
3
3
 
4
4
  ###
5
5
  # hack/ quick fix for broken intuit_values - overwrite with dummy
6
- class Hoe
7
- def intuit_values( input ); end
8
- end
6
+ # class Hoe
7
+ # def intuit_values( input ); end
8
+ # end
9
9
 
10
10
 
11
11
  Hoe.spec 'ordinals' do
12
12
 
13
- self.version = '1.0.3'
13
+ self.version = '1.1.0'
14
14
 
15
15
  self.summary = 'ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin, Litecoin, Dogecoin & co.'
16
16
  self.description = summary
@@ -0,0 +1,78 @@
1
+ ###
2
+ # helpers for recursive images (in .SVG)
3
+
4
+
5
+ class RecursiveImageComposite
6
+ def initialize( cols, rows,
7
+ width: 100, height: 100 )
8
+ @tile_cols = cols
9
+ @tile_rows = rows
10
+
11
+ @tile_width = width
12
+ @tile_height = height
13
+
14
+ @recursions = []
15
+ end
16
+
17
+
18
+ def count() @recursions.size; end
19
+ alias_method :size, :count ## add size alias (confusing if starting with 0?) - why? why not?
20
+
21
+ def tile_width() @tile_width; end
22
+ def tile_height() @tile_height; end
23
+ def width() @tile_width*@tile_cols; end
24
+ def height() @tile_height*@tile_rows; end
25
+
26
+ def add( obj ) @recursions << obj; end
27
+ alias_method :<<, :add
28
+
29
+ def to_svg
30
+ buf =<<TXT
31
+ <svg
32
+ xmlns="http://www.w3.org/2000/svg"
33
+ width="100%" height="100%"
34
+ viewBox="0 0 #{width} #{height}">
35
+ TXT
36
+
37
+ @recursions.each_with_index do |recursion,i|
38
+ y,x = i.divmod( @tile_cols )
39
+
40
+ if recursion.is_a?( RecursiveImage )
41
+ comment = "№#{i} @ (#{x}/#{y})"
42
+ buf += <<TXT
43
+ <g transform="translate(#{x*@tile_width},#{y*@tile_height})">
44
+ <!-- #{comment} -->
45
+ #{recursion.to_svg( :inline )}
46
+ </g>
47
+ TXT
48
+ else
49
+ id, opts = recursion.is_a?( Array )? recursion : [recursion, {}]
50
+
51
+ pixelate = opts.has_key?(:pixelate) ? opts[:pixelate]
52
+ : false
53
+ comment = opts.has_key?(:comment) ? opts[:comment]
54
+ : "№#{i} @ (#{x}/#{y})"
55
+
56
+
57
+ style = pixelate ? %Q[style="image-rendering: pixelated;"] : ''
58
+
59
+ buf += <<TXT
60
+ <g transform="translate(#{x*@tile_width},#{y*@tile_height})">
61
+ <!-- #{comment} -->
62
+ <image
63
+ width="#{@tile_width}" height="#{@tile_height}"
64
+ href="/content/#{id}"
65
+ #{style} />
66
+ </g>
67
+ TXT
68
+ end
69
+ end
70
+
71
+
72
+ buf += <<TXT
73
+ </svg>
74
+ TXT
75
+
76
+ buf
77
+ end
78
+ end # class RecursiveImageComposite
@@ -0,0 +1,77 @@
1
+ ###
2
+ # helpers for recursive images (in .SVG)
3
+
4
+
5
+ class RecursiveImage
6
+ def initialize( width, height )
7
+ @width = width
8
+ @height = height
9
+
10
+ @recursions = []
11
+ end
12
+
13
+ def add( obj ) @recursions << obj; end
14
+ alias_method :<<, :add
15
+
16
+ def count() @recursions.size; end
17
+ alias_method :size, :count ## add size alias (confusing if starting with 0?) - why? why not?
18
+
19
+ def width() @width; end
20
+ def height() @height; end
21
+
22
+
23
+ def to_svg( format=:standalone )
24
+ buf = ''
25
+
26
+ if [:standalone].include?( format.downcase.to_sym )
27
+ buf +=<<TXT
28
+ <svg
29
+ xmlns="http://www.w3.org/2000/svg"
30
+ width="100%" height="100%"
31
+ viewBox="0 0 #{width} #{height}">
32
+ TXT
33
+ else ## assume :inline/:embed or such
34
+ ## todo/check: add px e.g. 100 => 100px - why? why not?
35
+ buf +=<<TXT
36
+ <svg width="#{width}" height="#{height}">
37
+ TXT
38
+ end
39
+
40
+ @recursions.each_with_index do |recursion,i|
41
+ id, opts = recursion.is_a?( Array )? recursion : [recursion, {}]
42
+
43
+ pixelate = opts.has_key?(:pixelate) ? opts[:pixelate]
44
+ : false
45
+
46
+ style = pixelate ? %Q[style="image-rendering: pixelated;"] : ''
47
+
48
+ ## note: assumes spritesheet has tile of same size as image itself!!!!
49
+ spritesheet = opts[:spritesheet]
50
+ if spritesheet
51
+ num = opts[:num] || opts[:tile]
52
+ spritesheet_width = spritesheet[0]
53
+ tile_cols = spritesheet_width/width
54
+ y,x = num.divmod( tile_cols )
55
+
56
+ buf += <<TXT
57
+ <svg viewBox="#{x*width} #{y*height} #{width} #{height}">
58
+ <image href="/content/#{id}"
59
+ #{style} />
60
+ </svg>
61
+ TXT
62
+ else
63
+ buf += <<TXT
64
+ <image href="/content/#{id}"
65
+ #{style} />
66
+ TXT
67
+ end
68
+ end
69
+
70
+ buf += <<TXT
71
+ </svg>
72
+ TXT
73
+ buf
74
+ end # method to_svg
75
+ end # class RecursiveImage
76
+
77
+
data/lib/ordinals.rb CHANGED
@@ -88,4 +88,11 @@ require_relative 'ordinals/api'
88
88
  require_relative 'ordinals/stats'
89
89
 
90
90
 
91
+ ### add recursive image helpers
92
+ require_relative 'ordinals/recursive/image'
93
+ require_relative 'ordinals/recursive/composite'
94
+
95
+ ## add conveniecen shortcuts/alias - why? why not?
96
+ RcsvImage = RecursiveImage
97
+ RcsvImageComposite = RecursiveImageComposite
91
98
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinals
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.23'
67
+ version: '4.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.23'
74
+ version: '4.0'
75
75
  description: ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin,
76
76
  Litecoin, Dogecoin & co.
77
77
  email: gerald.bauer@gmail.com
@@ -88,6 +88,8 @@ files:
88
88
  - Rakefile
89
89
  - lib/ordinals.rb
90
90
  - lib/ordinals/api.rb
91
+ - lib/ordinals/recursive/composite.rb
92
+ - lib/ordinals/recursive/image.rb
91
93
  - lib/ordinals/stats.rb
92
94
  homepage: https://github.com/ordbase/ordbase
93
95
  licenses:
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
112
  - !ruby/object:Gem::Version
111
113
  version: '0'
112
114
  requirements: []
113
- rubygems_version: 3.3.7
115
+ rubygems_version: 3.4.10
114
116
  signing_key:
115
117
  specification_version: 4
116
118
  summary: ordinals gem - ordinals (inscription) api wrapper & helpers for Bitcoin,