CrushedPixel/Polyline2D
CrushedPixel/Polyline2D has 226 GitHub stars and 23 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-20 06:05 UTC. Last push 2024-04-05.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
소개
A header-only library to generate meshes for a solid path. Useful to render thick lines using OpenGL.
개발 도구README.md
OriginalPolyline2D
Polyline2D is a header-only C++17 library that generates a triangle mesh from a list of points.
It can be used to draw thick lines with rendering APIs like OpenGL, which do not support line drawing out of the box.
It supports common joint and end cap styles.
Example usage
#include <Polyline2D/Polyline2D.h>
using namespace crushedpixel;
std::vector<Vec2> points{
{ -0.25f, -0.5f },
{ -0.25f, 0.5f },
{ 0.25f, 0.25f },
{ 0.0f, 0.0f },
{ 0.25f, -0.25f },
{ -0.4f, -0.25f }
};
auto thickness = 0.1f;
auto vertices = Polyline2D::create(points, thickness,
Polyline2D::JointStyle::ROUND,
Polyline2D::EndCapStyle::SQUARE);
// render vertices, for example using OpenGL...
This code results in the following mesh:
For demonstration purposes, the generated mesh is once rendered in wireframe mode (light green), and once in fill mode (transparent green).
The red points show the input points.
There is no overdraw within segments, only lines that overlap are filled twice.
For an example application using this software, visit Polyline2DExample.
Installation
Manual
To use Polyline2D, simply clone this repository and include the file Polyline2D.h from the include directory.
Using CMake
To install the header files into your global header directory, you can use CMake:
mkdir build
cd build
cmake ..
make install
You can then include the header file using #include <Polyline2D/Polyline2D.h>.
Attribution and similar projects
The concepts and maths behind this project are largely inspired by this amazing blog post by "To be an Artgrammer".
Check out the original author's project vaserenderer, which also offers a C# implementation based on fragment shaders.