{"id":26235760,"url":"https://github.com/dxtaner/computer-graphics","last_synced_at":"2026-06-23T16:31:43.047Z","repository":{"id":134096191,"uuid":"321428774","full_name":"dxtaner/Computer-Graphics","owner":"dxtaner","description":"Bresham Algorithm","archived":false,"fork":false,"pushed_at":"2025-07-17T12:31:32.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T13:47:06.772Z","etag":null,"topics":["algorithm","bresenham-algorithm"],"latest_commit_sha":null,"homepage":"","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/dxtaner.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-14T17:51:32.000Z","updated_at":"2025-07-17T12:31:36.000Z","dependencies_parsed_at":"2025-07-17T17:50:54.297Z","dependency_job_id":"1d4a4d96-fb39-455f-923e-6c4121ec65b5","html_url":"https://github.com/dxtaner/Computer-Graphics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dxtaner/Computer-Graphics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2FComputer-Graphics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2FComputer-Graphics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2FComputer-Graphics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2FComputer-Graphics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxtaner","download_url":"https://codeload.github.com/dxtaner/Computer-Graphics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2FComputer-Graphics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34698687,"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-23T02:00:07.161Z","response_time":65,"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":["algorithm","bresenham-algorithm"],"created_at":"2025-03-13T03:17:46.573Z","updated_at":"2026-06-23T16:31:43.041Z","avatar_url":"https://github.com/dxtaner.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Computer-Graphics\nBresenham's Line Generation Algorithm\n=====================================\n\nThe idea of Bresenham's algorithm is to avoid floating point multiplication and addition to compute mx + c, \nand then computing round value of (mx + c) in every step. In Bresenham's algorithm, \nwe move across the x-axis in unit intervals.\n\n\n1. We always increase x by 1, and we choose about next y, whether we need to go to y+1 or remain on y. \n2. In other words, from any position (Xk, Yk) we need to choose between (Xk + 1, Yk) and (Xk + 1, Yk + 1).\n3. We would like to pick the y value (among Yk + 1 and Yk) corresponding to a point that is closer to the original line.\n\n\nThis is an implementation of Bresenham's Line Generation Algorithm. This algorithm is used to draw a straight line between two points by using an efficient calculation method with integer values. It computes pixel coordinates and provides a faster and more efficient way of generating lines.\n\nHow It Works\n------------\n\nBresenham's line generation algorithm uses an approximate approach to find a line between two points. As it progresses from the starting point to the target point, it updates the pixel coordinates using horizontal and vertical increments (deltaX and deltaY).\n\nThe basic steps of the algorithm are as follows:\n\n1.  Take the starting point (x1, y1) and the target point (x2, y2).\n2.  Calculate the values of Δx and Δy: Δx = x2 - x1 and Δy = y2 - y1.\n3.  Determine the increment of pixel coordinates: x increment = ±1 (depending on whether Δx is positive or negative) and y increment = ±1 (depending on whether Δy is positive or negative).\n4.  Calculate the slope factor: m = Δy / Δx.\n5.  Set the coordinates of the starting point as (x, y).\n6.  Iterate based on Δx:\n    *   Update the coordinates of the next pixel as (x + x increment, y).\n    *   Calculate the error: error = error + |m|.\n    *   If error ≥ 0, update the y coordinate as well: y = y + y increment and error = error - 1.\n7.  Complete the loop, and the line generation process is finished.\n\nExample Usage with Python\n-------------\n\n    \n        # Example of drawing a line using Bresenham's line generation algorithm between (0, 0) and (5, 8) points\n    \n        from bresenham import draw_line\n    \n        x1, y1 = 0, 0\n        x2, y2 = 5, 8\n    \n        # Calculate the line\n        pixels = draw_line(x1, y1, x2, y2)\n    \n        # Print the output\n        for pixel in pixels:\n            print(pixel)\n      \n\nDevelopment\n-----------\n\nThis project provides a module that includes Bresenham's line generation algorithm. If you want to customize the algorithm further or use it in a different program, you can examine and modify the \\`bresenham.py\\` file as needed.\n\nContributing\n------------\n\nAny contributions and feedback are welcome. If you wish to improve the algorithm or fix any issues, please submit a Pull Request. For new suggestions or bug reports, you can open an Issue.\n\nLicense\n-------\n\nThis project is licensed under the MIT License. For more information, please see the \\`LICENSE\\` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxtaner%2Fcomputer-graphics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxtaner%2Fcomputer-graphics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxtaner%2Fcomputer-graphics/lists"}