{"id":15527098,"url":"https://github.com/dagronf/qrcode","last_synced_at":"2025-05-15T17:05:20.742Z","repository":{"id":40340970,"uuid":"426120272","full_name":"dagronf/QRCode","owner":"dagronf","description":"A quick and beautiful macOS/iOS/tvOS/watchOS QR Code generator/detector library for SwiftUI, Swift and Objective-C.","archived":false,"fork":false,"pushed_at":"2025-01-19T19:15:54.000Z","size":17744,"stargazers_count":568,"open_issues_count":1,"forks_count":66,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-15T17:05:14.239Z","etag":null,"topics":["appkit","command-line-tool","ios","macos","objective-c","qrcode","qrcode-detector","qrcode-generator","swift","swiftui","tvos","uikit","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/dagronf.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}},"created_at":"2021-11-09T06:44:52.000Z","updated_at":"2025-05-15T09:54:03.000Z","dependencies_parsed_at":"2024-04-22T03:46:10.242Z","dependency_job_id":"684e1d6b-51c9-4231-b70c-82ac1d6abc55","html_url":"https://github.com/dagronf/QRCode","commit_stats":{"total_commits":422,"total_committers":5,"mean_commits":84.4,"dds":"0.011848341232227444","last_synced_commit":"90bf2183e2eec226840751af42a2eaebfd53330b"},"previous_names":[],"tags_count":152,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FQRCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FQRCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FQRCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FQRCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/QRCode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"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":["appkit","command-line-tool","ios","macos","objective-c","qrcode","qrcode-detector","qrcode-generator","swift","swiftui","tvos","uikit","watchos"],"created_at":"2024-10-02T11:04:26.236Z","updated_at":"2025-05-15T17:05:15.734Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","readme":"# QRCode\n\nA quick, stylish and beautiful macOS/iOS/tvOS/watchOS QR Code generator/detector library for SwiftUI, Swift and Objective-C.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/dagronf/QRCode\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-lightgrey\" /\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/pod-compatible-red\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macOS-10.13+-red\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/iOS-11+-blue\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tvOS-13+-orange\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/watchOS-6+-brightgreen\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macCatalyst-1.0+-purple\" /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.4-blueviolet\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/ObjectiveC-2.0-ff69b4\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/SwiftUI-2.0+-9cf\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"./Examples/basic/index.md\"\u003e\n      \u003cimg src=\"./Examples/basic/basic.png\" height=\"80\"/\u003e\n   \u003c/a\u003e\n   \u0026nbsp;\n   \u003ca href=\"./Examples/watchos/index.md\"\u003e\n      \u003cimg src=\"./Examples/watchos/watchos-qrcode.png\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u0026nbsp;\n   \u003ca href=\"./Examples/people/index.md\"\u003e\n      \u003cimg src=\"./Examples/people/qrcode-with-logo.png\" width=\"80\"/\u003e\n   \u003c/a\u003e   \n   \u0026nbsp;\n   \u003ca href=\"./Examples/scan/index.md\"\u003e\n      \u003cimg src=\"./Examples/scan/qrcode-with-basic-logo.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e   \n\n   \u003ca href=\"./Examples/lineargradient/index.md\"\u003e\n      \u003cimg src=\"./Examples/lineargradient/linear-background.png\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \n   \u003ca href=\"./Examples/negated/index.md\"\u003e\n      \u003cimg src=\"./Examples/negated/design-negated-quiet-space.png\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/green/index.md\"\u003e\n      \u003cimg src=\"./Examples/green/svgExportPixelBackgroundColors.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n\n   \u003ca href=\"./Examples/logo-background/logo-background.md\"\u003e\n      \u003cimg src=\"./Examples/logo-background/demo-simple-image-background.jpg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \n   \u003ca href=\"./Examples/red-b/red-b.md\"\u003e\n      \u003cimg src=\"./Examples/red-b/qrcode-off-pixels.jpg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \n   \u003ca href=\"./Examples/wombles/wombles.md\"\u003e\n      \u003cimg src=\"./Examples/wombles/demo-wombles.jpg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/wwf/index.md\"\u003e\n      \u003cimg src=\"./Examples/wwf/wwf.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/peacock/index.md\"\u003e\n      \u003cimg src=\"./Examples/peacock/beach-peacock.jpg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Art/images/3d-demo.jpg\"\u003e\n      \u003cimg src=\"./Art/images/3d-demo.jpg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/blobby/index.md\"\u003e \n      \u003cimg src=\"./Examples/blobby/blobby-style.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/wiki/index.md\"\u003e \n      \u003cimg src=\"./Examples/wiki/wiki.png\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/simple-inner-shadow/index.md\"\u003e \n      \u003cimg src=\"./Examples/simple-inner-shadow/basic-inner-shadow.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/lcd/index.md\"\u003e \n      \u003cimg src=\"./Examples/lcd/lcd.svg\" width=\"80\"/\u003e\n   \u003c/a\u003e\n   \u003ca href=\"./Examples/ugly-sweater/index.md\"\u003e \n      \u003cimg src=\"./Examples/ugly-sweater/ugly-sweater.png\" width=\"80\"/\u003e\n   \u003c/a\u003e\n\u003c/p\u003e\n\n## Why?\n\n* It's nice to have a simple drop-in component for displaying a QR code when you need it!\n* It's nice to have your app look great!\n\n## Features\n\n* Supports Swift, SwiftUI and Objective-C.\n* Supports Swift Package Manager and CocoaPods\n* Generate a QR code without access to a UI.\n* Supports all error correction levels.\n* Configurable quiet zone\n* Load/Save support\n* Drop-in live display support for SwiftUI, NSView (macOS) and UIView (iOS/tvOS).\n* Generate images, scalable PDFs, scalable SVGs and `CGPath` paths.\n* Configurable designs.\n* Add a logo to a QR code.\n* Configurable fill styles (solid, linear gradient, radial gradient) for image generation.\n* Configurable corner radius\n* Command line tool for generating qr codes from the command line (macOS 10.13+).\n* Basic qr code video detection (via importing `QRCodeDetector`).\n\n## Installing\n\n### Methods\n\n\u003cdetails\u003e\n\u003csummary\u003eSwift Package Manager\u003c/summary\u003e\nTo use in your project, add the following dependency to your Package.swift:\n\n```swift\n.package(url: \"https://github.com/dagronf/qrcode.git\", from: \"20.0.0\")\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCocoapods\u003c/summary\u003e\nTo install it, simply add the following line to your Podfile\n\n```ruby\npod 'DSF_QRCode', '~\u003e 20.0.0'\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eUsage\u003c/summary\u003e\n\nThe core functionality for generating a nice QR code is found in the `QRCode` library.\n\nIf you want to use the qr code video detection, you'll need to import the `QRCodeDetector` library.  The reason for\nseparating these out into two different libraries is because video detection **requires** your app to have a\n`NSCameraUsageDescription` defined in your including app (along with adding an `AVFoundation` dependency) if you're\nputting it on the app store - something that you may not want if your app doesn't need it!\n\n* For QR code generation, link against `QRCode`\n* For QR code video detection, link against `QRCodeDetector` \n\n### In your source\n\nSwift: `import QRCode`\n\nObjective-C: `@import QRCode;`\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAdvanced (Tuist)\u003c/summary\u003e\n\n### Using `Tuist` or similar\n\n`QRCode` supports Objective-C at its core, allowing usage in both Swift and Objective-C.\n\nWhile using `QRCode` directly in Xcode automatically supports this, it's important to make sure that you link against\nthe Objective-C library.  If not, you _WILL_ receive crashes during runtime.\n\nYou need to make sure your linker flags `OTHER_LDFLAGS` contains `-ObjC` to \n\nFor example, using [Tuist](https://tuist.io) you will need to add the following …\n\n```\nsettings: Settings(\n   base: [\n      \"OTHER_LDFLAGS\": \"-ObjC\"\n   ],\n   ...\n)\n```\n\n\u003c/details\u003e\n\n## Creating a QR Code\n\nYou create a QR Code by creating an instance of `QRCode.Document`\n\n### Using Swift\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"This is the content\")\n\n// Create a CGImage \nlet cgImage = try doc.cgImage(dimension: 400)\n// Create a PNG image\nlet pngData = try doc.pngData(dimension: 400)\n// Create a PDF (scalable content!)\nlet pdfData = try doc.pdfData(dimension: 400)\n// Create an SVG (scalable content!)\nlet svgData = try doc.svgData(dimension: 400)\n// Create a CGPath\nlet path = try doc.path(dimension: 400)\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eObjective-C\u003c/summary\u003e\n\n### Using Objective-C\n\n```objective-c\nNSError* error = NULL;\nQRCodeDocument* code = [[QRCodeDocument alloc] initWithUtf8String:@\"This is the content\"\n                                                  errorCorrection:QRCodeErrorCorrectionHigh\n                                                           engine:NULL\n                                                            error:\u0026error];\nCGImageRef cgr = [doc cgImageWithDimension:400 error:\u0026error];\n```\n\n\u003c/details\u003e\n\n|  Bitmap  |  Vector  |\n|----------|----------|\n|\u003ca href='./Art/images/basic-doco-md-coreimage.png'\u003e\u003cimg src=\"./Art/images/basic-doco-md-coreimage.png\" width=\"80\"/\u003e\u003c/a\u003e|\u003ca href='./Art/images/basic-doco-md-coreimage.pdf'\u003e\u003cimg src=\"./Art/images/basic-doco-md-coreimage.png\" width=\"80\"/\u003e\u003c/a\u003e|\n\n\n### Setting the error correction\n\n```swift\n@objc public var errorCorrection: QRCode.ErrorCorrection = .quantize\n```\n\nThe `QRCode.Document` has 4 different encoding levels\n\n| Error correction | Description                                          |\n|------------------|:-----------------------------------------------------|\n| low              | Lowest error correction (L - Recovers 7% of data)    |\n| medium           | Medium error correction (M - Recovers 15% of data)   |\n| quantize         | Quantize error correction (Q - Recovers 25% of data) |\n| high             | High error correction (H - Recovers 30% of data)     |\n\n## Generating your QR Code\n\n`QRCode.Document` has many methods and styles for generating a QR Code.\n\n### Exportable types\n\n|              |              |\n|:-------------|:-------------|\n| Bitmap types | `PNG`, `TIFF`, `JPEG` |\n| Vector types | `PDF`, `SVG` |\n| Path types   | `CGPath` | \n| Image Types  | `CGImage`, `NSImage`, `UIImage` |\n| Text types   | `json` |\n\n## Settings\n\n### Set the QR code's encoded content\n\n```swift\nlet doc = QRCode.Document(\"This is a test\")\n\n// Setting raw data\ndoc.data = Data(...)\n\n// Setting text\ndoc.utf8String = \"This is my text\"\ndoc.setText(\"This is my text\")\n\n// Setting a message\ndoc.setMessage(...)\n```\n\n\nThe higher the error correction level, the larger the QR code will be.\n\n## Design\n\n`QRCode` supports a number of ways of 'designing' your qr code.  By default, the qr code will be generated in its traditional form - square, black foreground and white background. By tweaking the design settings of the qr code you can make it a touch fancier.\n\n### WARNING\n\n\tYou can style your QR code so much that it can no longer be read by readers.\n\t\n\t\t1. Always check that your QR code can be read **at the size that it will be presented to users**. (hint: use your phone!)\n\t\t2. Have good contrast between the QR Code and its background\n\t\t3. If you use 'off' pixels (see below) make sure they are very high contrast to the 'on' pixels.\n\t\t4. Don't have high contrast between the 'on' pixels and the eye.\n\nThe design comprises two components :-\n\n|        | Description                                                               |\n|--------|:--------------------------------------------------------------------------|\n| shape  | The shape of each of the individual components within the QR code         |\n| style  | The fill styles for each of the individual components within the QR code  |\n\nYou can individually specify the shape and fill style for each of the components of the QR code.\n\n### QR code components\n\nThe QRCode is made up of four distinct components\n\n* The 'on' data pixels (`onPixels`)\n* The eye, which is made up of an `eye` (the outer part of the eye) and a `pupil` (the inner part).\n* The 'off' data pixels (`offPixels`)\n\n## Styling your QR Code\n\nOnce you have your `QRCode.Document`, there are many way you can style it to give your design more personality\n\n\n\u003cdetails\u003e\n\u003csummary\u003etl;dr Simple Example\u003c/summary\u003e\n \n```swift\nlet doc = try QRCode.Document(\"This is a test\")\n\n// Set the background color to clear\ndoc.design.backgroundColor(CGColor.clear)\n\n// Set the foreground color to blue\ndoc.design.foregroundColor(CGColor.blue)\n\n// Generate a CGPath object containing the QR code\nlet path = doc.path(CGSize(width: 400, height: 400))\n\n// Generate an image using the default styling (square, black foreground, white background) with 3x resolution\nlet image = try doc.uiImage(CGSize(width: 400, height: 400), dpi: 216)\n\n// Generate pdf data containing the qr code\nlet pdfdata = try doc.pdfData(CGSize(width: 400, height: 400))\n\n// Save a JSON representation of the qrcode document\nlet jsonData = try doc.jsonData()\n\n// Load a qr code from json\nlet loadedDoc = try QRCode.Document(jsonData: jsonData)\n```\n\n\u003c/details\u003e\n\n### QRCode builder\n\n`QRCode.Builder` is a lightweight Swift-only convenience shim for the QRCode Document.\n\n```swift\nlet image = try QRCode.build\n   .text(\"https://www.worldwildlife.org/about\")\n   .quietZonePixelCount(3)\n   .foregroundColor(CGColor(srgbRed: 1, green: 0, blue: 0.6, alpha: 1))\n   .backgroundColor(CGColor(srgbRed: 0, green: 0, blue: 0.2, alpha: 1))\n   .background.cornerRadius(3)\n   .onPixels.shape(QRCode.PixelShape.CurvePixel())\n   .eye.shape(QRCode.EyeShape.Teardrop())\n   .generate.image(dimension: 600, representation: .png())\n```\n\n\u003ca href=\"./Art/images/builder-shim.png\"\u003e\u003cimg src=\"./Art/images/builder-shim.png\" width=\"150\"/\u003e\u003c/a\u003e\n\n\n### Shape\n\nThe 'shape' represents the way that each of the components are drawn \n\n#### 'OnPixels' shape\n\nThe data shape represents how the 'pixels' within the QR code are displayed.  By default, this is a simple square, \nhowever you can supply a `PixelShape` object to custom-draw the data.  There are built-in generators for a variety of styles.\n\n\u003cimg src=\"./Art/images/data_abstract.png\" width=\"60\" title=\"Abstract\" /\u003e \u003cimg src=\"./Art/images/data_arrow.png\" width=\"60\" title=\"Arrow\" /\u003e \u003cimg src=\"./Art/images/data_blob.png\" width=\"60\" title=\"Blob\" /\u003e \u003cimg src=\"./Art/images/data_circle.png\" width=\"60\" title=\"Circle\" /\u003e \u003cimg src=\"./Art/images/data_circuit.png\" width=\"60\" title=\"Circuit\" /\u003e \u003cimg src=\"./Art/images/data_crt.png\" width=\"60\" title=\"CRT\" /\u003e \u003cimg src=\"./Art/images/data_curvePixel.png\" width=\"60\" title=\"Curve pixel\" /\u003e \u003cimg src=\"./Art/images/data_diagonal.png\" width=\"60\" title=\"Diagonal\" /\u003e \u003cimg src=\"./Art/images/data_diamond.png\" width=\"60\" title=\"Diamond\" /\u003e \u003cimg src=\"./Art/images/data_donut.png\" width=\"60\" title=\"Donut\" /\u003e \u003cimg src=\"./Art/images/data_flower.png\" width=\"60\" title=\"Flower\" /\u003e \u003cimg src=\"./Art/images/data_grid2x2.png\" width=\"60\" title=\"2x2 Square Grid\" /\u003e \u003cimg src=\"./Art/images/data_grid3x3.png\" width=\"60\" title=\"3x3 Square Grid\" /\u003e \u003cimg src=\"./Art/images/data_grid4x4.png\" width=\"60\" title=\"4x4 Square Grid\" /\u003e \u003cimg src=\"./Art/images/data_heart.png\" width=\"60\" title=\"Heart\" /\u003e \u003cimg src=\"./Art/images/data_hexagon.png\" width=\"60\" title=\"Hexagon\" /\u003e \u003cimg src=\"./Art/images/data_horizontal.png\" width=\"60\" title=\"Horizontal bars\" /\u003e \u003cimg src=\"./Art/images/data_koala.png\" width=\"60\" title=\"Koala\" /\u003e \u003cimg src=\"./Art/images/data_pointy.png\" width=\"60\" title=\"Pointy\" /\u003e \u003cimg src=\"./Art/images/data_razor.png\" width=\"60\" title=\"Razor\" /\u003e \u003cimg src=\"./Art/images/data_roundedEndIndent.png\" width=\"60\" title=\"Rounded end indent\" /\u003e \u003cimg src=\"./Art/images/data_roundedPath.png\" width=\"60\" title=\"Rounded path\" /\u003e \u003cimg src=\"./Art/images/data_roundedRect.png\" width=\"60\" title=\"Rounded rectangle\" /\u003e \u003cimg src=\"./Art/images/data_sharp.png\" width=\"60\" title=\"Sharp\" /\u003e \u003cimg src=\"./Art/images/data_shiny.png\" width=\"60\" title=\"Shiny\" /\u003e \u003cimg src=\"./Art/images/data_spikyCircle.png\" width=\"60\" title=\"Spiky Circle\" /\u003e \u003cimg src=\"./Art/images/data_square.png\" width=\"60\" title=\"Square\" /\u003e \u003cimg src=\"./Art/images/data_squircle.png\" width=\"60\" title=\"Squircle\" /\u003e \u003cimg src=\"./Art/images/data_star.png\" width=\"60\" title=\"Star\" /\u003e \u003cimg src=\"./Art/images/data_stitch.png\" width=\"60\" title=\"Stitch\" /\u003e \u003cimg src=\"./Art/images/data_vertical.png\" width=\"60\" title=\"Vertical bars\" /\u003e \u003cimg src=\"./Art/images/data_vortex.png\" width=\"60\" title=\"Vortex\" /\u003e \u003cimg src=\"./Art/images/data_wave.png\" width=\"60\" title=\"Wave\" /\u003e \u003cimg src=\"./Art/images/data_wex.png\" width=\"60\" title=\"Wex\" /\u003e \n\n[Pixel style configuration options](./Documentation/shape-configuration/pixel-styles.md)\n\n#### Eye shape\n\nYou can provide an `EyeShape` object to style just the eyes of the generated qr code. There are built-in generators for\nsquare, circle, rounded rectangle, and more.\n\n\u003cimg src=\"./Art/images/eye_barsHorizontal.png\" width=\"60\" title=\"Horizontal bars\" /\u003e \u003cimg src=\"./Art/images/eye_barsVertical.png\" width=\"60\" title=\"Vertical bars\" /\u003e \u003cimg src=\"./Art/images/eye_circle.png\" width=\"60\" title=\"Circle\" /\u003e \u003cimg src=\"./Art/images/eye_cloud.png\" width=\"60\" title=\"Cloud\" /\u003e \u003cimg src=\"./Art/images/eye_corneredPixels.png\" width=\"60\" title=\"Cornered pixels\" /\u003e \u003cimg src=\"./Art/images/eye_crt.png\" width=\"60\" title=\"CRT\" /\u003e \u003cimg src=\"./Art/images/eye_dotDragHorizontal.png\" width=\"60\" title=\"Dot Drag Horizontal\" /\u003e \u003cimg src=\"./Art/images/eye_dotDragVertical.png\" width=\"60\" title=\"Dot Drag Vertical\" /\u003e \u003cimg src=\"./Art/images/eye_edges.png\" width=\"60\" title=\"Edges\" /\u003e \u003cimg src=\"./Art/images/eye_explode.png\" width=\"60\" title=\"Explode\" /\u003e \u003cimg src=\"./Art/images/eye_eye.png\" width=\"60\" title=\"Eye\" /\u003e \u003cimg src=\"./Art/images/eye_fireball.png\" width=\"60\" title=\"Fireball\" /\u003e \u003cimg src=\"./Art/images/eye_headlight.png\" width=\"60\" title=\"Headlight\" /\u003e \u003cimg src=\"./Art/images/eye_leaf.png\" width=\"60\" title=\"Leaf\" /\u003e \u003cimg src=\"./Art/images/eye_peacock.png\" width=\"60\" title=\"Peacock\" /\u003e \u003cimg src=\"./Art/images/eye_pinch.png\" width=\"60\" title=\"Pinch\" /\u003e \u003cimg src=\"./Art/images/eye_pixels.png\" width=\"60\" title=\"Pixels\" /\u003e \u003cimg src=\"./Art/images/eye_roundedOuter.png\" width=\"60\" title=\"Rounded outer\" /\u003e \u003cimg src=\"./Art/images/eye_roundedPointingIn.png\" width=\"60\" title=\"Rounded Pointing In\" /\u003e \u003cimg src=\"./Art/images/eye_roundedPointingOut.png\" width=\"60\" title=\"Rounded pointing out\" /\u003e \u003cimg src=\"./Art/images/eye_roundedRect.png\" width=\"60\" title=\"Rounded rectangle\" /\u003e \u003cimg src=\"./Art/images/eye_shield.png\" width=\"60\" title=\"Shield\" /\u003e \u003cimg src=\"./Art/images/eye_spikyCircle.png\" width=\"60\" title=\"Spiky Circle\" /\u003e \u003cimg src=\"./Art/images/eye_square.png\" width=\"60\" title=\"Square\" /\u003e \u003cimg src=\"./Art/images/eye_squarePeg.png\" width=\"60\" title=\"Square Peg\" /\u003e \u003cimg src=\"./Art/images/eye_squircle.png\" width=\"60\" title=\"Squircle\" /\u003e \u003cimg src=\"./Art/images/eye_surroundingBars.png\" width=\"60\" title=\"Surrounding bars\" /\u003e \u003cimg src=\"./Art/images/eye_teardrop.png\" width=\"60\" title=\"Teardrop\" /\u003e \u003cimg src=\"./Art/images/eye_ufo.png\" width=\"60\" title=\"UFO\" /\u003e \u003cimg src=\"./Art/images/eye_ufoRounded.png\" width=\"60\" title=\"UFO Rounded\" /\u003e \u003cimg src=\"./Art/images/eye_usePixelShape.png\" width=\"60\" title=\"Use Pixel Shape\" /\u003e \n\n[Eye style configuration options](./Documentation/shape-configuration/eye-styles.md)\n\n#### Pupil shape\n\nYou can provide an override to the default `EyeShape` pupil shape to change just the shape of the pupil. There are built-in generators for square, circle, rounded rectangle, and more.\n\nIf you don't override the pupil shape, it defaults to the eye shape's pupil shape.\n\n\u003cimg src=\"./Art/images/pupil_barsHorizontal.png\" width=\"30\" title=\"Horizontal bars\" /\u003e \u003cimg src=\"./Art/images/pupil_barsHorizontalSquare.png\" width=\"30\" title=\"Square horizontal bars\" /\u003e \u003cimg src=\"./Art/images/pupil_barsVertical.png\" width=\"30\" title=\"Vertical bars\" /\u003e \u003cimg src=\"./Art/images/pupil_barsVerticalSquare.png\" width=\"30\" title=\"Square vertical bars\" /\u003e \u003cimg src=\"./Art/images/pupil_blade.png\" width=\"30\" title=\"Blade\" /\u003e \u003cimg src=\"./Art/images/pupil_blobby.png\" width=\"30\" title=\"Blobby\" /\u003e \u003cimg src=\"./Art/images/pupil_circle.png\" width=\"30\" title=\"Circle\" /\u003e \u003cimg src=\"./Art/images/pupil_cloud.png\" width=\"30\" title=\"Cloud\" /\u003e \u003cimg src=\"./Art/images/pupil_corneredPixels.png\" width=\"30\" title=\"Cornered pixels\" /\u003e \u003cimg src=\"./Art/images/pupil_cross.png\" width=\"30\" title=\"Cross\" /\u003e \u003cimg src=\"./Art/images/pupil_crossCurved.png\" width=\"30\" title=\"CrossCurved\" /\u003e \u003cimg src=\"./Art/images/pupil_crt.png\" width=\"30\" title=\"CRT\" /\u003e \u003cimg src=\"./Art/images/pupil_dotDragHorizontal.png\" width=\"30\" title=\"Dot Drag Horizontal\" /\u003e \u003cimg src=\"./Art/images/pupil_dotDragVertical.png\" width=\"30\" title=\"Dot Drag Vertical\" /\u003e \u003cimg src=\"./Art/images/pupil_edges.png\" width=\"30\" title=\"Edges\" /\u003e \u003cimg src=\"./Art/images/pupil_explode.png\" width=\"30\" title=\"Explode\" /\u003e \u003cimg src=\"./Art/images/pupil_forest.png\" width=\"30\" title=\"Forest\" /\u003e \u003cimg src=\"./Art/images/pupil_hexagonLeaf.png\" width=\"30\" title=\"Hexagon Leaf\" /\u003e \u003cimg src=\"./Art/images/pupil_leaf.png\" width=\"30\" title=\"Leaf\" /\u003e \u003cimg src=\"./Art/images/pupil_orbits.png\" width=\"30\" title=\"Orbits\" /\u003e \u003cimg src=\"./Art/images/pupil_pinch.png\" width=\"30\" title=\"Pinch\" /\u003e \u003cimg src=\"./Art/images/pupil_pixels.png\" width=\"30\" title=\"Pixels\" /\u003e \u003cimg src=\"./Art/images/pupil_roundedOuter.png\" width=\"30\" title=\"Rounded outer\" /\u003e \u003cimg src=\"./Art/images/pupil_roundedPointingIn.png\" width=\"30\" title=\"Rounded Pointing In\" /\u003e \u003cimg src=\"./Art/images/pupil_roundedPointingOut.png\" width=\"30\" title=\"Rounded pointing out\" /\u003e \u003cimg src=\"./Art/images/pupil_roundedRect.png\" width=\"30\" title=\"Rounded rectangle\" /\u003e \u003cimg src=\"./Art/images/pupil_seal.png\" width=\"30\" title=\"Seal\" /\u003e \u003cimg src=\"./Art/images/pupil_shield.png\" width=\"30\" title=\"Shield\" /\u003e \u003cimg src=\"./Art/images/pupil_spikyCircle.png\" width=\"30\" title=\"Spiky Circle\" /\u003e \u003cimg src=\"./Art/images/pupil_square.png\" width=\"30\" title=\"Square\" /\u003e \u003cimg src=\"./Art/images/pupil_squircle.png\" width=\"30\" title=\"Squircle\" /\u003e \u003cimg src=\"./Art/images/pupil_teardrop.png\" width=\"30\" title=\"Teardrop\" /\u003e \u003cimg src=\"./Art/images/pupil_ufo.png\" width=\"30\" title=\"UFO\" /\u003e \u003cimg src=\"./Art/images/pupil_ufoRounded.png\" width=\"30\" title=\"UFO Rounded\" /\u003e \u003cimg src=\"./Art/images/pupil_usePixelShape.png\" width=\"30\" title=\"Use Pixel Shape\" /\u003e \n\n[Pupil style configuration options](./Documentation/shape-configuration/pupil-styles.md)\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"Custom pupil\")\ndoc.design.style.background = QRCode.FillStyle.Solid(CGColor.white)\ndoc.design.shape.eye = QRCode.EyeShape.Squircle()\ndoc.design.style.eye = QRCode.FillStyle.Solid(0.149, 0.137, 0.208)\ndoc.design.shape.pupil = QRCode.PupilShape.BarsHorizontal()\ndoc.design.style.pupil = QRCode.FillStyle.Solid(0.314, 0.235, 0.322)\ndoc.design.style.onPixels = QRCode.FillStyle.Solid(0.624, 0.424, 0.400)\n```\n\n\u003cimg src=\"./Art/images/custompupil.png\" width=\"150\"/\u003e\n\n\u003c/details\u003e\n\n#### 'offPixels' shape (optional)\n\nYou can specify a shape to be drawn when a data 'pixel' is _off_. This can be used to make your qr code prettier.\nJust remember that the more embellishment you add to a QR code the more difficult it will be to read.\n\nIt's really important to make sure that there is a high color contrast between the 'offPixels' shape and the 'onPixels' shape to aid readers.\n\n\u003cimg src=\"./Art/images/dataInverted.png\" width=\"150\"/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQRCode source\u003c/summary\u003e\n\n```swift\nlet doc1 = try QRCode.Document(utf8String: \"Hi there noodle\")\ndoc1.design.backgroundColor(NSColor.white.cgColor)\ndoc1.design.shape.eye = QRCode.EyeShape.RoundedOuter()\ndoc1.design.shape.onPixels = QRCode.PixelShape.Circle()\ndoc1.design.style.onPixels = QRCode.FillStyle.Solid(NSColor.systemGreen.cgColor)\ndoc1.design.shape.offPixels = QRCode.PixelShape.Horizontal(insetFraction: 0.4, cornerRadiusFraction: 1)\ndoc1.design.style.offPixels = QRCode.FillStyle.Solid(NSColor.systemGreen.withAlphaComponent(0.4).cgColor)\n\n// Set a custom pupil shape. If this isn't set, the default pixel shape for the eye is used\ndoc1.design.shape.pupil = QRCode.PupilShape.BarsHorizontal()\n\n// Generate a image for the QRCode\nlet cgImage = try doc1.cgImage(CGSize(width: 300, height: 300))\n```\n\n\u003c/details\u003e\n\n### Style\n\n#### Fill styles\n\nYou can provide a custom fill for any of the individual components of the qr code.\n\n* The 'onPixels'\n* The eye (outer)\n* The pupil (inner)\n* The 'offPixels'\n\n\u003cimg src=\"./Art/images/eye_colorstyles.png\" width=\"150\"/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQRCode source\u003c/summary\u003e\n\n```swift\nlet doc2 = try QRCode.Document(utf8String: \"Github example for colors\")\ndoc2.design.backgroundColor(NSColor.white.cgColor)\ndoc2.design.shape.eye = QRCode.EyeShape.RoundedOuter()\ndoc2.design.shape.onPixels = QRCode.PixelShape.RoundedPath()\n\n// Eye color\ndoc2.design.style.eye = QRCode.FillStyle.Solid(NSColor.systemGreen.cgColor)\n// Pupil color\ndoc2.design.style.pupil = QRCode.FillStyle.Solid(NSColor.systemBlue.cgColor)\n// Data color\ndoc2.design.style.onPixels = QRCode.FillStyle.Solid(NSColor.systemBrown.cgColor)\n\n// Generate a image for the QRCode\nlet cgImage = try doc2.cgImage(CGSize(width: 300, height: 300))\n```\n\n\u003c/details\u003e\n\nThis library supports the current fill types.\n\n* solid fill (`QRCode.FillStyle.Solid`)\n* linear gradient (`QRCode.FillStyle.LinearGradient`)\n* radial gradient (`QRCode.FillStyle.RadialGradient`)\n* image (`QRCode.FillStyle.Image`)\n\n#### Style examples\n\nA simple QRCode with a red radial fill.\n\n\u003cimg src=\"./Art/images/fillstyles.png\" width=\"150\"/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQRCode source\u003c/summary\u003e\n\n```swift\nlet doc3 = try QRCode.Document(utf8String: \"Github example for colors\")\ndoc3.design.style.background = QRCode.FillStyle.Solid(CGColor.white)\n\n// Set the fill color for the data to radial gradient\nlet radial = QRCode.FillStyle.RadialGradient(\n   DSFGradient(pins: [\n      DSFGradient.Pin(CGColor(red: 0.8, green: 0, blue: 0, alpha: 1), 0),\n      DSFGradient.Pin(CGColor(red: 0.1, green: 0, blue: 0, alpha: 1), 1)\n   ])!,\n   centerPoint: CGPoint(x: 0.5, y: 0.5)\n)\ndoc3.design.style.onPixels = radial\n\n// Generate a image for the QRCode\nlet cgImage = try doc3.cgImage(CGSize(width: 300, height: 300))\n```\n\n\u003c/details\u003e\n\n## Adding shadows\n\nThe `QRCode.Shadow` class is used to apply shadows to a QR Code. The shadow is applied to the `style` component\nof the `QRCode.Document`\n\n### WARNING\n\nAdding heavy shadows can heavily adversely affect the ability to recognise the content of the QR code.\n\n### Usage\n\nThe shadow is applied equally to the primary components of the QRCode, namely :- \n\n* `.onPixels`\n* `.eye`\n* `.pupil` \n\nBy default, no shadows are applied.\n\n| Parameter  | Description |\n|------------|-------------|\n| `dx`       | The fraction of a `module` width to offset along the horizontal axis (1.0 == 1 module width) |\n| `dy`       | The fraction of a `module` height to offset along the vertical axis (1.0 == 1 module height) | \n| `blur`     | The blur radius of the shadow | \n| `color`    | The color of the shadow |\n\nA `module` represents a single square within the QRCode output. For example, in the image below, the dx and dy values are equal to 0.5.\n\n\u003cimg src=\"./Art/images/shadow-module-offset.png\" /\u003e\n\n### Shadow styles\n\n#### Drop shadow\n\n##### Swift\n\n```swift\nlet shadow = QRCode.Shadow(.dropShadow, dx: 0.2, dy: -0.2, blur: 3, color: CGColor.sRGBA(1, 0, 1))\ndocument.design.style.shadow = shadow\n```\n\n##### Objective-C\n\n```objc\nNSColor* color = [NSColor colorWithRed: 1.0 green: 0.0 blue: 0.0 alpha: 1.0];\nstruct CGColor* shadowColor = [color CGColor];\nQRCodeShadow* shadow = [[QRCodeShadow alloc] init:QRCodeShadowTypeDropShadow\n                                               dx: 0.2\n                                               dy: -0.2\n                                             blur: 3\n                                            color: shadowColor];\ndocument.design.style.shadow = shadow;\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eDrop shadow example\u003c/summary\u003e\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"Drop shadow sample\")\nlet shadow = QRCode.Shadow(\n   .dropShadow,\n   dx: 0.2,\n   dy: -0.2,\n   blur: 8,\n   color: CGColor.sRGBA(0, 1, 0, 1)\n)\ndoc.design.style.shadow = shadow\nlet pngData = try doc.pngData(dimension: 600, dpi: 144)\n```\n\n\u003ca href=\"./Art/images/qrcode-drop-shadow.png\"\u003e\u003cimg src=\"./Art/images/qrcode-drop-shadow.png\" width=\"150\"/\u003e\u003c/a\u003e\n\n\u003c/details\u003e\n\n#### Inner shadow\n\n```swift\nlet shadow = QRCode.Shadow(.innerShadow, dx: 0.2, dy: -0.2, blur: 3, color: CGColor.sRGBA(1, 0, 1))\ndocument.design.style.shadow = shadow\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eInner shadow example\u003c/summary\u003e\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"Inner shadow sample\")\nlet shadow = QRCode.Shadow(\n   .innerShadow,\n   dx: 0.2,\n   dy: -0.2,\n   blur: 8,\n   color: CGColor.sRGBA(0, 1, 0, 1)\n)\ndoc.design.style.shadow = shadow\nlet pngData = try doc.pngData(dimension: 600, dpi: 144)\n```\n\n\u003ca href=\"./Art/images/qrcode-inner-shadow.png\"\u003e\u003cimg src=\"./Art/images/qrcode-inner-shadow.png\" width=\"150\"/\u003e\u003c/a\u003e\n\n\u003c/details\u003e\n\n## Adding a logo to a QR code\n\nThe `QRCode.LogoTemplate` class is used to define a logo on the QR code. \nThe document has a `logoTemplate` member where this can be set (see the examples below)\n\n### WARNING\n\nAdding a logo can heavily adversely affect the ability to recognise the content of the QR code. If you add a logo it's highly recommended to set the errorCorrection levels to `.high`.\nLogos that cover more than 25% of the data tend to cause more failures than successes when reading. \n\nAfter adding an image its important to verify that the qr code can be read (Most phone cameras can read qr codes).\nIf the logo ends up covering more that 25% of the data, it is highly likely your QR code will have trouble being read by some readers.\nBefore reporting a bug about the qr code failing to be read, remove the image and retry. If the code can be read without the image it means your logo is too big.\n\n### Method 1: Logo Masking\n\nThe simplest method is to provide a logo and an optional transparent image mask. \nIf the mask is not supplied, the library will use the transparency information from the logo image to generate a mask for you.\n\nThe image and mask image should be the same size and square for the best results. Both the logo and the mask will be scaled to the final size of the QR code before application.\n\n|  logo  |  mask  |    | result |\n|:------:|:------:|:--:|:------:|\n\u003cimg src=\"./Tests/QRCodeTests/Resources/logo.png\" width=\"100\"/\u003e | \u003cimg src=\"./Tests/QRCodeTests/Resources/logo-mask.png\" width=\"100\"/\u003e | ➜ | \u003cimg src=\"./Art/images/design-logo-masking.png\" width=\"100\"/\u003e |\n\n\n\u003cdetails\u003e\n\u003csummary\u003eSample image and mask examples \u003c/summary\u003e\n\n#### Logo and mask\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"Adding a logo to a QR code using an image and a mask image\", errorCorrection: .high)\nlet logoImage = ... some logo image ...\nlet logoMaskImage = ... some mask image ...\ndoc.logoTemplate = QRCode.LogoTemplate(logoImage: logoImage, maskImage: logoMaskImage)\n```\n\n|  logo  |  mask  | result |\n|:------:|:------:|:------:|\n\u003cimg src=\"./Tests/QRCodeTests/Resources/logo.png\" width=\"150\"/\u003e | \u003cimg src=\"./Tests/QRCodeTests/Resources/logo-mask.png\" width=\"150\"/\u003e | \u003cimg src=\"./Art/images/design-logo-masking.png\" width=\"150\"/\u003e |\n\n#### Logo only\n\n```swift\nlet doc = try QRCode.Document(utf8String: \"Adding a logo to a QR code using an image's transparency\", errorCorrection: .high)\nlet logoImage = ... some logo image ...\ndoc.logoTemplate = QRCode.LogoTemplate(logoImage: logoImage)\n```\n\n|  logo  | result |\n|:------:|:------:|\n\u003cimg src=\"./Tests/QRCodeTests/Resources/logo.png\" width=\"150\"/\u003e | \u003cimg src=\"./Art/images/design-logo-masking-using-transparency.png\" width=\"150\"/\u003e |\n\n\n\u003c/details\u003e\n\n### Method 2: Logo templates\n\nThe logo template defines an image and a _relative_ path in the QRCode in which to draw the image.\n\nThe relative path represents the section in the QR code 'data' where the image is drawn. It represents a _relative_\npath (ie. x=0.0, y=0.0, width=1.0, height=1.0) within the bounds of the QR code.\n\nx=0.0, y=0.0 represents the **top left** of the qr code.\n\nFor example, if you wanted to put a circle logo in the center of your qr code where the circle is \nexactly 1/3 of the size of the QR code, then the path is defined as :-\n\n\u003ca href=\"./Art/logo-template-path-center.png\"\u003e\n  \u003cimg src=\"./Art/logo-template-path-center.png\" width=\"200\"/\u003e\n\u003c/a\u003e  \n\n```swift\nlet path = CGPath(ellipseIn: CGRect(x: 0.35, y: 0.30, width: 0.3, height: 0.3), transform: nil)\n```\n\n(note that a 1/3 mask will most likely render the qr code unreadable :-). \n\nA 1/4 size rectangular logo in the lower right of the qr code would be :- \n\n\u003ca href=\"./Art/logo-template-path-lower-right.png\"\u003e\n  \u003cimg src=\"./Art/logo-template-path-lower-right.png\" width=\"200\"/\u003e\n\u003c/a\u003e\n\n```swift\nlet path = CGPath(rect: CGRect(x: 0.75, y: 0.75, width: 0.25, height: 0.25), transform: nil)\n```\n\nThe mask path only affects the `onPixels` and `offPixels` within the QR code. Defining a logo that falls within the eye boundaries will be clipped. \n\nThere are a number of pre-built `LogoTemplate` creators for the 'standard' logo positions.\n\n* circle center (`QRCode.LogoTemplate.CircleCenter`)\n* circle bottom right (`QRCode.LogoTemplate.CircleBottomRight`)\n* square center (`QRCode.LogoTemplate.SquareCenter`)\n* square bottom right (`QRCode.LogoTemplate.SquareBottomRight`) \n\n\u003cdetails\u003e\n\u003csummary\u003eLogo Template Examples\u003c/summary\u003e\n\n### Example 1\n\n```swift\n// Define a rectangle mask within the bounds of the QR code. A centered square, 30% of the qr code size.\nlet doc = try QRCode.Document(...)\n\ndoc.logoTemplate = QRCode.LogoTemplate(\n   path: CGPath(rect: CGRect(x: 0.35, y: 0.35, width: 0.30, height: 0.30), transform: nil), \n   inset: 3,\n   image: UIImage(named: \"square-logo\")?.cgImage\n)\n\nlet qrCodeWithLogo = try doc.nsImage(dimension: 300)\n```\n\ngenerates\n\n\u003ca href=\"./Art/images/qrcode-with-logo-example.png\"\u003e\u003cimg src=\"./Art/images/qrcode-with-logo-example.png\" width=\"100\"/\u003e\u003c/a\u003e\n\n### Example 2\n\nA round logo in the lower right of the qr code\n\n```swift\nlet doc = try QRCode.Document(...)\ndoc.logoTemplate = QRCode.LogoTemplate(\n   path: CGPath(ellipseIn: CGRect(x: 0.7, y: 0.7, width: 0.30, height: 0.30), transform: nil),\n   inset: 8\n)\nlet image = NSImage(named: \"instagram-icon\")!\nlet qrCodeWithLogo = try doc.uiImage(dimension: 300, image: image)\n```\n\ngenerates\n\n\u003ca href=\"./Art/images/qrcode-with-logo-example-bottom-right.png\"\u003e\u003cimg src=\"./Art/images/qrcode-with-logo-example-bottom-right.png\" width=\"100\"/\u003e\u003c/a\u003e\n\n\u003c/details\u003e\n\n## Quiet zone\n\nYou can add a quiet zone around the outside of the QR code by setting `additionalQuietZonePixels` on the design object. This represents the number of pixels spacing are added around the outside of the actual QR Code.\n\nNote that a background color/image/fill is not affected by the quiet zone (will always extend to the boundaries of the generated image)\n\nBy default, the quiet zone is set to 0 pixels.\n\n| 0 pixels | 5 pixels | 10 pixels | 15 pixels | Background Image\u003cbr/\u003e with 6 pixels |\n|:----:|:----:|:----:|:----:|:----:|\n| \u003ca href=\"./Art/images/quiet-space-0.png\"\u003e\u003cimg src=\"./Art/images/quiet-space-0.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-5.png\"\u003e\u003cimg src=\"./Art/images/quiet-space-5.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-10.png\"\u003e\u003cimg src=\"./Art/images/quiet-space-10.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-15.png\"\u003e\u003cimg src=\"./Art/images/quiet-space-15.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-background-image.png\"\u003e\u003cimg src=\"./Art/images/quiet-space-background-image.png\" width=\"150\"/\u003e\u003c/a\u003e |\n\n```swift\nlet doc = try QRCode.Document(\"https://www.swift.org/about/\")\ndoc.design.style.background = QRCode.FillStyle.Solid(0.410, 1.000, 0.375)\ndoc.design.additionalQuietZonePixels = 4\nlet qrcodeImage = try doc.cgImage(CGSize(width: 300, height: 300))\n```\n\n## Background Corner Radius\n\nYou can specify a corner radius for your background fill on the style object, which is in fractional qr code data-pixel values.\n\nBy default, the corner radius is set to 0.\n\n| 0 pixels | 2 pixels | 4 pixels | 6 pixels |\n|:--------:|:--------:|:--------:|:--------:|\n| \u003ca href=\"./Art/images/quiet-space-0.png\"\u003e\u003cimg src=\"./Art/images/corner-radius-0.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-0.png\"\u003e\u003cimg src=\"./Art/images/corner-radius-2.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-0.png\"\u003e\u003cimg src=\"./Art/images/corner-radius-4.png\" width=\"150\"/\u003e\u003c/a\u003e | \u003ca href=\"./Art/images/quiet-space-0.png\"\u003e\u003cimg src=\"./Art/images/corner-radius-6.png\" width=\"150\"/\u003e\u003c/a\u003e |\n\n\u003cdetails\u003e\n\u003csummary\u003eBackground corner radius example\u003c/summary\u003e\n\n```swift\nlet doc = try QRCode.Document(\"Corner radius checking\")\ndoc.design.style.background = QRCode.FillStyle.Solid(1, 0, 0)\ndoc.design.foregroundStyle(QRCode.FillStyle.Solid(1, 1, 1))\ndoc.design.additionalQuietZonePixels = 2\ndoc.design.style.backgroundFractionalCornerRadius = 3.0\nlet qrcodeImage = try doc.cgImage(CGSize(width: 300, height: 300))\n```\n\n\u003ca href=\"./Art/images/corner-radius-example.png\"\u003e\u003cimg src=\"./Art/images/corner-radius-example.png\" width=\"150\"/\u003e\u003c/a\u003e\n\n\u003c/details\u003e\n\n## Message Formatters\n\nThere are a number of QRCode data formats that are somewhat common with QR code readers, such as QR codes \ncontaining phone numbers or contact details.\n\nThere are a number of built-in formatters for generating some common QR Code types. These can be found in the `messages` subfolder.\n\n* URLs (Link)\n* Generate an email (Mail)\n* A phone number (Phone)\n* Contact Details (Contact)\n* A UTF-8 formatted string (Text)\n\n## Generating output\n\n### Generate a path\n\n```swift\n@objc func path(_ size: CGSize, components: Components, design: QRCode.Design) -\u003e CGPath\n```\n\nProduces a CGPath representation of the QRCode\n\n* The size in pixels of the generated path\n* The components of the qr code to include in the path (defaults to the standard QR components)\n   * The eye 'outer' ring\n   * The eye pupil\n   * The pixels that are 'on' within the QR Code\n   * The pixels that are 'off' within the QR Code\n* The shape of the qr components\n\nThe components allow the caller to generate individual paths for the QR code components which can then be individually styled and recombined later on. \n\nThere are also extensions on `CGPath` to make it even easier to generate a `CGPath` from a qr code.\n\n```swift\nlet qrcodePath = CGPath.qrCode(\"This is a test!!!\", dimension: 800)\n```\n\n### Generating a styled image\n\n```swift\n@objc func cgImage(_ size: CGSize, dpi: CGFloat = 72.0) throws -\u003e CGImage\n```\n\nGenerate an CGImage from the QR Code, using an (optional) design object for styling the QR code\n\n```swift\n@objc func nsImage(_ size: CGSize, dpi: CGFloat = 72.0) throws -\u003e NSImage\n```\n\n*(macOS only)* Generate an NSImage from the QR Code, using an (optional) design object for styling the QR code\n\n```swift\n@objc func uiImage(_ size: CGSize, dpi: CGFloat = 72.0) throws -\u003e UIImage\n```\n\n*(iOS/tvOS/watchOS/macCatalyst only)* Generate an UIImage from the QR Code, using an (optional) design object for styling the QR code\n\n### Generate a styled, scalable PDF representation of the QR Code\n\n```swift\n@objc func pdfData(_ size: CGSize, pdfResolution: CGFloat) throws -\u003e Data\n```\n\nGenerate a scalable PDF from the QRCode using an (optional) design object for styling the QR code and resolution\n\n### Generate a SVG representation of the QR Code\n\n```swift\n@objc func svg(dimension: Int) -\u003e String\n```\n\nGenerate an SVG representation of the QR code.\n\n### Add a QR Code to the pasteboard (macOS/iOS)\n\nAdds multiple representations of the QRCode to the specified pasteboard\n\n| Platform | Added Types        |\n|:---------|:-------------------|\n| macOS    | `PDF`/`PNG`/`TIFF` | \n| iOS      | `PDF`/`PNG`        |\n\n```swift\n@objc func addToPasteboard(pasteboard: NSPasteboard = NSPasteboard.general, _ size: CGSize, dpi: CGFloat = 72.0)\n@objc func addToPasteboard(pasteboard: UIPasteboard = UIPasteboard.general, _ size: CGSize, dpi: CGFloat = 72.0)\n```\n\n### Generate a text representation of the QR Code\n\n```swift\n@objc func asciiRepresentation() -\u003e String\n```\n\nReturn an ASCII representation of the QR code using the extended ASCII code set\n\nOnly makes sense if presented using a fixed-width font.\n\t\n```swift\n@objc func smallAsciiRepresentation() -\u003e String\n```\n\nReturns an small ASCII representation of the QR code (about 1/2 the regular size) using the extended ASCII code set\n\nOnly makes sense if presented using a fixed-width font.\n\n## Presentation\n\nThis library provides drop-in components for presenting a styled QR code.\n\n### NSView/UIView\n\n#### `QRCodeDocumentView`\n\n`QRCodeDocumentView` is a view implementation to display a `QRCode.Document` object.\n\n#### `QRCodeView`\n\n`QRCodeView` is a view implementation for displaying a QR Code. This view supports :-\n\n* ~~`@IBDesignable` via Interface Builder so you can design and style your QR code completely within Interface Builder without having a `QRCode.Document` object.~~\n* (Optional) drag support for dragging a QR code out of the view.\n\n### SwiftUI\n\n#### `QRCodeViewUI`\n\nThe simplest way to add a stylish QR code to your SwiftUI app. `QRCodeViewUI` is a SwiftUI view for displaying a qrcode with just the basic styling elements.\n\n```swift\nQRCodeViewUI(\n   content: \"This is a test\",\n   foregroundColor: CGColor(srgbRed: 1, green: 0.8, blue: 0.6, alpha: 1.0),\n   backgroundColor: CGColor(srgbRed: 0.2, green: 0.2, blue: 0.8, alpha: 1.0),\n   onPixelShape: QRCode.PixelShape.RoundedPath(cornerRadiusFraction: 0.7, hasInnerCorners: true),\n   eyeShape: QRCode.EyeShape.RoundedRect()\n)\n```\n\n#### `QRCodeDocumentViewUI`\n\nIf you need more control over the styling and content of your QR code, `QRCodeDocumentViewUI` is a `SwiftUI` view that displays a `QRCode.Document` object. \n\n```swift\nvar body: some View {\n   VStack {\n      QRCodeDocumentUIView(document: doc)\n   }\n   .padding()\n}\n```\n\n\n#### `QRCodeShape`\n\n`QRCodeShape` is a `SwiftUI` Shape object generating paths from different components of a QR code. \n\nSo anything you can do with any SwiftUI shape object (eg. a rectangle) you can now do with a styled QRCode shape outline. \n\nFor example, you can use `.fill` to set the color content (eg. a linear gradient, solid color etc), add a drop shadow, add a transform etc...\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e \n\n```swift\nlet qrContent = try QRCodeShape(myData)\n...\nZStack {\n   qrContent\n      .components(.eyeOuter)\n      .fill(.green)\n   qrContent\n      .components(.eyePupil)\n      .fill(.teal)\n   qrContent\n      .components(.onPixels)\n      .fill(.black)\n}\n```\n\n\u003c/details\u003e\n\n### Modifiers\n\n```swift\nfunc errorCorrection(_ errorCorrection: QRCode.ErrorCorrection) -\u003e QRCodeShape {\n```\nSet the error correction level\n\n```swift\nfunc components(_ components: QRCode.Components) -\u003e QRCodeShape\n```\n\nSet which components of the QR code to be added to the path\n\n```swift\nfunc shape(_ shape: QRCode.Shape) -\u003e QRCodeShape\n```\n\nSet the shape (onPixels, offPixels, eye, pupil)\n\n```swift\nfunc eyeShape(_ eyeShape: QRCodeEyeShape) -\u003e QRCodeShape\n```\n\nSet the shape of the eye (eye and pupil)\n\n```swift\nfunc pupilShape(_ pupilShape: QRCodePupilShape) -\u003e QRCodeShape\n```\n\nSet the shape of the pupil\n\n```swift\nfunc onPixelShape(_ pixelShape: QRCodePixelShape) -\u003e QRCodeShape\n```\n\nSet the shape of the 'on' pixels in the QR code\n\n```swift\nfunc offPixelShape(_ pixelShape: QRCodePixelShape) -\u003e QRCodeShape\n```\n\nSet the shape of the 'off' pixels in the QR code\n\n```swift\nfunc relativeMaskPath(_ maskPath: CGPath) -\u003e QRCodeShape\n```\n\nSet the masking path\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e \n\n```swift\nstruct ContentView: View {\n\n   @State var content: String = \"This is a test of the QR code control\"\n   @State var correction: QRCodeView.ErrorCorrection = .low\n\n   var body: some View {\n      Text(\"Here is my QR code\")\n      QRCodeShape(\n         text: content,\n         errorCorrection: correction\n      )\n      .fill(LinearGradient(gradient: gradient, startPoint: .topLeading, endPoint: .bottomTrailing))\n      .shadow(color: .black, radius: 1, x: 1, y: 1)\n      .frame(width: 250, height: 250, alignment: .center)\n   }\n}\n```\n\u003c/details\u003e\n\n## Objective-C\n\nThe `QRCode` library fully supports Objective-C.\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e \n\n### Using QRCode.Document\n\n```objc\nQRCodeDocument* doc = [QRCodeDocument new];\ndoc.utf8String = @\"This is an objective-c qr code\";\ndoc.design.shape.onPixels = [QRCodePixelShapeRazor new];\n\nNSError* error = NULL;\nCGImageRef image = [doc cgImageWithDimension:600 error:\u0026error];\nassert(error == nil);\n```\n\n### Using QRCode directly\n\n```objc\nQRCode* code = [[QRCode alloc] init];\n[code updateWithText:@\"This message\"\n     errorCorrection:QRCodeErrorCorrectionHigh\n               error:nil];\n\n// Create a new design\nQRCodeDesign* design = [QRCodeDesign new];\n\n// Set the foreground color to a solid red\ndesign.style.onPixels = [[QRCodeFillStyleSolid alloc] init: CGColorCreateGenericRGB(1, 0, 0, 1)];\n\n// Use the leaf style\ndesign.shape.eye = [[QRCodeEyeShapeLeaf alloc] init];\n\n// Generate the image\nCGImageRef image = [code cgImage:CGSizeMake(400, 400)\n                          design:design\n                    logoTemplate:nil\n                           error:nil];\n```\n\u003c/details\u003e\n\n## Load/Save\n\nThe `QRCode.Document` class has methods for loading/saving QRCode definitions to a JSON format\n\n```swift\nlet qrCode = try QRCode.Document()\nqrCode.data = \"this is a test\".data(using: .utf8)!\nqrCode.design.shape.onPixels = QRCode.PixelShape.Circle()\nqrCode.design.shape.eye = QRCode.EyeShape.Leaf()\n\nlet jsonData = try qrCode.jsonData()\n\n...\n\nlet loadedQRCode = try QRCode.Document.Create(jsonData: jsonData)\n```\n\n## Detecting QR Codes\n\n### From an image\n\nThe library provides a mechanism for detecting QR codes in an image\n\n```swift\n// CGImage/NSImage/UIImage detection\nif let detected = QRCode.DetectQRCodes(in: /*some image*/),\n   detected.count \u003e 0 {\n   // Do something with the detected qr codes\n   let qrCodeBounds = detected[0].bounds\n   let qrCodeMessage = detected[0].messageString\n   ...\n}\n```\n\nEven easier, there is an extension on `CGImage` to detect the strings encoded within the image if you only want the string content for each match.\n\n```swift\nlet image = CGImage(...)\nlet messages = image.detectQRCodeStrings()\n```\n\n### From a video stream\n\nIn order to allow `QRCode` to be used in App Store or Test Flight targets without having to allow Camera usage,\nthe video detector component has been extracted out into its own target, `QRCodeDetector`.\n\nThere is a video detector class `QRCodeDetector.VideoDetector` which is a very basic qr code detector for video streams.\n\nThere are two basic demos demonstrating the qr code detection in a video stream.\n\n* `macOS QRCode Detector`: Video qr code detector for macOS targets\n* `iOS QRCode Detector`: Video qr code detector for iOS targets (requires a real device)\n\n## Demo\n\nThere are a number of demo apps which you can find in the `Demo` subfolder.  There are simple demo applications for\n\n* SwiftUI (macOS, iOS, macCatalyst, watchOS)\n* iOS (Swift, including macCatalyst)\n* macOS (Swift and Objective-C)\n\n## Command line tool\n\nYou can build the command line tool by opening a terminal window, `cd` into the QRCode folder and build using\n\n`swift build -c release --product qrcodegen`\n\nThe `qrcodegen` tool can be found in the `.build/release` folder.\n\n```zsh\n% .build/release/qrcodegen --help\nOVERVIEW: Create a qr code\n\nExamples:\n   qrcodegen -t \"This is a QR code\" --output-file \"fish.png\" 512\n   qrcodegen -t \"QRCode on the clipboard\" --output-format clipboard 1024\n   qrcodegen --style-template-file qrtemplate.json -t \"QRCode on the clipboard\" --output-format clipboard 1024\n\n* If you don't specify either -t or --input-file, the qrcode content will be read from STDIN\n* If you don't specify an output file, the generated qr code will be written to a temporary file\n  and opened in the default application.\n* You can generate a style template file by exporting to json format.\n\nUSAGE: qr-code-gen [\u003coptions\u003e] \u003cdimension\u003e\n\nARGUMENTS:\n  \u003cdimension\u003e             The QR code dimension. \n\nOPTIONS:\n  --input-file \u003cinput-file\u003e\n                          The file containing the content for the QR code \n  --output-file \u003coutput-file\u003e\n                          The output file \n  --output-format \u003coutput-format\u003e\n                          The output format (png [default],pdf,svg,ascii,smallascii,clipboard,json) \n  --output-compression \u003coutput-compression\u003e\n                          The output format compression factor (if the output format supports it, png,jpg) \n  --style-template-file \u003cstyle-template-file\u003e\n                          The QR code file to use as a style template \n  --logo-image-file \u003clogo-image-file\u003e\n                          The image file to use as a logo if the style template file defines a logo template \n  -t, --text \u003ctext\u003e       The text to be stored in the QR code \n  -s, --silence           Silence any output \n  -c, --error-correction \u003cerror-correction\u003e\n                          The level of error correction. Available levels are \"L\" (low), \"M\" (medium), \"Q\" (quantize), \"H\" (high) \n  --all-pixel-shapes \u003call-pixel-shapes\u003e\n                          Print all the available pixel shapes. \n  -d, --on-pixel-shape \u003con-pixel-shape\u003e\n                          The onPixels shape to use. Available shapes are grid2x2, grid3x3, grid4x4, abstract, arrow, blob, crt, circle,\n                          circuit, curvePixel, donut, flower, heart, horizontal, pointy, razor, roundedEndIndent, roundedPath, roundedRect,\n                          sharp, shiny, spikyCircle, square, squircle, star, vertical, vortex, wave. \n  -n, --on-pixel-inset-fraction \u003con-pixel-inset-fraction\u003e\n                          The spacing around each individual pixel in the onPixels section \n  -r, --on-pixel-shape-corner-radius \u003con-pixel-shape-corner-radius\u003e\n                          The onPixels shape corner radius fractional value (0.0 -\u003e 1.0) \n  -a, --on-pixel-shape-has-inner-corners \u003con-pixel-shape-has-inner-corners\u003e\n                          The onPixels 'has inner corners' value (true/false) \n  --all-eye-shapes \u003call-eye-shapes\u003e\n                          Print all the available eye shapes. \n  -e, --eye-shape \u003ceye-shape\u003e\n                          The eye shape to use. Available shapes are crt, circle, corneredPixels, dotDragHorizontal, dotDragVertical, edges,\n                          explode, eye, fireball, headlight, barsHorizontal, leaf, peacock, pinch, pixels, roundedPointingIn, roundedOuter,\n                          roundedRect, shield, spikyCircle, square, squarePeg, squircle, surroundingBars, teardrop, ufo, usePixelShape,\n                          barsVertical. \n  --eye-shape-corner-radius \u003ceye-shape-corner-radius\u003e\n                          The fractional (0 ... 1) corner radius to use for the eye shape IF the eye shape supports it. \n  --all-pupil-shapes \u003call-pupil-shapes\u003e\n                          Print all the available pupil shapes. \n  -p, --pupil-shape \u003cpupil-shape\u003e\n                          The pupil shape to use. Available shapes are blade, blobby, crt, circle, corneredPixels, cross, crossCurved,\n                          dotDragHorizontal, dotDragVertical, edges, explode, forest, hexagonLeaf, barsHorizontal, leaf, orbits, pinch, pixels,\n                          roundedPointingIn, roundedOuter, roundedRect, seal, shield, spikyCircle, square, barsHorizontalSquare,\n                          barsVerticalSquare, squircle, teardrop, ufo, usePixelShape, barsVertical. \n  --pupil-shape-corner-radius \u003cpupil-shape-corner-radius\u003e\n                          The fractional (0 ... 1) corner radius to apply to the pupil shape IF the pupil shape supports it. \n  --bg-color \u003cbg-color\u003e   The background color to use (format r,g,b,a - 1.0,0.5,0.5,1.0) \n  --data-color \u003cdata-color\u003e\n                          The onPixels color to use (format r,g,b,a - 1.0,0.5,0.5,1.0) \n  --eye-color \u003ceye-color\u003e The eye color to use (format r,g,b,a - 1.0,0.5,0.5,1.0) \n  --pupil-color \u003cpupil-color\u003e\n                          The pupil color to use (format r,g,b,a - 1.0,0.5,0.5,1.0) \n  -h, --help              Show help information.\n```\n\n### Example\n\n```sh\n# Generate a qr code 800x800, png format, using roundedPath for the data, leaf for the eye and a transparent background\n.build/release/qrcodegen -c H -d roundedPath -e leaf --bg-color 1.0,1.0,1.0,0.0 -t \"qrcode generated by command line\" --output-file \"output.png\" 800\n```\n\n## Thanks\n\n### Denso Wave\n\n[Denso Wave](https://www.qrcode.com/en/) \n\nQR Code is a registered trademark of DENSO WAVE.\n\n### swift-qrcode-generator\n\nSince watchOS doesn't support Core Image filters, I defer to using an (optional) 3rd party for generating QR Codes for watchOS. It is based on [Nayuki's QR Code generator](https://github.com/nayuki/QR-Code-generator) code.\n\n[swift-qrcode-generator](https://github.com/dagronf/swift-qrcode-generator)\n\n## License\n\n[QRCode](https://github.com/dagronf/QRCode)\n\n```\nMIT License\n\nCopyright (c) 2025 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n[swift-qrcode-generator](https://github.com/fwcd/swift-qrcode-generator)\n\n```\nMIT License\n\nCopyright (c) Project Nayuki. (MIT License)\nCopyright (c) 2020 fwcd\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fqrcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fqrcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fqrcode/lists"}