sevgi-graphics 0.98.2 → 1.0.0
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/CHANGELOG.md +96 -2
- data/README.md +4 -1
- data/lib/sevgi/graphics/attribute.rb +8 -10
- data/lib/sevgi/graphics/auxiliary/canvas.rb +4 -4
- data/lib/sevgi/graphics/auxiliary/content.rb +5 -16
- data/lib/sevgi/graphics/document/base.rb +2 -2
- data/lib/sevgi/graphics/document.rb +15 -27
- data/lib/sevgi/graphics/element.rb +23 -8
- data/lib/sevgi/graphics/mixtures/call.rb +9 -24
- data/lib/sevgi/graphics/mixtures/core.rb +10 -9
- data/lib/sevgi/graphics/mixtures/duplicate.rb +4 -16
- data/lib/sevgi/graphics/mixtures/export.rb +2 -0
- data/lib/sevgi/graphics/mixtures/hatch.rb +5 -5
- data/lib/sevgi/graphics/mixtures/identify.rb +1 -1
- data/lib/sevgi/graphics/mixtures/inkscape.rb +23 -10
- data/lib/sevgi/graphics/mixtures/rdf.rb +1 -1
- data/lib/sevgi/graphics/mixtures/render.rb +11 -95
- data/lib/sevgi/graphics/mixtures/save.rb +2 -2
- data/lib/sevgi/graphics/mixtures/symbols.rb +2 -2
- data/lib/sevgi/graphics/mixtures/tile.rb +4 -4
- data/lib/sevgi/graphics/mixtures/transform.rb +22 -3
- data/lib/sevgi/graphics/mixtures/underscore.rb +2 -2
- data/lib/sevgi/graphics/mixtures/wrappers.rb +49 -0
- data/lib/sevgi/graphics/version.rb +1 -1
- data/lib/sevgi/graphics/xml.rb +4 -9
- data/lib/sevgi/graphics.rb +22 -17
- metadata +4 -4
data/lib/sevgi/graphics.rb
CHANGED
|
@@ -15,7 +15,7 @@ require_relative "graphics/version"
|
|
|
15
15
|
module Sevgi
|
|
16
16
|
# SVG document builder and DSL namespace.
|
|
17
17
|
#
|
|
18
|
-
# A document profile controls root metadata and preambles
|
|
18
|
+
# A document profile controls root metadata and preambles. A {Canvas} controls
|
|
19
19
|
# physical size, margins, viewport, and viewBox. {Graphics.SVG} combines them
|
|
20
20
|
# into an element tree. Library code keeps that tree as an object until it
|
|
21
21
|
# explicitly renders, validates, saves, or exports it.
|
|
@@ -25,9 +25,9 @@ module Sevgi
|
|
|
25
25
|
# circle cx: 5, cy: 5, r: 4
|
|
26
26
|
# end
|
|
27
27
|
# drawing.Render #=> "<svg width=\"10\" height=\"10\">\n <circle cx=\"5\" cy=\"5\" r=\"4\"/>\n</svg>"
|
|
28
|
-
# @see https://sevgi.roktas.dev/
|
|
29
|
-
# @see https://sevgi.roktas.dev/
|
|
30
|
-
# @see https://sevgi.roktas.dev/
|
|
28
|
+
# @see https://sevgi.roktas.dev/documents/ SVG construction and profile guide
|
|
29
|
+
# @see https://sevgi.roktas.dev/compose/ Composition guide
|
|
30
|
+
# @see https://sevgi.roktas.dev/examples/ Runnable drawing examples
|
|
31
31
|
# @see Sevgi::Graphics::Document
|
|
32
32
|
# @see Sevgi::Graphics::Canvas
|
|
33
33
|
module Graphics
|
|
@@ -63,19 +63,18 @@ module Sevgi
|
|
|
63
63
|
# Looks up a named profile when both definition keywords are omitted. Supplying `preambles:` or `attributes:`
|
|
64
64
|
# defines a named profile, or returns an existing profile when every explicitly supplied field matches. Omitted
|
|
65
65
|
# fields are ignored during existing-profile comparison. Profile containers and strings are copied into the
|
|
66
|
-
# process-global, thread-atomic registry
|
|
67
|
-
# omitted
|
|
68
|
-
# stringified once before registration. Concurrent identical definitions return the same
|
|
69
|
-
# class.
|
|
66
|
+
# process-global, thread-atomic registry. Attribute names and nested Hash keys are normalized. Nil attributes are
|
|
67
|
+
# omitted. Update suffixes remain available for document-class inheritance. Mutable non-container values are
|
|
68
|
+
# stringified once before registration. Concurrent identical definitions return the same registered class.
|
|
70
69
|
# @param name [Symbol, String] profile name
|
|
71
70
|
# @param preambles [Array<String>, nil, Sevgi::Undefined] document preamble lines
|
|
72
|
-
# @param attributes [Hash, nil, Sevgi::Undefined] default root attributes
|
|
71
|
+
# @param attributes [Hash, nil, Sevgi::Undefined] default root attributes. Nil means an empty Hash
|
|
73
72
|
# @return [Class] document class
|
|
74
73
|
# @raise [Sevgi::ArgumentError] when a profile conflicts or metadata is invalid XML, cyclic, or cannot be stringified
|
|
75
74
|
# @overload document(preambles: Undefined, attributes: Undefined)
|
|
76
75
|
# Defines an anonymous document profile without registering it globally.
|
|
77
76
|
# @param preambles [Array<String>, nil, Sevgi::Undefined] document preamble lines
|
|
78
|
-
# @param attributes [Hash, nil, Sevgi::Undefined] default root attributes
|
|
77
|
+
# @param attributes [Hash, nil, Sevgi::Undefined] default root attributes. Nil means an empty Hash
|
|
79
78
|
# @return [Class] anonymous document class
|
|
80
79
|
# @raise [Sevgi::ArgumentError] when metadata is invalid XML, cyclic, or cannot be stringified
|
|
81
80
|
# @return [Class] document class
|
|
@@ -96,19 +95,20 @@ module Sevgi
|
|
|
96
95
|
|
|
97
96
|
# Defines or replaces a document profile class.
|
|
98
97
|
# Validation and snapshot capture complete before an existing registration is atomically replaced.
|
|
99
|
-
# Use the non-bang {#document} for ordinary idempotent definitions
|
|
98
|
+
# Use the non-bang {#document} for ordinary idempotent definitions. This
|
|
100
99
|
# bang form is an explicit process-global replacement.
|
|
101
100
|
# @param name [Symbol, String] profile name
|
|
102
101
|
# @param preambles [Array<String>, nil] document preamble lines
|
|
103
|
-
# @param attributes [Hash, nil] default root attributes
|
|
102
|
+
# @param attributes [Hash, nil] default root attributes. Nil means an empty Hash
|
|
104
103
|
# @return [Class] document class
|
|
105
104
|
# @raise [Sevgi::ArgumentError] when the name or metadata is invalid XML, cyclic, or cannot be stringified
|
|
106
105
|
def document!(name, preambles: [], attributes: {})
|
|
107
106
|
Graphics::Document.define(name, preambles:, attributes:, overwrite: true)
|
|
108
107
|
end
|
|
109
108
|
|
|
110
|
-
# Defines a paper profile unless the same profile already exists.
|
|
111
|
-
#
|
|
109
|
+
# Defines a paper profile unless the same profile already exists.
|
|
110
|
+
# Registration is process-global and thread-atomic. Identical concurrent definitions are idempotent. Conflicting
|
|
111
|
+
# definitions are rejected.
|
|
112
112
|
# @param width [Numeric] paper width
|
|
113
113
|
# @param height [Numeric] paper height
|
|
114
114
|
# @param name [Symbol, String] profile name
|
|
@@ -135,15 +135,20 @@ module Sevgi
|
|
|
135
135
|
|
|
136
136
|
# Builds an SVG root element tree without rendering it.
|
|
137
137
|
#
|
|
138
|
-
# The first argument selects root metadata
|
|
139
|
-
# canvas attributes. Keyword attributes are applied
|
|
140
|
-
# @param document [Symbol, String, Class] document profile
|
|
138
|
+
# The first argument selects root metadata, or supplies the canvas while using the default profile. The second
|
|
139
|
+
# supplies canvas attributes when the first argument is a profile. Keyword attributes are applied after both.
|
|
140
|
+
# @param document [Symbol, String, Class, Sevgi::Graphics::Canvas, Sevgi::Graphics::Paper] document profile,
|
|
141
|
+
# document class, or canvas input that uses the default profile
|
|
141
142
|
# @param canvas [Sevgi::Graphics::Canvas, Sevgi::Graphics::Paper, Symbol, String, Sevgi::Undefined, nil] canvas input
|
|
142
143
|
# @yield evaluates the drawing DSL in the root element
|
|
143
144
|
# @yieldreturn [Object] ignored block result
|
|
144
145
|
# @return [Sevgi::Graphics::Document::Proto] SVG root element
|
|
145
146
|
# @raise [Sevgi::ArgumentError] when the document/canvas profile or root XML attributes are invalid
|
|
146
147
|
def SVG(document = :default, canvas = Undefined, **, &block)
|
|
148
|
+
if canvas.equal?(Undefined) && (document.is_a?(Canvas) || document.is_a?(Paper))
|
|
149
|
+
document, canvas = :default, document
|
|
150
|
+
end
|
|
151
|
+
|
|
147
152
|
Graphics::Document.(document, canvas, **, &block)
|
|
148
153
|
end
|
|
149
154
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sevgi-graphics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Recai Oktaş
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 1.0.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 1.0.0
|
|
26
26
|
description: Builds and renders SVG document trees from Ruby.
|
|
27
27
|
email: roktas@gmail.com
|
|
28
28
|
executables: []
|
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
94
|
version: '0'
|
|
95
95
|
requirements: []
|
|
96
|
-
rubygems_version: 4.0.
|
|
96
|
+
rubygems_version: 4.0.20
|
|
97
97
|
specification_version: 4
|
|
98
98
|
summary: Core SVG DSL for Sevgi.
|
|
99
99
|
test_files: []
|