{"id":13667195,"url":"https://github.com/3Qax/SwiftyGFX","last_synced_at":"2025-04-26T15:32:19.208Z","repository":{"id":63901407,"uuid":"193221370","full_name":"3Qax/SwiftyGFX","owner":"3Qax","description":"A Swift graphics library useful when working with dot matrix displays.","archived":false,"fork":false,"pushed_at":"2020-01-05T13:26:34.000Z","size":89,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T14:03:02.856Z","etag":null,"topics":["graphics-library","iot","swift"],"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/3Qax.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}},"created_at":"2019-06-22T10:30:05.000Z","updated_at":"2024-08-27T04:03:52.000Z","dependencies_parsed_at":"2023-01-14T12:45:24.448Z","dependency_job_id":null,"html_url":"https://github.com/3Qax/SwiftyGFX","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Qax%2FSwiftyGFX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Qax%2FSwiftyGFX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Qax%2FSwiftyGFX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3Qax%2FSwiftyGFX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3Qax","download_url":"https://codeload.github.com/3Qax/SwiftyGFX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251008776,"owners_count":21522176,"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":["graphics-library","iot","swift"],"created_at":"2024-08-02T07:00:33.284Z","updated_at":"2025-04-26T15:32:18.954Z","avatar_url":"https://github.com/3Qax.png","language":"Swift","funding_links":[],"categories":["Graphics"],"sub_categories":["Networking, IoT, Bus Protocols, …"],"readme":"# SwiftyGFX\n\nA swift graphics library intended for my [SwiftyOLED](https://github.com/3Qax/SwiftyOLED) library. Feel free to design API for it when creating display libraries using swift on arm.\n\n## Documentation\n\n### Coordinate system\n\nThis library uses iOS like coordinate system. The X axis is increasing to the right. The Y axis is increasing downwards.\n\n### Primitives\n\nEach of defined primitives conforms to _Drawable_ protocool. The library defines following groups of primitives:\n\n#### Lines\n\nThe Bresenham's was used for drawing oblique lines. Even though you can draw horizontal and vertical lines with `ObliqueLine` class it is way faster to used either `HorizontalLine` or `VerticalLine` class.\n\n```swift\n    ObliqueLine(from origin: Point, to endPoint: Point)\n    HorizontalLine(from origin: Point, to endPoint: Point)\n    HorizontalLine(from origin: Point, lenght: UInt)\n    VerticalLine(from origin: Point, to endPoint: Point)\n    VerticalLine(from origin: Point, lenght: UInt)\n```\n\nIf you pass incorret values to `HorizontalLine` or `VerticalLine`, that is points with diffrent y coordinates or x coordinates accordingly, library will back up to using y or x of origin.\n\n#### Rectangles\n\n```swift\n    Rectangle(at origin: Point = Point(x: 0, y: 0), height: UInt, width: UInt)\n    Square(at origin: Point = Point(x: 0, y: 0), sideSize a: UInt)\n```\n\n#### Ellipses\n\n```swift\n    Ellipse(at origin: Point = Point(x: 0, y: 0), yRadius: UInt, xRadius: UInt)\n    Ellipse(at origin: Point = Point(x: 0, y: 0), height: UInt, width: UInt)\n    Circle(at origin: Point = Point(x: 0, y: 0), radius: UInt)\n    Circle(at origin: Point = Point(x: 0, y: 0), width: UInt)\n```\n\n#### Triangles\n\n```swift\n    Triangle(at origin: Point = Point(x: 0, y: 0), corner1: Point, corner2: Point, corner3: Point)\n```\n\n#### Text\n\nIf you do not specify the _pathToFont_ parameter the library will try to use _DejaVuSans_ font which is embeded into Raspbian. If that fails the library will try to get list of all installed fonts from `fontconfig` package and use the first one. If that fails library will raise fatalError.\n\n```swift\n    Text(_ text: String, font pathToFont: String? = nil, at origin: Point = Point(x: 0, y: 0), pixelHeight: UInt32 = 16, pixelWidth: UInt32 = 16)\n\n```\n\nYou can change text size by using one of two methods:\n\n```swift\n    public func setPixel(height: UInt32, width: UInt32)\n    public func setChar(height: Int, width: Int, horizontalResolution: UInt32, verticalResolution: UInt32)\n````\n\nThese two are just wrappers around `FT_Set_Pixel_Sizes` and `FT_Set_Char_Size` from FreeType 2 library. For more info go to it's documentation.\n\n### Filling\n\nThe `Rectangle`, `Square`, `Ellipse`, `Circle`, `Triangle` types can be filled. This functionality is provided by `.fill()` and `.filled()` methods. Only diffrence is that `.filled()` returns a filled copy of object it's been called on.\n\n### Rendering\n\nThe _Drawable_ protocool guarantes that for each object you can generate array of tuplets of integer and integer by calling `.generatePointsForDrawing()`. This effectively is array of points (each having X and Y coordinate). They can be passed to the display library of your choice and therefore be displayed. \n\n## Contributing\n\nFeel free to sugest changes, report bugs and issues, create pull requests.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3Qax%2FSwiftyGFX","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3Qax%2FSwiftyGFX","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3Qax%2FSwiftyGFX/lists"}