{"id":37766472,"url":"https://github.com/blep/pyray_examples","last_synced_at":"2026-01-16T14:43:38.829Z","repository":{"id":293648018,"uuid":"983932695","full_name":"blep/pyray_examples","owner":"blep","description":"Examples for pyray, using pyray bindings for raylib","archived":false,"fork":false,"pushed_at":"2025-07-30T23:08:21.000Z","size":35112,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-31T00:55:43.519Z","etag":null,"topics":["examples","raylib","raylib-python"],"latest_commit_sha":null,"homepage":"","language":"C","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/blep.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":"2025-05-15T06:22:40.000Z","updated_at":"2025-07-30T23:08:24.000Z","dependencies_parsed_at":"2025-07-31T00:25:05.624Z","dependency_job_id":null,"html_url":"https://github.com/blep/pyray_examples","commit_stats":null,"previous_names":["blep/pyray_examples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blep/pyray_examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blep%2Fpyray_examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blep%2Fpyray_examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blep%2Fpyray_examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blep%2Fpyray_examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blep","download_url":"https://codeload.github.com/blep/pyray_examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blep%2Fpyray_examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["examples","raylib","raylib-python"],"created_at":"2026-01-16T14:43:37.095Z","updated_at":"2026-01-16T14:43:38.822Z","avatar_url":"https://github.com/blep.png","language":"C","readme":"# 100+ python examples for pyray, the python bindings of raylib\n\nThis repo contains example programs for [pyray](https://github.com/electronstudio/raylib-python-cffi), the Python \nbindings for the [raylib](https://github.com/raysan5/raylib) library. All examples have been migrated from the \nofficial raylib C examples.\n\nOriginal C examples:\n- [raylib](https://github.com/raysan5/raylib/tree/master/examples)\n- [raylib GUI](https://github.com/raysan5/raygui/tree/master/examples)\n\n\u003e **Note:**  \n\u003e A ticket was opened to request integration of these examples with pyray:  \n\u003e https://github.com/electronstudio/raylib-python-cffi/issues/173\n\n## Running the examples\n\nCreate a virtual environment (for Windows, activation differs on each platform):\n```bash\npython -m venv venv\nvenv\\Scripts\\activate\n```\n\nInstall the pyray package:\n```bash\npip install -r requirements.txt\n```\n\nRun the desired example:\n```bash\npython raylib_official_examples/textures/textures_background_scrolling.py\n```\n\n## Using those examples\n\n*WARNING*: most of the code is the result of an automatic migration from C to Python using non-deterministic tools, \nso it may contain bugs, may not be idiomatic Python, contains odd comments... \n\n*Not all the code was reviewed.* (I just don't have the time for that) \n\n## Example licenses\n\nThe license of the original C examples [has been preserved](raylib_official_examples/copyright_comment.py).\n(See the module-level docstring in each.) As far as I know, they all follow the zlib/libpng license.\n\n## Examples status\n\nNote that not all examples work: 140/173 (~81%) examples work without issues.\n\nSee [migration_issues](raylib_official_examples/migration_issues.md) for the list of examples with known issues, \nand a brief description of the issue. Note that some examples run, but some actions cause crashes. The action is \ndescribed next to the example path.\n\nSee [pyray API oddities](raylib_official_examples/pyray_api_oddities.md) for some quick notes on API that seem\nclumsy to use.\n\nMany examples share common failures, such as failure to create a Texture2D().\n\nThe script [list_working_examples.py](raylib_official_examples/list_working_examples.py) can be used to update:\n- [list of examples that work without known issues](raylib_official_examples/examples_list_working.txt)\n- [list of examples that have known issues](raylib_official_examples/examples_list_with_issues.txt)\n\n## How this migration from C to Python was done\n\nThis is a heavily tool-assisted migration of those 120+ examples, in about 1.5 calendar days.\n\nTools used (as of 2025-05-14):\n- Visual Studio Code (1.100.1), with GitHub Copilot\n  - Agent mode\n  - Model: mostly \"Claude 3.7 Sonnet\", but initially used \"Gemini 2.5 Pro (Preview)\". \n    Unfortunately, Gemini started returning constant \"500 Server Error\", so I switched to Claude which felt much \n    slower, but gave good results with some rare Python syntax/indent issues...\n\nThe original C examples were copied into the repo directory: the Copilot Agent is only allowed to access files within \nthe project directory. This is the great advantage of using the agent mode: you don't need to add files to the context,\njust provide some reference to them.\n\nYou can find a rough [log of the prompts here](prompts/migrate_to_py.md), though midway I started just updating the \nlast one as it was growing too big, and it seems to accept new guidelines without issues.\n\n## Main migration prompt\n\nMigration prompts started with the first paragraph, and grew as I found recurrent issues.\nRecommendations:\n- Create the target directory beforehand if you don't want to waste 1 min for \"I need to create the directory\".\n- Don't trust it when it says it migrated everything. Compare the original number of .c and .py files. It's common\n  to require 3+ iterations for a directory (but this also gives you the opportunity to adjust the prompt with newly\n  discovered issues).\n- In practice, I was testing/tracking down issues on the previous conversion batch while the tool worked on the next\n  batch. To track a given source had been tested, I added it to git (which shows up in a different color in PyCharm).\n- For some languages, it may be necessary to provide complete examples of \"good\" quality code. Add these source files \n  to the context and explain in the prompt how they should be used as a reference.  \n\n*Prompt:*\n```text\nLet's migrate all examples from raylib_c_examples/textures to raylib_official_examples/textures. Existing files may have already been migrated.\nUse \"import pyray as rl\" to import raylib.\n\nComments must be written in English.\n\nDon't forget that:\n- The correct way to call rlgl_* functions in Python is, for example: \"rl.rl_push_matrix()\".\n- It is rl.rl_color4ub(), not rl.rl_color_4ub()\n- It is rl.rl_normal3f(), not rl.rl_normal_3f()\n- It is rl.draw_texture_n_patch, not rl.draw_texture_npatch()\n- It is \"rl.update_camera(camera, rl.CAMERA_FREE)\", not \"rl.update_camera(rl.byref(camera), rl.CAMERA_FREE)\", rl.byref() doesn't exist\n- It is rl.rl_scalef(), not rl.rl_scale_f()\n- It is rl.rl_rotatef(), not rl.rl_rotate_f()\n- It is rl.rl_translatef(), not rl.rl_translate_f()\n- It is rl.ffi.new(), not rl.pyray.ffi.new()\n- It is rl.gui_get_state(), not rl.get_gui_state()\n\n# Converting file loading\nWhen you see code loading files such as: \nmusic = rl.load_music_stream(\"raylib_c_examples/audio/resources/country.mp3\") # BAD \n\nConvert them using the following approach: THIS_DIR global constant (just after the import) with directory of the script, \nand then make the path relative to it:\n\nfrom pathlib import Path\nTHIS_DIR = Path(__file__).resolve().parent\n#...\nmusic = rl.load_music_stream(str(THIS_DIR/\"raylib_c_examples/audio/resources/country.mp3\")) # GOOD\n\n# Loading shader\nYou should never pass None as the first parameter to rl.load_shader. The correct way to load a shader is:\nshdr_outline = rl.load_shader(\"\", str(THIS_DIR/f\"resources/shaders/glsl{GLSL_VERSION}/outline.fs\"))\n\n# Pointer handling in rl.gui_*() functions\n\nIn the calls to rl.gui_slider_bar(), the 4th parameter must be a pointer to float created \nwith: \"pyray.ffi.new('float *', 1.0)\" for example. The float pointer value is accessed \nwith pointer[0].\n\nVariables initialized with pyray.ffi.new() must be suffixed with _ptr.  \n\nExample of bad code:\n    start_angle = 0.0\n    print( f\"Angle is {start_angle}\" )\n    start_angle = rl.gui_slider_bar(rl.Rectangle(600, 40, 120, 20), \"StartAngle\", f\"{start_angle:.2f}\", start_angle, 0, 720)\n\nExample of correct code:\n    start_angle_ptr = pyray.ffi.new('float *', 0.0)\n    print( f\"Angle is {start_angle_ptr[0]}\" )\n    rl.gui_slider_bar(rl.Rectangle(600, 40, 120, 20), \"StartAngle\", f\"{start_angle:.2f}\", start_angle_ptr, 0, 720)\n\nSimilar care is required for rl.gui_check_box(), but concerning the last parameter.\nSimilar care is required for rl.gui_spinner(), rl.gui_combo_box(), rl.gui_list_view(), rl.gui_list_view() \nand rl.gui_value_box(), but for the 3rd parameter.\nSimilar care is required for rl.gui_list_view_ex(), but concerning the last 3 parameters.\n\nIncorrect: font.base_size, font_sdf.glyph_count\nCorrect: font.baseSize, font_sdf.glyphCount\n```\n\n## Review and fix prompt\n\nBelow is an example of prompts used to fix non-trivial issues discovered after migration was done.\n\n*Prompt:*\n```text\nReview all the shapes/ migration to Python. The calls to rl.gui_slider_bar(), which have been incorrectly migrated \nfrom C to Python, and adjust the code so that it is correct. \nThe 4th parameter must be a pointer to float created with: \"pyray.ffi.new('float *', 1.0)\" for example. The float \npointer value is accessed with pointer[0].\n\nExample of bad code:\n    start_angle = 0.0\n    print( f\"Angle is {start_angle}\" )\n    start_angle = rl.gui_slider_bar(rl.Rectangle(600, 40, 120, 20), \"StartAngle\", f\"{start_angle:.2f}\", start_angle, 0, 720)\n\nExample of correct code:\n    start_angle_ptr = rl.ffi.new('float *', 0.0)\n    print( f\"Angle is {start_angle_ptr[0]}\" )\n    rl.gui_slider_bar(rl.Rectangle(600, 40, 120, 20), \"StartAngle\", f\"{start_angle_ptr[0]:.2f}\", start_angle_ptr, 0, 720)\n\nThere is also an identical issue for rl.gui_check_box(), but concerning the last parameter. Correct it too. \n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblep%2Fpyray_examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblep%2Fpyray_examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblep%2Fpyray_examples/lists"}