GithubHelp home page GithubHelp logo

nim-libgd's Introduction

nim-libgd

Nim Wrapper for LibGD 2.x

Work in progress...

This library has been tested with Nim v0.20.0 (1.0 RC) on Linux

Example of Usage

import libgd

proc main() =

  withGd imageCreate(300, 300) as img:
    discard img.backgroundColor(0xffffff)
    let green = img.setColor(0, 0, 255)

    img.setThickness(4)
    img.drawRectangle(
      startCorner=[10, 10],
      endCorner=[300 - 10, 300 - 10],
      color=green)
    let png_out = open("test.png", fmWrite)
    img.writePng(png_out)
    png_out.close()

main()

Fractal Image from Examples

Newton Fractal

Graph from Examples

Cubic Function Graph

How to install nim-libgd with Nimble?

You need to have installed the gd library in your system.

If you use Arch Linux, the library can be installed with: sudo pacman -S gd.

Run the Nimble install command: $ nimble install https://github.com/mrhdias/nim-libgd

Functions

Work in progress...

Drawing Functions

proc setPixel(
  img: gdImagePtr,
  point: array[2,int],
  color: int = -1
)
proc drawLine(
  img: gdImagePtr,
  start_point: array[2,int],
  end_point: array[2,int],
  color: int = -1,
  dashed: bool = false
)
proc drawRectangle(
  img: gdImagePtr,
  start_corner: array[2,int],
  end_corner: array[2,int],
  color: int,
  fill: bool = false
)
proc drawArc(
  img: gdImagePtr,
  center: array[2,int],
  axis: array[2,int],
  angles: array[2,int],
  color: int,
  fill: bool = false,
  style: int = 0
)
proc drawEllipse(
  img: gdImagePtr,
  center: array[2,int],
  axis: array[2,int],
  color: int,
  fill: bool = false
)
proc drawCircle(
  img: gdImagePtr,
  center: array[2,int],
  radius: int,
  color: int = -1,
  fill: bool = false
)
proc drawPolygon(
  img: gdImagePtr,
  points: openArray[array[0..1, int]],
  color: int,
  fill: bool = false,
  open: bool = false
)
proc drawRegularPolygon(
  img: gdImagePtr,
  center: array[2,int],
  sides: int,
  radius: int,
  start_angle: int = 0,
  color: int,
  fill: bool = false,
  open: bool = false
)

Image Filters

proc filterContrast(src: gdImagePtr, contrast: float): bool
proc filterBrightness(src: gdImagePtr, brightness: int): bool
proc filterGrayScale(src: gdImagePtr): bool
proc filterNegate(src: gdImagePtr): bool
proc filterEmboss(src: gdImagePtr): bool
proc filterGaussianBlur(src: gdImagePtr): bool
proc filterSmooth(src: gdImagePtr, weight: float): bool
proc filterEdgeDetectQuick(src: gdImagePtr): bool
proc filterSelectiveBlur(src: gdImagePtr): bool
proc filterMeanRemoval(src: gdImagePtr): bool

nim-libgd's People

Contributors

mrhdias avatar rustomax avatar

Watchers

 avatar  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.