{"id":51043539,"url":"https://github.com/qoretechnologies/module-cairo","last_synced_at":"2026-06-22T12:01:42.694Z","repository":{"id":338808524,"uuid":"1158974900","full_name":"qoretechnologies/module-cairo","owner":"qoretechnologies","description":"Qore Cairo module for vector graphics (SVG, PostScript, EPS)","archived":false,"fork":false,"pushed_at":"2026-05-07T11:33:04.000Z","size":221,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-05-07T13:32:39.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"QuakeC","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qoretechnologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-16T06:38:28.000Z","updated_at":"2026-05-07T11:33:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/qoretechnologies/module-cairo","commit_stats":null,"previous_names":["qoretechnologies/module-cairo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/qoretechnologies/module-cairo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoretechnologies%2Fmodule-cairo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoretechnologies%2Fmodule-cairo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoretechnologies%2Fmodule-cairo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoretechnologies%2Fmodule-cairo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qoretechnologies","download_url":"https://codeload.github.com/qoretechnologies/module-cairo/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qoretechnologies%2Fmodule-cairo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34647750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2026-06-22T12:01:41.577Z","updated_at":"2026-06-22T12:01:42.689Z","avatar_url":"https://github.com/qoretechnologies.png","language":"QuakeC","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Qore Cairo Module\n\n## Introduction\n\nThe `cairo` module provides Qore bindings for the\n[Cairo 2D graphics library](https://www.cairographics.org/), enabling\ncreation and manipulation of vector graphics in SVG, PostScript, and EPS\nformats, as well as PNG raster images.\n\nWith optional [librsvg](https://wiki.gnome.org/Projects/LibRsvg) support,\nthe module can also load and render existing SVG files, converting them to\nPNG, PostScript, or EPS.\n\n## Features\n\n- Create SVG, PostScript, and EPS documents from drawing commands\n- Create and manipulate PNG raster images\n- Path operations: lines, curves, arcs, rectangles\n- Text rendering with font face and size control\n- Linear and radial gradient patterns\n- Affine transformations: translate, rotate, scale, matrix\n- Multi-page PostScript output\n- Recording surfaces for deferred rendering\n- SVG input and format conversion (requires librsvg)\n- Data provider integration for Qorus workflows\n\n## Requirements\n\n- Qore 2.0+\n- CMake 3.5+\n- C++17 compiler\n- Cairo (required)\n- librsvg (optional; enables SVG input and conversion)\n\n## OS Packages\n\nUbuntu:\n\n```bash\nsudo apt-get update\nsudo apt-get install -y cmake pkg-config libcairo2-dev\n# Optional: SVG input support\nsudo apt-get install -y librsvg2-dev\n```\n\nAlpine:\n\n```bash\nsudo apk add --no-cache cmake pkgconfig cairo-dev\n# Optional: SVG input support\nsudo apk add --no-cache librsvg-dev\n```\n\nFedora:\n\n```bash\nsudo dnf install -y cmake pkgconf-pkg-config cairo-devel\n# Optional: SVG input support\nsudo dnf install -y librsvg2-devel\n```\n\nMacPorts:\n\n```bash\nsudo port install cmake pkgconfig cairo\n# Optional: SVG input support\nsudo port install librsvg\n```\n\n## Building\n\n```bash\nmkdir build\ncd build\ncmake ..\nmake\nmake install\n```\n\nTo disable librsvg SVG input support:\n\n```bash\ncmake .. -DENABLE_RSVG=OFF\n```\n\n## Quick Start\n\n### Create an SVG file\n\n```qore\n#!/usr/bin/qore\n\n%requires cairo\n\nCairoSurface svg = CairoSurface::createSvg(\"label.svg\", 400.0, 200.0);\nCairoContext ctx(svg);\n\n# Draw border\nctx.rectangle(5.0, 5.0, 390.0, 190.0);\nctx.setSourceRgb(0.0, 0.0, 0.0);\nctx.setLineWidth(2.0);\nctx.stroke();\n\n# Add title\nctx.selectFontFace(\"Helvetica\", \"normal\", \"bold\");\nctx.setFontSize(24.0);\nctx.moveTo(20.0, 40.0);\nctx.showText(\"SHIPPING LABEL\");\n\n# Add details\nctx.selectFontFace(\"Helvetica\", \"normal\", \"normal\");\nctx.setFontSize(14.0);\nctx.moveTo(20.0, 70.0);\nctx.showText(\"To: Customer Name\");\nctx.moveTo(20.0, 90.0);\nctx.showText(\"123 Main Street\");\n\nsvg.finish();\n```\n\n### Create a PNG image with gradients\n\n```qore\n#!/usr/bin/qore\n\n%requires cairo\n\nCairoSurface img = CairoSurface::createImage(300, 300);\nCairoContext ctx(img);\n\n# Background gradient\nCairoPattern grad = CairoPattern::createLinear(0.0, 0.0, 0.0, 300.0);\ngrad.addColorStopRgb(0.0, 0.2, 0.4, 0.8);\ngrad.addColorStopRgb(1.0, 0.0, 0.1, 0.3);\nctx.setSource(grad);\nctx.paint();\n\n# Draw a white circle\nctx.setSourceRgba(1.0, 1.0, 1.0, 0.9);\nctx.arc(150.0, 150.0, 100.0, 0.0, 2.0 * M_PI);\nctx.fill();\n\nimg.writeToPng(\"gradient.png\");\n```\n\n### Convert SVG to PNG (requires librsvg)\n\n```qore\n#!/usr/bin/qore\n\n%requires cairo\n\nCairoSvgReader reader(\"logo.svg\");\nfloat w = reader.getWidth();\nfloat h = reader.getHeight();\n\nCairoSurface img = CairoSurface::createImage(int(w), int(h));\nCairoContext ctx(img);\nreader.renderTo(ctx);\nimg.writeToPng(\"logo.png\");\n```\n\n### Create a PostScript document\n\n```qore\n#!/usr/bin/qore\n\n%requires cairo\n\n# US Letter: 612 x 792 points\nCairoSurface ps = CairoSurface::createPs(\"document.ps\", 612.0, 792.0);\nCairoContext ctx(ps);\n\n# Page 1\nctx.selectFontFace(\"Times\", \"normal\", \"bold\");\nctx.setFontSize(36.0);\nctx.setSourceRgb(0.0, 0.0, 0.0);\nctx.moveTo(72.0, 720.0);\nctx.showText(\"Chapter 1\");\nctx.showPage();\n\n# Page 2\nctx.selectFontFace(\"Times\", \"normal\", \"normal\");\nctx.setFontSize(12.0);\nctx.moveTo(72.0, 720.0);\nctx.showText(\"Body text on page two.\");\n\nps.finish();\n```\n\n## Data Provider\n\nThe module includes a CairoDataProvider for integration with Qore's data\nprovider framework and Qorus workflows.\n\n```qore\n%requires CairoDataProvider\n\nAbstractDataProvider dp = DataProvider::getFactoryObjectFromStringEx(\"cairo{}/image/create\");\n\nhash\u003cauto\u003e result = dp.doRequest({\n    \"width\": 200,\n    \"height\": 200,\n    \"commands\": (\n        {\"op\": \"set_source_rgb\", \"r\": 1.0, \"g\": 0.0, \"b\": 0.0},\n        {\"op\": \"arc\", \"x\": 100, \"y\": 100, \"radius\": 80, \"angle1\": 0.0, \"angle2\": 6.283},\n        {\"op\": \"fill\"},\n    ),\n    \"output_path\": \"circle.png\",\n});\n```\n\nExample `qdp` actions:\n\n```bash\n# Create SVG\nqdp 'cairo{}/svg/create' width=400,height=200,output_path=out.svg,commands='({\"op\":\"set_source_rgb\",\"r\":0,\"g\":0,\"b\":0},{\"op\":\"rectangle\",\"x\":10,\"y\":10,\"width\":380,\"height\":180},{\"op\":\"stroke\"})'\n\n# Convert SVG to PNG (requires librsvg)\nqdp 'cairo{}/svg/to-png' input_path=logo.svg,output_path=logo.png,width=256,height=256\n\n# Get SVG info (requires librsvg)\nqdp 'cairo{}/svg/get-info' input_path=logo.svg\n\n# Create PNG image\nqdp 'cairo{}/image/create' width=200,height=200,output_path=circle.png,commands='({\"op\":\"set_source_rgba\",\"r\":1,\"g\":0,\"b\":0,\"a\":1},{\"op\":\"arc\",\"x\":100,\"y\":100,\"radius\":80,\"angle1\":0,\"angle2\":6.283},{\"op\":\"fill\"})'\n\n# Get PNG image info\nqdp 'cairo{}/image/get-info' input_path=photo.png\n\n# Draw on existing PNG\nqdp 'cairo{}/image/draw' input_path=photo.png,output_path=annotated.png,commands='({\"op\":\"text\",\"text\":\"Watermark\",\"x\":10,\"y\":30,\"size\":20})'\n\n# Create PostScript\nqdp 'cairo{}/postscript/create' width=612,height=792,output_path=doc.ps,commands='({\"op\":\"text\",\"text\":\"Hello\",\"x\":72,\"y\":720,\"family\":\"Helvetica\",\"size\":24})'\n\n# Create EPS\nqdp 'cairo{}/postscript/create' width=400,height=300,eps=true,output_path=figure.eps,commands='({\"op\":\"rectangle\",\"x\":10,\"y\":10,\"width\":380,\"height\":280},{\"op\":\"stroke\"})'\n\n# Convert SVG to PostScript (requires librsvg)\nqdp 'cairo{}/svg/to-ps' input_path=diagram.svg,output_path=diagram.ps,width=612,height=792\n\n# Convert SVG to EPS (requires librsvg)\nqdp 'cairo{}/svg/to-eps' input_path=logo.svg,output_path=logo.eps,width=400,height=400\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## Copyright\n\nCopyright 2026 Qore Technologies, s.r.o.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqoretechnologies%2Fmodule-cairo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqoretechnologies%2Fmodule-cairo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqoretechnologies%2Fmodule-cairo/lists"}