All Projects → miloyip → Line

miloyip / Line

2D Line Drawing Samples in C

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Line

Light2d
Light rendering in 2D
Stars: ✭ 673 (+354.73%)
Mutual labels:  graphics-programming
Nova Rs
Nova Renderer, but in Rust
Stars: ✭ 98 (-33.78%)
Mutual labels:  graphics-programming
Herebedragons
A basic 3D scene implemented with various engines, frameworks or APIs.
Stars: ✭ 1,616 (+991.89%)
Mutual labels:  graphics-programming
Awesome Creative Coding
Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.
Stars: ✭ 8,696 (+5775.68%)
Mutual labels:  graphics-programming
Godot Particle Dof
Bokeh-esque particle depth of field in Godot 3.0
Stars: ✭ 77 (-47.97%)
Mutual labels:  graphics-programming
Vulkan Samples
One stop solution for all Vulkan samples
Stars: ✭ 2,009 (+1257.43%)
Mutual labels:  graphics-programming
Dungeontemplatelibrary
🌏: Dungeon free resources (terrain & roguelike generation)
Stars: ✭ 595 (+302.03%)
Mutual labels:  graphics-programming
Diligentengine
A modern cross-platform low-level graphics library and rendering framework
Stars: ✭ 2,142 (+1347.3%)
Mutual labels:  graphics-programming
Flycube
Graphics API wrapper is written in C++ on top of Directx 12 and Vulkan. Provides main features including ray tracing.
Stars: ✭ 78 (-47.3%)
Mutual labels:  graphics-programming
Godot Motion Blur
A motion blur shader for Godot 3.0
Stars: ✭ 115 (-22.3%)
Mutual labels:  graphics-programming
X Postprocessing Library
Unity Post Processing Stack Library | Unity引擎的高品质后处理库
Stars: ✭ 1,079 (+629.05%)
Mutual labels:  graphics-programming
Real Time Rendering 3rd Cn Summary Ebook
📘 电子书 -《Real-Time Rendering 3rd》提炼总结 | 全书共9万7千余字。你可以把它看做中文通俗版的《Real-Time Rendering 3rd》,也可以把它看做《Real-Time Rendering 3rd》的解读版与配套学习伴侣,或者《Real-Time Rendering 4th》的前置阅读材料。
Stars: ✭ 1,159 (+683.11%)
Mutual labels:  graphics-programming
Xrtl
Cross-platform Real-Time Rendering Library
Stars: ✭ 108 (-27.03%)
Mutual labels:  graphics-programming
Vk9
Direct3D 9 compatibility layer using Vulkan.
Stars: ✭ 799 (+439.86%)
Mutual labels:  graphics-programming
Vulkantutorial
Tutorial for the Vulkan graphics and compute API
Stars: ✭ 1,962 (+1225.68%)
Mutual labels:  graphics-programming
Renderdoc
RenderDoc is a stand-alone graphics debugging tool.
Stars: ✭ 5,969 (+3933.11%)
Mutual labels:  graphics-programming
Renderer
A shader-based software renderer written from scratch in C89
Stars: ✭ 1,366 (+822.97%)
Mutual labels:  graphics-programming
Diligentsamples
Sample projects demonstrating the usage of Diligent Engine
Stars: ✭ 138 (-6.76%)
Mutual labels:  graphics-programming
Pencilsketcheffect
Real Time Hatching In Unity
Stars: ✭ 134 (-9.46%)
Mutual labels:  graphics-programming
Graphicalgorithm
🐙 🐙图形学论文实现
Stars: ✭ 108 (-27.03%)
Mutual labels:  graphics-programming

2D Line Drawing Samples

This project contains C source code for drawing 2D lines by different techniques.

All samples output PNGs with svpng.

License: public domain.

Bresenham

The fundamental line drawing algorithm by Bresenham [1], based on rosetta code.

line_bresenham.c

Sampling

Represent lines as capsule shapes, in order to support real-valued coordinates and variable width.

line_sampling.c

Anti-aliasing by super sampling

Simple anti-aliasing with 5x5 super sampling.

line_supersampling.c

Anti-aliasing by signed distnace field

Using signed distnace field (SDF) of capsule shape to perform anti-aliasing with single sample per pixel.

line_sdf.c

SDF optimization with AABB

Use AABB of capsule to reduce the number of samples. Render shapes into the buffer individually with alpha blending.

line_sdfaabb.c

Visual comparison

Performance comparison

$ make test
gcc -Wall -O3 -o line_bresenham line_bresenham.c
gcc -Wall -O3 -o line_sampling line_sampling.c
gcc -Wall -O3 -o line_supersampling line_supersampling.c
gcc -Wall -O3 -o line_sdf line_sdf.c
gcc -Wall -O3 -o line_sdfaabb line_sdfaabb.c
time ./line_bresenham
        0.03 real         0.02 user         0.00 sys
time ./line_sampling
        1.93 real         1.91 user         0.00 sys
time ./line_supersampling
       47.06 real        46.85 user         0.10 sys
time ./line_sdf
        2.00 real         1.98 user         0.00 sys
time ./line_sdfaabb
        0.03 real         0.03 user         0.00 sys

Final notes

  1. These samples are only for illustrative purposes.
  2. Line clipping are not performed.
  3. The SDF AABB sample can be further optimized by tigther quaduraliteral bounds.

References

[1] Bresenham, Jack E. "Algorithm for computer control of a digital plotter." IBM Systems journal 4.1 (1965): 25-30.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].