skia2/site/user/special/lua.md
Mike Klein 38af9438d7 GN: build Lua tools when skia_use_lua.
When we opt into Lua, this builds SampleLua into SampleApp, and the lua_app and lua_pictures tools.

I've tested this builds with and without skia_use_system_lua on my Mac laptop and Linux desktop.

I've made lua_pictures.cpp's flags static to avoid conflicts with flags in SkCommonFlags.cpp.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4699

DOCS_PREVIEW= https://skia.org/?cl=4699

Change-Id: I8176fd51d8a38746e7d730cfcce66da42b9a015a
Reviewed-on: https://skia-review.googlesource.com/4699
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
2016-11-11 17:34:36 +00:00

1.0 KiB

Skia Lua Bindings

Warning: The following has only been tested on Mac and Linux, but it will likely work for any Unix.

Prerequisites

This assumes you already have Skia building normally. If not, refer to How to build Skia.

Build

To build Lua support into Skia tools, set the GN argument skia_use_lua to true. Optionally, set skia_use_system_lua. Then re-run GN.

Try It Out

The tools lua_app and lua_pictures should now be available when you compile, and SampleApp should now have a Lua sample.

To-Do

Skia had a feature that let it be imported as an .so by Lua. This feature is not yet supported by GN, but would have looked something like this:

$ lua

Lua 5.2.0  Copyright (C) 1994-2011 Lua.org, PUC-Rio
> require 'skia'
> paint = Sk.newPaint()
> paint:setColor{a=1, r=1, g=0, b=0}
> doc = Sk.newDocumentPDF('test.pdf')
> canvas = doc:beginPage(72*8.5, 72*11)
> canvas:drawText('Hello Lua', 300, 300, paint)
> doc:close()