{"id":15047635,"url":"https://github.com/hugodonotexit/libgraph","last_synced_at":"2026-01-30T13:05:37.293Z","repository":{"id":241395819,"uuid":"806181497","full_name":"Hugodonotexit/libgraph","owner":"Hugodonotexit","description":"A graphing library for C++","archived":false,"fork":false,"pushed_at":"2024-09-17T04:22:20.000Z","size":335,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T17:17:05.877Z","etag":null,"topics":["cpp","cpp17","graph","lib","library","mathematical-modelling"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hugodonotexit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["Hugodonotexit"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2024-05-26T15:48:33.000Z","updated_at":"2024-07-05T06:48:44.000Z","dependencies_parsed_at":"2024-06-09T07:42:21.135Z","dependency_job_id":"f6a380ea-99d3-4611-953a-98241d795afd","html_url":"https://github.com/Hugodonotexit/libgraph","commit_stats":null,"previous_names":["hugodonotexit/libgraph"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugodonotexit%2Flibgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugodonotexit%2Flibgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugodonotexit%2Flibgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugodonotexit%2Flibgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hugodonotexit","download_url":"https://codeload.github.com/Hugodonotexit/libgraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489777,"owners_count":20298997,"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":["cpp","cpp17","graph","lib","library","mathematical-modelling"],"created_at":"2024-09-24T21:01:56.652Z","updated_at":"2026-01-30T13:05:37.227Z","avatar_url":"https://github.com/Hugodonotexit.png","language":"C++","funding_links":["https://github.com/sponsors/Hugodonotexit"],"categories":[],"sub_categories":[],"readme":"## libgraph: A Simple C++ Library for Interactive Graphing\n\n**libgraph** is a lightweight C++ library designed to simplify interactive graphing. It provides a user-friendly interface to define, evaluate, and visualize mathematical functions, as well as draw lines and points on a graphical canvas. Built upon SDL (Simple DirectMedia Layer), it offers a basic yet effective platform for visualization and exploration of mathematical concepts.\n\n**Key Features:**\n\n- **Function Parsing and Evaluation:** libgraph utilizes a `Func` class to parse and validate mathematical functions expressed as strings. It supports a range of operations, including arithmetic, trigonometric, and logarithmic functions. \n- **Interactive Graphing:** The `SDLG` class handles the graphical representation of functions and lines. It provides a customizable canvas with adjustable zoom and pan features, enabling users to explore the visualized data interactively.\n- **Basic Drawing Primitives:** The library allows users to draw lines and points on the canvas, providing additional flexibility for visual representation.\n- **Customizable Colors:** Both functions and drawing elements can be customized with different colors, improving clarity and visual appeal.\n\n**Core Classes:**\n\n- **`Func`:** Represents a mathematical function parsed from a string.\n    - `setFunc(std::string func)`: Sets the function string.\n    - `getFunc()`: Returns the function string.\n    - `get_y(double x)`: Evaluates the function for a given `x` value.\n- **`SDLG`:** Handles the graphical rendering and user interactions.\n    - `setWinSize(int width, int height)`: Sets the window size.\n    - `setWinwColour(Colour colour)`: Sets the background color.\n    - `run()`: Starts the graphical loop, handling events and rendering.\n    - `setLine(Vectorlf a, Vectorlf b, Colour colour)`: Draws a line segment.\n    - `deleteLine(int index)`: Deletes a line segment.\n    - `pushFunc(Func func, Colour colour)`: Adds a function to the graph.\n    - `removeFunc(int i)`: Removes a function from the graph.\n\n**Example Usage:**\n\n```cpp\n#include \"sdlgaphic.hpp\"\n#include \u003ciostream\u003e\n\nint main() {\n  // Create an SDLG object with default settings\n  sgt::SDLG graph;\n\n  // Define a function\n  sgt::Func function(\"sin(x) + cos(x)\");\n\n  // Add the function to the graph\n  graph.pushFunc(function);\n\n  // Set a line\n  graph.setLine(sgt::Vectorlf(0, 0), sgt::Vectorlf(10, 10), sgt::Colour::Red());\n\n  // Run the graphical loop\n  graph.run();\n\n  return 0;\n}\n```\n\n\n**Core Dependencies:**\n\n* **SDL (Simple DirectMedia Layer):** This is the primary dependency for graphical rendering. It provides the foundation for creating windows, managing events, and drawing graphics.\n* **SDL_ttf:** This library is used for rendering text on the graph. It allows you to display labels, axes, and other text elements.\n\n**Optional Dependencies:**\n\n* **OpenMP:** This library can be used for parallel processing, potentially accelerating the evaluation of functions for large datasets. However, it's not strictly required for basic functionality.\n\n**Note:** The dependencies need to be installed on your system before you can compile and run `libgraph`. The installation instructions for each dependency are provided in the \"Installation\" section of the documentation.\n\nHere's a breakdown of why each dependency is needed:\n\n* **SDL:** Provides the core functionality for creating a graphical window, handling user input (mouse and keyboard), and drawing lines, curves, and other graphical elements.\n* **SDL_ttf:** Enables the rendering of text within the graph window. This is crucial for displaying labels, axes, and other textual information.\n* **OpenMP:**  Allows for parallel execution of tasks, potentially improving performance for computationally intensive functions. However, it's not essential for the basic functionality of the library.\n\n**Installation:**\n\n1. **Install SDL:** Follow the instructions for your operating system: [https://www.libsdl.org/](https://www.libsdl.org/)\n2. **Install SDL_ttf:** Follow the instructions for your operating system: [https://www.libsdl.org/projects/SDL_ttf/](https://www.libsdl.org/projects/SDL_ttf/)\n3. **Include the `sdlgaphic.hpp` header file in your project.**\n\n**License:**\n\nMIT License\n\n**Contributions:**\n\nContributions are welcome! Please fork the repository and submit a pull request.\n\n**Contact:**\n\nFor questions or issues, please open an issue on the GitHub repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugodonotexit%2Flibgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugodonotexit%2Flibgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugodonotexit%2Flibgraph/lists"}