This project has given up GitHub. (See Software Freedom Conservancy's Give Up GitHub site for details.)
You can now find this project at https://codeberg.org/apicici/clipper-luajit-ffi instead.
Any use of this project's code by GitHub Copilot, past or present, is done without our permission. We do not consent to GitHub's use of this project's code in Copilot.
Join us; you can give up GitHub too!
LuaJIT FFI bindings for the C++ version of Angus Johnson's Clipper library.
Pre-built binaries can be found in the releases page for the following systems/architectures:
- Linux x64
- Windows x86, x64
- macos x64
The shared library required for LuaJIT FFI can be compiled using CMake with the provided CMakeLists.txt
.
Refer to the Clipper library's documentation for usage of the C++ library.
- Place the shared library (
clipper.so
,clipper.dll
, orclipper.dylib
, depending on the system) andclipper.lua
somewhere where they can be found byrequire
. You may need to modifypackage.path
andpackage.cpath
. - Require the library with
local clipper = require "clipper"
- Lua numbers are automatically converted to Clipper's
CInt
type. However,CInt
cdata objects are not automatically converted to numbers (usetonumber
to convert them). - FFI does not use explicit pointers or references. Just pass an object to a function, and it will be treated as a value, pointer, or reference as necessary
- Clipper
Path
andPaths
are wrapped in Lua and (mostly) behave asstd::vector
. Usage examples:path = clipper.Path() -- initialise empty vector path.push_back(clipper.IntPoint(1,2)) -- add IntPoint to vector path = clipper.Path(3) -- initialise vector of size 3 path[0] = clipper.IntPoint(2, 3) -- specify first IntPoint in vector