Giter VIP home page Giter VIP logo

nanovg.jl's Introduction

NanoVG

Julia bindings for the NanoVG drawing library.

NanoVG is small antialiased vector graphics rendering library for OpenGL. It has lean API modeled after HTML5 canvas API. It is aimed to be a practical and fun toolset for building scalable user interfaces and visualizations.

Screenshot

NanoVG Demo

Installation

NanoVG is a   Julia Language   package. To install NanoVG, open Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command:

pkg> add https://github.com/dylanxyz/NanoVG.jl

Note that NanoVG is not yet at the public registry, installation is done directly from this repo.

Documentation

In progress...

Basic Example

using GLFW
using NanoVG
using ModernGL

function main()
   title = "NanoVG Basic Example"
   width = 800
   height = 600

   window = GLFW.CreateWindow(width, height, title)
   @assert window.handle != C_NULL "Could not create a GLFW window 😢"

   GLFW.MakeContextCurrent(window)

   # Create the NanoVG context with the GL3 implementation
   NanoVG.create(NanoVG.GL3, antialiasing=true)

   while true
      if GLFW.WindowShouldClose(window) break end
      # get the framebuffer size
      width, height = GLFW.GetFramebufferSize(window)
      # get the window size
      winWidth, winHeight = GLFW.GetWindowSize(window)
      # dpr = device pixel ratio
      dpr = width / winWidth
      # set the viewport
      glViewport(0, 0, width, height)
      # create a new frame
      NanoVG.frame(winWidth, winHeight, dpr)
      # drawing functions should be called here
      
      # set the fill color
      fillcolor(rgb(128, 32, 56))
      # draw a filled circle at the center of the screen
      circle(width/2, height/2, 128, :fill)

      # render the frame to the screen
      NanoVG.render()

      GLFW.SwapBuffers(window)
      GLFW.PollEvents()
   end

   NanoVG.dispose()
   GLFW.DestroyWindow(window)
end

main()

License

This package is licensed under the MIT license.

NanoVG is licensed under the zlib license.

Additional licenses for assets:

nanovg.jl's People

Contributors

telavoid avatar dylanxyz avatar

Stargazers

Páll Haraldsson avatar Suavesito avatar Jeffrey Sarnoff avatar

Watchers

 avatar

nanovg.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

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.