<commit_before>#![doc(html_root_url = "https://github.com/KevinKelley/nanovg-rs")]

#![feature(optin_builtin_traits, slice_patterns, const_fn)] // Until 1.0, when this feature stablizes
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(unused_qualifications)]
#![allow(unused_imports)]
#![allow(unused_attributes)]
#![allow(dead_code)]
//#![warn(missing_doc)]
#![deny(unused_parens)]
#![deny(non_upper_case_globals)]
#![deny(unused_results)]

#[macro_use]
extern crate bitflags;
extern crate libc;

use std::fmt;
use std::ptr;
use std::str;
use std::ffi::CString;

use libc::{c_char, c_int, c_void, c_float};

use ffi::NVGcolor;
use ffi::NVGpaint;
use ffi::NVGglyphPosition;
use ffi::NVGtextRow;

mod ffi;

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum Winding {
    CCW                     = ffi::NVG_CCW,
    CW                      = ffi::NVG_CW,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum Solidity {
    SOLID                   = ffi::NVG_SOLID,
    HOLE                    = ffi::NVG_HOLE,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum LineCap {
    BUTT                    = ffi::NVG_BUTT,
    ROUND                   = ffi::NVG_ROUND,
    SQUARE                  = ffi::NVG_SQUARE,
    BEVEL                   = ffi::NVG_BEVEL,
    MITER                   = ffi::NVG_MITER,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum PatternRepeat {
    NOREPEAT                = ffi::NVG_NOREPEAT,
    REPEATX                 = ffi::NVG_REPEATX,
    REPEATY                 = ffi::NVG_REPEATY,
}

bitflags!{
    flags Align: u32 {
        const LEFT         = ffi::NVG_ALIGN_LEFT,
        const CENTER       = ffi::NVG_ALIGN_CENTER,
        const RIGHT        = ffi::NVG_ALIGN_RIGHT,
        const TOP          = ffi::NVG_ALIGN_TOP,
        const MIDDLE       = ffi::NVG_ALIGN_MIDDLE,
        const BOTTOM       = ffi::NVG_ALIGN_BOTTOM,
        const BASELINE     = ffi::NVG_ALIGN_BASELINE
    }
}

bitflags!{
    flags CreationFlags: u32 {
        const ANTIALIAS        = ffi::NVG_ANTIALIAS,
        const STENCIL_STROKES  = ffi::NVG_STENCIL_STROKES
    }
}

bitflags!{
    flags ImageFlags: u32 {
        const GENERATE_MIPMAPS = ffi::NVG_IMAGE_GENERATE_MIPMAPS
    }
}

// Color

#[derive(Clone, Copy, PartialEq)]
pub struct Color {
    nvg: NVGcolor
}

impl Color {
    #[inline]
    fn wrap(nvg: NVGcolor) -> Color { Color { nvg: nvg } }

    #[inline]
    pub fn r(&self) -> f32 { self.nvg.r }

    #[inline]
    pub fn g(&self) -> f32 { self.nvg.g }

    #[inline]
    pub fn b(&self) -> f32 { self.nvg.b }

    #[inline]
    pub fn a(&self) -> f32 { self.nvg.a }

    pub fn rgb(r: u8, g: u8, b: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgRGB(r, g, b) })
    }
    pub const fn rgb_f(r: f32, g: f32, b: f32) -> Color {
        Color { nvg: ffi::NVGcolor { r: r, g: g, b: b, a: 1.0 } }
    }
    pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgRGBA(r, g, b, a) })
    }
    pub const fn rgba_f(r: f32, g: f32, b: f32, a: f32) -> Color {
        Color { nvg: ffi::NVGcolor { r: r, g: g, b: b, a: a } }
    }
    pub fn lerp_rgba(c0: Color, c1: Color, u: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgLerpRGBA(c0.nvg, c1.nvg, u) })
    }
    pub fn trans_rgba(c0: Color, a: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgTransRGBA(c0.nvg, a) })
    }
    pub fn trans_rgba_f(c0: Color, a: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgTransRGBAf(c0.nvg, a) })
    }
    pub fn hsl(h: f32, s: f32, l: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgHSL(h, s, l) })
    }
    pub fn hsla(h: f32, s: f32, l: f32, a: u8) -> Color {
        Color::wrap(unsafe { ffi:: nvgHSLA(h, s, l, a) })
    }
}

impl fmt::Debug for Color {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "r:{}, g:{}, b:{}, a:{}", self.r(), self.g(), self.b(), self.a())
    }
}

// Paint

pub struct Paint {
    nvg: NVGpaint<commit_msg>Removed 'const' functions.<commit_after>#![doc(html_root_url = "https://github.com/KevinKelley/nanovg-rs")]

#![feature(optin_builtin_traits, slice_patterns, const_fn)] // Until 1.0, when this feature stablizes
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(unused_qualifications)]
#![allow(unused_imports)]
#![allow(unused_attributes)]
#![allow(dead_code)]
//#![warn(missing_doc)]
#![deny(unused_parens)]
#![deny(non_upper_case_globals)]
#![deny(unused_results)]

#[macro_use]
extern crate bitflags;
extern crate libc;

use std::fmt;
use std::ptr;
use std::str;
use std::ffi::CString;

use libc::{c_char, c_int, c_void, c_float};

use ffi::NVGcolor;
use ffi::NVGpaint;
use ffi::NVGglyphPosition;
use ffi::NVGtextRow;

mod ffi;

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum Winding {
    CCW                     = ffi::NVG_CCW,
    CW                      = ffi::NVG_CW,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum Solidity {
    SOLID                   = ffi::NVG_SOLID,
    HOLE                    = ffi::NVG_HOLE,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum LineCap {
    BUTT                    = ffi::NVG_BUTT,
    ROUND                   = ffi::NVG_ROUND,
    SQUARE                  = ffi::NVG_SQUARE,
    BEVEL                   = ffi::NVG_BEVEL,
    MITER                   = ffi::NVG_MITER,
}

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(u32)]
pub enum PatternRepeat {
    NOREPEAT                = ffi::NVG_NOREPEAT,
    REPEATX                 = ffi::NVG_REPEATX,
    REPEATY                 = ffi::NVG_REPEATY,
}

bitflags!{
    flags Align: u32 {
        const LEFT         = ffi::NVG_ALIGN_LEFT,
        const CENTER       = ffi::NVG_ALIGN_CENTER,
        const RIGHT        = ffi::NVG_ALIGN_RIGHT,
        const TOP          = ffi::NVG_ALIGN_TOP,
        const MIDDLE       = ffi::NVG_ALIGN_MIDDLE,
        const BOTTOM       = ffi::NVG_ALIGN_BOTTOM,
        const BASELINE     = ffi::NVG_ALIGN_BASELINE
    }
}

bitflags!{
    flags CreationFlags: u32 {
        const ANTIALIAS        = ffi::NVG_ANTIALIAS,
        const STENCIL_STROKES  = ffi::NVG_STENCIL_STROKES
    }
}

bitflags!{
    flags ImageFlags: u32 {
        const GENERATE_MIPMAPS = ffi::NVG_IMAGE_GENERATE_MIPMAPS
    }
}

// Color

#[derive(Clone, Copy, PartialEq)]
pub struct Color {
    nvg: NVGcolor
}

impl Color {
    #[inline]
    fn wrap(nvg: NVGcolor) -> Color { Color { nvg: nvg } }

    #[inline]
    pub fn r(&self) -> f32 { self.nvg.r }

    #[inline]
    pub fn g(&self) -> f32 { self.nvg.g }

    #[inline]
    pub fn b(&self) -> f32 { self.nvg.b }

    #[inline]
    pub fn a(&self) -> f32 { self.nvg.a }

    pub fn rgb(r: u8, g: u8, b: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgRGB(r, g, b) })
    }
    pub fn rgb_f(r: f32, g: f32, b: f32) -> Color {
        Color { nvg: ffi::NVGcolor { r: r, g: g, b: b, a: 1.0 } }
    }
    pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgRGBA(r, g, b, a) })
    }
    pub fn rgba_f(r: f32, g: f32, b: f32, a: f32) -> Color {
        Color { nvg: ffi::NVGcolor { r: r, g: g, b: b, a: a } }
    }
    pub fn lerp_rgba(c0: Color, c1: Color, u: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgLerpRGBA(c0.nvg, c1.nvg, u) })
    }
    pub fn trans_rgba(c0: Color, a: u8) -> Color {
        Color::wrap(unsafe { ffi::nvgTransRGBA(c0.nvg, a) })
    }
    pub fn trans_rgba_f(c0: Color, a: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgTransRGBAf(c0.nvg, a) })
    }
    pub fn hsl(h: f32, s: f32, l: f32) -> Color {
        Color::wrap(unsafe { ffi::nvgHSL(h, s, l) })
    }
    pub fn hsla(h: f32, s: f32, l: f32, a: u8) -> Color {
        Color::wrap(unsafe { ffi:: nvgHSLA(h, s, l, a) })
    }
}

impl fmt::Debug for Color {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "r:{}, g:{}, b:{}, a:{}", self.r(), self.g(), self.b(), self.a())
    }
}

// Paint

pub struct Paint {
    nvg: NVGpaint
{'fraction_non_alphanumeric': 0.1626066526524051, 'fraction_numerical': 0.018053666378137753, 'mean_word_length': 2.4271186440677965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1614441', 'n_tokens_mistral': 3464, 'n_tokens_neox': 3379, 'n_words': 721}