Module: Sumi::Graphics
- Extended by:
- Graphics
- Included in:
- Graphics
- Defined in:
- graphics/lib/sumi/graphics.rb,
graphics/lib/sumi/graphics/element.rb,
graphics/lib/sumi/graphics/version.rb,
graphics/lib/sumi/graphics/document.rb,
graphics/lib/sumi/graphics/mixtures.rb,
graphics/lib/sumi/graphics/attribute.rb,
graphics/lib/sumi/graphics/mixtures/rdf.rb,
graphics/lib/sumi/graphics/auxiliary/xml.rb,
graphics/lib/sumi/graphics/document/base.rb,
graphics/lib/sumi/graphics/document/html.rb,
graphics/lib/sumi/graphics/mixtures/call.rb,
graphics/lib/sumi/graphics/mixtures/core.rb,
graphics/lib/sumi/graphics/mixtures/lint.rb,
graphics/lib/sumi/graphics/mixtures/save.rb,
graphics/lib/sumi/graphics/mixtures/tile.rb,
graphics/lib/sumi/graphics/mixtures/hatch.rb,
graphics/lib/sumi/graphics/auxiliary/paper.rb,
graphics/lib/sumi/graphics/mixtures/export.rb,
graphics/lib/sumi/graphics/mixtures/render.rb,
graphics/lib/sumi/graphics/auxiliary/canvas.rb,
graphics/lib/sumi/graphics/auxiliary/margin.rb,
graphics/lib/sumi/graphics/auxiliary/scalar.rb,
graphics/lib/sumi/graphics/document/default.rb,
graphics/lib/sumi/graphics/document/minimal.rb,
graphics/lib/sumi/graphics/mixtures/imprint.rb,
graphics/lib/sumi/graphics/mixtures/include.rb,
graphics/lib/sumi/graphics/mixtures/symbols.rb,
graphics/lib/sumi/graphics/auxiliary/content.rb,
graphics/lib/sumi/graphics/document/inkscape.rb,
graphics/lib/sumi/graphics/mixtures/identify.rb,
graphics/lib/sumi/graphics/mixtures/inkscape.rb,
graphics/lib/sumi/graphics/mixtures/validate.rb,
graphics/lib/sumi/graphics/mixtures/wrappers.rb,
graphics/lib/sumi/graphics/auxiliary/snapshot.rb,
graphics/lib/sumi/graphics/mixtures/duplicate.rb,
graphics/lib/sumi/graphics/mixtures/polyfills.rb,
graphics/lib/sumi/graphics/mixtures/transform.rb,
graphics/lib/sumi/graphics/mixtures/underscore.rb,
showcase/lib/sumi/showcase/passive.rb
Overview
SVG document builder and DSL namespace.
A document profile controls root metadata and preambles. A Canvas controls physical size, margins, viewport, and viewBox. #SVG combines them into an element tree. Library code keeps that tree as an object until it explicitly renders, validates, saves, or exports it.
Defined Under Namespace
Modules: Document, Mixtures, Module, Modules Classes: Attributes, Canvas, Content, Element, Margin, Paper
Constant Summary collapse
- VERSION =
Current graphics component version.
"1.0.0"- LintError =
Raised when graphics lint checks fail.
Class.new(Error)
Instance Method Summary collapse
- #canvas ⇒ Object
-
#document(name = Undefined, preambles: Undefined, attributes: Undefined) ⇒ Class
Document class.
-
#document!(name, preambles: [], attributes: {}) ⇒ Class
Defines or replaces a document profile class.
-
#paper(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines a paper profile unless the same profile already exists.
-
#paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines or replaces a paper profile.
-
#SVG(document = :default, canvas = Undefined) { ... } ⇒ Sumi::Graphics::Document::Proto
Builds an SVG root element tree without rendering it.
Instance Method Details
#canvas(paper, **overrides) ⇒ Sumi::Graphics::Canvas #canvas(width:, height:, unit: "mm", name: :custom, margins: []) ⇒ Sumi::Graphics::Canvas
52 53 54 |
# File 'graphics/lib/sumi/graphics.rb', line 52 def canvas(...) Graphics::Canvas.call(...) end |
#document(name) ⇒ Class #document(name, preambles: Undefined, attributes: Undefined) ⇒ Class #document(preambles: Undefined, attributes: Undefined) ⇒ Class
Returns document class.
91 92 93 |
# File 'graphics/lib/sumi/graphics.rb', line 91 def document(name = Undefined, preambles: Undefined, attributes: Undefined) Graphics::Document.define(name, preambles:, attributes:) end |
#document!(name, preambles: [], attributes: {}) ⇒ Class
Defines or replaces a document profile class. Validation and snapshot capture complete before an existing registration is atomically replaced. Use the non-bang #document for ordinary idempotent definitions. This bang form is an explicit process-global replacement.
104 105 106 |
# File 'graphics/lib/sumi/graphics.rb', line 104 def document!(name, preambles: [], attributes: {}) Graphics::Document.define(name, preambles:, attributes:, overwrite: true) end |
#paper(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines a paper profile unless the same profile already exists. Registration is process-global and thread-atomic. Identical concurrent definitions are idempotent. Conflicting definitions are rejected.
117 118 119 120 121 |
# File 'graphics/lib/sumi/graphics.rb', line 117 def paper(width, height, name = :custom, unit: "mm") Graphics::Paper.define(name, width:, height:, unit:, overwrite: false) name end |
#paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines or replaces a paper profile. Use this only when replacing the process-global meaning of a name is intentional.
131 132 133 |
# File 'graphics/lib/sumi/graphics.rb', line 131 def paper!(width, height, name = :custom, unit: "mm") name.tap { Graphics::Paper.define(name, width:, height:, unit:, overwrite: true) } end |
#SVG(document = :default, canvas = Undefined) { ... } ⇒ Sumi::Graphics::Document::Proto
Builds an SVG root element tree without rendering it.
The first argument selects root metadata, or supplies the canvas while using the default profile. The second supplies canvas attributes when the first argument is a profile. Keyword attributes are applied after both.
146 147 148 149 150 151 152 |
# File 'graphics/lib/sumi/graphics.rb', line 146 def SVG(document = :default, canvas = Undefined, **, &block) if canvas.equal?(Undefined) && (document.is_a?(Canvas) || document.is_a?(Paper)) document, canvas = :default, document end Graphics::Document.(document, canvas, **, &block) end |