• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A header-only library to generate meshes for a solid path. Useful to render thick lines using OpenGL.

Polyline2D

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: Result 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".

If you're looking to generate 2d Polylines in a Unity project, check out the original author's project vaser-unity.

More Repositories

1

moshpit

A powerful cross-platform command-line tool for datamoshing.
Go
94
star
2

Plugalyzer

Command-line VST3, AU and LADSPA plugin host for easier debugging of audio plugins
C++
44
star
3

PixelCamMod

A Modification for Minecraft that allows you to create cinematic camera paths through your world.
Java
33
star
4

PacketGate

Sponge library to manipulate incoming and outgoing Packets.
Java
20
star
5

CubicSplineDemo

A simple Java program demonstrating the use of cubic spline interpolation.
Java
15
star
6

Mineskull

PHP
12
star
7

Polyline2DPathRenderer

Renders JUCE Paths very quickly using OpenGL.
C++
10
star
8

UltimateCameraStudio

Bukkit plugin to create smooth camera paths for cinematic purposes.
Java
10
star
9

Polyline2DExample

A JUCE example application for Polyline2D.
C++
9
star
10

bpmdetect

A tool to detect the tempo of a .wav file.
Java
6
star
11

skypy

A Skype Bot written in Python, allowing you to add functionality using modules.
Python
5
star
12

PanoStreamMod

A Modification for Minecraft that allows you to create 360Β° livestreams and videos.
Java
5
star
13

littlstar-java-sdk

A Java Wrapper for the Littlstar Web API. http://developer.littlstar.com
Java
4
star
14

MasqueradeAPI

Disguise API for Sponge.
Java
4
star
15

MCMapAnalytics

The source code for http://crushedpixel.eu/analytics, a web service that allows map makers to track the amount of players using their creations.
PHP
2
star
16

MasqueradeCommand

A simple Disguise plugin for Sponge.
Java
2
star
17

ember-semantic-validated-form

cp-validated form components for Ember with semantic ui.
JavaScript
2
star
18

Fourmatting

Advanced formatting library for Java.
Java
1
star
19

MasqueradePlugin

Official implementation of the MasqueradeAPI.
Java
1
star
20

jargo

WIP JSON API framework for golang
Go
1
star
21

DragonCurveDemo

Java
1
star
22

KiloheartsRemapperGenerator

Python script to generate remapper curves for Kilohearts audio plug-ins.
Python
1
star