2015-01-08 18:43:34 +00:00
|
|
|
Skia Lua Bindings
|
|
|
|
=================
|
|
|
|
|
2016-11-11 16:39:44 +00:00
|
|
|
**Warning: The following has only been tested on Mac and Linux, but it will
|
|
|
|
likely work for any Unix.**
|
2015-01-08 18:43:34 +00:00
|
|
|
|
|
|
|
Prerequisites
|
|
|
|
-------------
|
|
|
|
|
2016-11-11 16:39:44 +00:00
|
|
|
This assumes you already have Skia building normally. If not, refer to [How to
|
|
|
|
build Skia](../build).
|
2015-01-08 18:43:34 +00:00
|
|
|
|
|
|
|
Build
|
|
|
|
-----
|
|
|
|
|
2016-11-11 16:39:44 +00:00
|
|
|
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.
|
2015-01-08 18:43:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
Try It Out
|
|
|
|
----------
|
|
|
|
|
2016-11-11 16:39:44 +00:00
|
|
|
The tools `lua_app` and `lua_pictures` should now be available when you compile,
|
2018-06-18 21:09:01 +00:00
|
|
|
and `Viewer` should now have a `Lua` sample.
|
2016-11-11 16:39:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
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:
|
2015-01-08 18:43:34 +00:00
|
|
|
|
|
|
|
$ 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()
|