Git Product home page Git Product logo

lua-nanovg's Introduction

lua-nanovg - NanoVG support for Lua language

lua-nanovg is a Lua binding for NanoVG. add a light-weight support for vector graphics support to Lua language.

lua-nanovg has a HTML5 canvas similar inteface, makes Lua client-side GUI more easily.

lua-nanovg has the same Licence with Lua language.

Usage

To use lua-nanovg, you should first require it, after that, you will get a function to create context for drawing:

local ctx = require 'nvg' ()

You can pass some arguments to this function, to specify the atlas size and/or edge AA (anti-alias) flags:

local ctx = require 'nvg' (256, 256, "AA") -- default
local ctx = require 'nvg' (256, 256) -- no edge anti-alias
local ctx = require 'nvg' "AA" -- use edge anti-alias, and default atlas size.

After you get context, you can draw with it. All APIs will exactly same with HTML5 canvas.

API

sub module:

  • color
  • image
  • gradient
  • font
ctx:beginFrame()
ctx:endFrame()
ctx:color("name")
ctx:color("#rgb")
ctx:color("#argb")
ctx:color("#rrggbb")
ctx:color("#aarrggbb")
ctx:color(r,g,b)
ctx:color(r,g,b,a)
ctx:color("HSL", h,s,l);
ctx:color("HSL", h,s,l,a);

ctx:save()
ctx:restore()
ctx:reset()

ctx.strokeStyle = color|paint;
ctx.fillStyle = color|paint;

ctx.lineCap = "butt|round|square";
ctx.lineJoin = "round|bevel|miter";
ctx.lineWidth = width;
ctx.miterLimit = number;

ctx:resetTransform()
ctx:scale()
ctx:rotate()
ctx:translate()
ctx:transform()
ctx:setTransform()


ctx:image() -> ctx.image.load
ctx:drawImage()
ctx.image.new()
ctx.image.load()
=image.width
=image.height
image:update()
image:delete()

ctx:gradient()
ctx.gradient.linear()
ctx.gradient.box()
ctx.gradient.radial()

ctx:scissor()

ctx.pathWnding = "(solid|hole)|(CCW|CW)";
ctx:beginPath()
ctx:moveTo()
ctx:lineTo()
ctx:bezierTo() == ctx:bezierCurveTo()
ctx:arcTo()
ctx:closePath()

ctx:arc()
ctx:rect()
ctx:roundRect()
ctx:ellipse()
ctx:circle()
ctx:fill()
ctx:stroke()

ctx.font = font;
ctx.textAlign = 
ctx.fontBlur = number;
ctx:text()
ctx:measureText()

lua-nanovg's People

Contributors

starwing avatar

Watchers

Matthieu Texier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.