{"id":18547666,"url":"https://github.com/vincentlaucsb/svg","last_synced_at":"2025-04-09T21:31:54.308Z","repository":{"id":41815234,"uuid":"121179706","full_name":"vincentlaucsb/svg","owner":"vincentlaucsb","description":"A simple header-only library for generating SVG files from C++","archived":false,"fork":false,"pushed_at":"2023-11-18T20:58:29.000Z","size":402,"stargazers_count":19,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T11:21:33.731Z","etag":null,"topics":["cpp","svg"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vincentlaucsb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-11T23:55:12.000Z","updated_at":"2024-08-14T14:43:37.000Z","dependencies_parsed_at":"2022-08-11T18:20:23.992Z","dependency_job_id":null,"html_url":"https://github.com/vincentlaucsb/svg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentlaucsb%2Fsvg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentlaucsb%2Fsvg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentlaucsb%2Fsvg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentlaucsb%2Fsvg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincentlaucsb","download_url":"https://codeload.github.com/vincentlaucsb/svg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248114745,"owners_count":21050102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","svg"],"created_at":"2024-11-06T20:30:34.250Z","updated_at":"2025-04-09T21:31:52.964Z","avatar_url":"https://github.com/vincentlaucsb.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVG for C++\n\n[![Build Status](https://travis-ci.org/vincentlaucsb/svg.svg?branch=master)](https://travis-ci.org/vincentlaucsb/svg) [![codecov](https://codecov.io/gh/vincentlaucsb/svg/branch/master/graph/badge.svg)](https://codecov.io/gh/vincentlaucsb/svg)\n\n## Purpose\nThis a header-only library for generating SVG files from a simple C++ interface. It can also perform non-trivial tasks such as calculating a bounding box for an SVG's elements, or merging several graphics together.\n\n[Want to see more? Read the documentation.](https://vincentlaucsb.github.io/svg/)\n\n## Basic Usage\n\n```\n#include \"svg.hpp\"\n#include \u003cfstream\u003e\n\nint main() {\n    SVG::SVG root;\n\n    // Basic CSS support\n    root.style(\"circle\").set_attr(\"fill\", \"#000000\")\n        .set_attr(\"stroke\", \"#000000\");\n    root.style(\"rect#my_rectangle\").set_attr(\"fill\", \"red\");\n\n    // Method 1 of adding elements - add_child\u003c\u003e()\n    auto shapes = root.add_child\u003cSVG::Group\u003e();\n    auto rect = shapes-\u003eadd_child\u003cSVG::Rect\u003e(\"my_rectangle\");\n\n    // Method 2 of adding elements - operator\u003c\u003c\n    *shapes \u003c\u003c SVG::Circle(-100, -100, 100) \u003c\u003c SVG::Circle(100, 100, 100);\n\n    // Reference elements by id, tag, class name, etc...\n    root.get_element_by_id(\"my_rectangle\")\n        -\u003eset_attr(\"x\", 20).set_attr(\"y\", 20)\n        .set_attr(\"width\", 40).set_attr(\"height\", 40);\n\n    std::cout \u003c\u003c \"There are \" \u003c\u003c root.get_children\u003cSVG::Circle\u003e().size() \u003c\u003c\n        \" circles.\" \u003c\u003c std::endl;\n\n    // Automatically scale width and height to fit elements\n    root.autoscale();\n\n    // Output our drawing\n    std::ofstream outfile(\"my_drawing.svg\");\n    outfile \u003c\u003c std::string(root);\n}\n```\n\n### Output\n\n```\n\u003csvg height=\"420.0\" viewBox=\"-210.0 -210.0 420.0 420.0\" width=\"420.0\" xmlns=\"http://www.w3.org/2000/svg\"\u003e\n\t\u003cstyle type=\"text/css\"\u003e\n\t\t\u003c![CDATA[\n\t\t\tcircle {\n\t\t\t\tfill: #000000;\n\t\t\t\tstroke: #000000;\n\t\t\t}\n\t\t\trect#my_rectangle {\n\t\t\t\tfill: red;\n\t\t\t}\n\t\t]]\u003e\n\t\u003c/style\u003e\n\t\u003cg\u003e\n\t\t\u003crect height=\"40\" id=\"my_rectangle\" width=\"40\" x=\"20\" y=\"20\" /\u003e\n\t\t\u003ccircle cx=\"-100.0\" cy=\"-100.0\" r=\"100.0\" /\u003e\n\t\t\u003ccircle cx=\"100.0\" cy=\"100.0\" r=\"100.0\" /\u003e\n\t\u003c/g\u003e\n\u003c/svg\u003e\n```\n\n## Simple Animations\nThis package supports creating basic animations via CSS keyframes via the frame_animate() function.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentlaucsb%2Fsvg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincentlaucsb%2Fsvg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentlaucsb%2Fsvg/lists"}