项目作者: JulianWebb

项目描述 :
Love2D Hex Colour Conversion Library
高级语言: Lua
项目地址: git://github.com/JulianWebb/Hexatonic.git
创建时间: 2020-10-05T18:02:04Z
项目社区:https://github.com/JulianWebb/Hexatonic

开源协议:Other

下载


HEXATONIC: An overengineered hex color code conversion library for Love2D

An overengineered hex color code conversion library for Love2D

Built off of Hex Maniac by LavenderTheGreat

Features

  • Convert from RGB(A) with an optional opacity value
  • Converts correctly for both 0-1 and 0-255 seemlessly
  • Argument validation for both hex color codes and opacity
  • Takes console logging functions on initalization

Require

HEXATONIC can be required in multiple ways

  1. -- Multistep
  2. local HEXATONIC = require 'hexatonic')
  3. local hex = HEXATONIC(Logger)
  4. -- Single step
  5. -- #1
  6. local hex = require 'hexatonic'(Logger)
  7. -- #2
  8. local hex = require('hexatonic')(Logger)

The logger argument is a table expected to contain log, alert, and error functions for HEXATONIC to call when or if required.

Usage

Usage is simple, simply call hex with a hex color code and optional opacity value (0-1), it will return a table matching Love’s requirements for a color.

  1. love.graphics.setColor(hex('20214F'))
  2. love.graphics.setColor(hex('20214FA3'))
  3. love.graphics.setColor(hex('20214F', 0.25))