Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrewyavors/Lua-Color-Converter
Converts your hex or RGB values into Corona/Defold-compatible format
https://github.com/andrewyavors/Lua-Color-Converter
colors corona corona-sdk defold hex lua-color-converter rgb-values
Last synced: about 2 months ago
JSON representation
Converts your hex or RGB values into Corona/Defold-compatible format
- Host: GitHub
- URL: https://github.com/andrewyavors/Lua-Color-Converter
- Owner: andrewyavors
- Created: 2016-01-15T23:04:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T16:17:39.000Z (9 months ago)
- Last Synced: 2024-10-25T09:48:41.140Z (about 2 months ago)
- Topics: colors, corona, corona-sdk, defold, hex, lua-color-converter, rgb-values
- Language: Lua
- Homepage:
- Size: 7.81 KB
- Stars: 29
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-solar2d - Lua-Color-Converter - converts hex or RGB values into compatible format. (Graphics)
README
# Lua Color Converter
Converts your hex or RGB values into Corona/Defold-compatible format (numbers from 0 to 1)### HowTo:
1. Put **convertcolor.lua** into your project directory2. Load it from your files (where it's necessary)
```lua
local color = require("convertcolor")
```3. Use it to convert from hex:
```lua
color.hex("#ff00ff")
color.hex("#ff00ff", 0.5) --alpha set to 50%
```
.. and to convert from regular rgb:
```lua
color.rgb(255, 0, 255)
color.rgba(255, 0, 255, 0.1) --alpha set to 10%
```### Examples:
```lua
local myText = display.newText( "example from Corona Docs", 0, 0, native.systemFontBold, 12 )
myText:setFillColor( color.hex("#ff10ae") )
``````lua
go.set("#label", "color", vmath.vector4(color.rgb(255, 16, 174, 1))
```