skia2/site/user/special/lua.md
Brian Osman 63b3bfb711 Reland "Remove old references to SampleApp"
This reverts commit 3ff2b20057.

Reason for revert: Infra fires are out.

Original change's description:
> Revert "Remove old references to SampleApp"
> 
> This reverts commit 1c477fc263.
> 
> Reason for revert: Botpocalypse.
> Original change's description:
> > Remove old references to SampleApp
> > 
> > Docs-Preview: https://skia.org/?cl=135570
> > Change-Id: I330ffa964c2d90ca8d3cd844aabcd8616ccd0540
> > Reviewed-on: https://skia-review.googlesource.com/135570
> > Reviewed-by: Cary Clark <caryclark@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> 
> TBR=halcanary@google.com,brianosman@google.com,caryclark@google.com
> 
> Change-Id: I514e2c7bca8a1ebd311593573a94e8a078695785
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/135600
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

TBR=halcanary@google.com,brianosman@google.com,caryclark@google.com

Change-Id: I660482ef32acecf5b1bf24d2dec919bc68fde97e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/135660
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2018-06-18 21:09:09 +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 Viewer 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()