Skip to content

Commit

Permalink
Port of color-java (#3)
Browse files Browse the repository at this point in the history
* Initial port of color-java (#1)

* ci: Fixing typo in readme, and adding initial stubs for github actions.

* doc: Updating build-test action link.

* ci: Adding initial build files

* test: Adding test stub configs

* chore: Porting classes from color-java project.

* chore: Porrting Color from color-java

* refactor: Moving functions around to be next to overloaded functions.

* refactor: Changing type any to (number | string)

* fix: Fixing compile errors in ColorUtils.ts

* fix: Removed most helper methods from color since typescript sucks.

* chore: Port from  color-java/ColorUtilsTest, with tests disabled.

* ci: Getting tests running

* test: uncommenting out tests for 'test valid'

* fix: Allowing for null on isValidHex calls

* fix: Correcting porting errors.

* test: uncommenting out most of 'test utils'

* fix: Correcting porting errors in toHSL

* chore: Port if ColorTest from color-java.  All commented out.

* test: uncommenting out and fixing helper methods

* test: Uncommenting out test color creation

* fix: Fixing recursion on setRed, setBule, setGreen

* fix: Trying to handle floating points at 0 and at 1

* test: Uncommenting out color hex constants test.

* test: Uncommenting test hex integers test.

* test: Uncommenting out alpha integer test

* test: Uncommenting RGB test

* test: uncommenting hex integers test

* test: uncommenting arithmetic test

* test: uncommenting hex singles test

* test: uncommenting color hsl test

* test: commenting out color with alpha check.  Fixing TODO's

* test: fixing last remaing TODOs

* ci: Porting over ReadmeTest from color-java

* doc: Updating readme from ReadmeTest.ts

* Preparing for release (#2)

* doc: Correcting spacing in README usage

* chore: Removing unused index.ts file

* doc: Removing node as an engine

* doc: Updating readme

* ci: Trying new github action

* ci: Fixing github actions

* ci: Removing coveralls step

* ci: More github action fixing

* doc: Removing link to ngagoint.github.io
  • Loading branch information
gillandk authored Sep 16, 2022
1 parent 9b309a9 commit 1cde06a
Show file tree
Hide file tree
Showing 20 changed files with 11,912 additions and 55 deletions.
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Bug report
about: Report an issue
title: ''
labels: bug
assignees: ''

---

Please fill out as much known and relevant information as possible.

#### Version Information:

* Color Javascript Version:
* Color Javascript Source: (e.g. Central Repository, Release, Source Code Build)
* IDE Name & Version:
* NPM Version: (npm --version)
* Node Version: (node --version)
* Platform & OS:
* Other Relevant Libraries:

#### Expected Results:

* What did you expect to happen?

#### Observed Results:

* What happened instead?
* How often does this occur?

#### Output:

* Any logs, errors, or output messages?

#### Steps to Reproduce:

1. Step One
2. Step Two
3. ...

#### Relevant Code:

```javascript
// Code to reproduce the problem?
```

#### Test Files:

* Links to any files needed for testing?

#### Additional Information:

* Any additional configuration, data, or information that might help with the issue?
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

blank_issues_enabled: false
contact_links:
- name: Discussions
url: https://github.com/ngageoint/color-js/discussions
about: Questions, Feature Requests, Feedback, Conversations
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Documentation report
about: Report a documentation issue
title: ''
labels: documentation
assignees: ''

---

**Describe the documentation issue**
A clear and concise description of what the issue is.

**Additional context**
Add any other context about the issue here.
19 changes: 19 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build & Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Build & Test
run: |
npm install
npm run build --if-present
npm test
env:
CI: true
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v1
- name: Build
run: |
npm install
npm run build --if-present
env:
CI: true

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test/fixtures/private
**/*/tmp

dist
test-dist
**/*/package-lock.json

built
Expand All @@ -62,5 +63,6 @@ bundle
test/bundle
test/sql-wasm.wasm
docs/coverage
tsconfig.tsbuildinfo

.idea
6 changes: 6 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
spec: 'test-dist/**/*.js',
ignore: 'test-dist/node_modules/**',
import: [
],
};
119 changes: 64 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Color Java
# Color Javascript

#### Color Lib ####

Expand All @@ -11,68 +11,77 @@ Software source code previously released under an open source license and then m

### About ###

[Color](http://ngageoint.github.io/color-js/) is a javascript library providing color representation with support for hex, RBG, arithmetic RBG, HSL, and integer colors.
Color-js is a javascript library providing color representation with support for hex, RBG, arithmetic RBG, HSL, and integer colors.

### Usage ###

View the latest [JS Docs](http://ngageoint.github.io/color-js/)
### Build and Installation ###

![Build & Test](https://github.com/ngageoint/color-js/actions/workflows/build-test.yml/badge.svg)
[![NPM](https://img.shields.io/npm/v/@ngageoint/color-js.svg)](https://www.npmjs.com/package/@ngageoint/color-js)
[![Coverage Status](https://coveralls.io/repos/github/ngageoint/color-js/badge.svg)](https://coveralls.io/github/ngageoint/color-js)

Pull from [NPM](https://www.npmjs.com/package/@ngageoint/color-js)

```install
npm install --save color-js
```sh
$ npm install @ngageoint/color-js
```

```javascript
### Usage ###

Color rgb = Color.color(154, 205, 50);
Color rgba = Color.color(255, 165, 0, 64);
Color rgbOpacity = Color.color(255, 165, 0, 0.25f);
Color arithmeticRGB = Color.color(1.0f, 0.64705882352f, 0.0f);
Color arithmeticRGBOpacity = Color.color(1.0f, 0.64705882352f, 0.0f,
0.25098039215f);
Color hex = Color.color("#BA55D3");
Color hexAlpha = Color.color("#D9FFFF00");
Color hexInteger = Color.color(0xFFC000);
Color hexIntegerAlpha = new Color(0x40FFA500);
Color integer = Color.color(16711680);
Color integerAlpha = Color.color(-12303292);
Color hexSingles = Color.color("FF", "C0", "CB");
Color hexSinglesAlpha = Color.color("00", "00", "00", "80");
Color hexSinglesOpacity = Color.color("FF", "A5", "00", 0.25f);
Color hsl = Color.color(new float[] { 300.0f, 1.0f, 0.2509804f });
Color hsla = Color
.color(new float[] { 60.0f, 1.0f, 0.5f, 0.85098039215f });
Color orangeAlpha = Color.color(ColorConstants.ORANGE, 120);
Color orangeOpacity = Color.color(ColorConstants.ORANGE, 0.25f);
```javascript

Color color = Color.blue();
const rgb: Color = new Color();
rgb.setRGB(154, 205, 50);
const rgba: Color = new Color();
rgba.setRGB(255, 165, 0);
rgba.setAlpha(64);
const rgbOpacity: Color = new Color();
rgbOpacity.setRGB(255, 165, 0);
rgbOpacity.setOpacity(0.25);
const arithmeticRGB: Color = new Color();
arithmeticRGB.setRGB(1.0, 0.64705882352, 0.0);
const arithmeticRGBOpacity: Color = new Color();
arithmeticRGBOpacity.setRGB(1.0, 0.64705882352, 0.0);
arithmeticRGBOpacity.setOpacity(0.25098039215);
const hex: Color = Color.color("#BA55D3");
const hexAlpha: Color = Color.color("#D9FFFF00");
const hexInteger: Color = new Color();
hexInteger.setColor(0xFFC000);
const hexIntegerAlpha: Color = new Color();
hexIntegerAlpha.setColor(0x40FFA500);
const integer: Color = new Color();
integer.setColor(16711680);
const integerAlpha: Color = new Color();
integerAlpha.setColor(-12303292);
const hexSingles: Color = new Color();
hexSingles.setRGB("FF", "C0", "CB");
const hexSinglesAlpha: Color = new Color();
hexSinglesAlpha.setRGB("00", "00", "00", "80")
const hexSinglesOpacity: Color = new Color();
hexSinglesOpacity.setRGB("FF", "A5", "00");
hexSinglesOpacity.setOpacity(0.25);
const hsl: Color = new Color();
hsl.setColorByHSL(300.0, 1.0, 0.2509804);
const hsla: Color = new Color();
hsla.setColorByHSL(60.0, 1.0, 0.5, 0.85098039215);
const orangeAlpha: Color = Color.color(ColorConstants.ORANGE);
orangeAlpha.setAlpha(120);
const orangeOpacity: Color = Color.color(ColorConstants.ORANGE);
orangeOpacity.setOpacity(0.25);

const color = Color.blue();
color.setAlpha(56);
String hexValue = color.getColorHex();
String hexShorthand = color.getColorHexShorthand();
String hexWithAlpha = color.getColorHexWithAlpha();
String hexShorthandWithAlpha = color.getColorHexShorthandWithAlpha();
int integerValue = color.getColor();
int integerAlphaValue = color.getColorWithAlpha();
int red = color.getRed();
float greenArithmetic = color.getGreenArithmetic();
String blueHex = color.getBlueHex();
String alphaHexShorthand = color.getAlphaHexShorthand();
float opacity = color.getOpacity();
float[] hslValue = color.getHSL();
float hue = color.getHue();
float saturation = color.getSaturation();
float lightness = color.getLightness();
const hexValue: string = color.getColorHex();
const hexShorthand: string = color.getColorHexShorthand();
const hexWithAlpha: string = color.getColorHexWithAlpha();
const hexShorthandWithAlpha: string = color.getColorHexShorthandWithAlpha();
const integerValue: number = color.getColor();
const integerAlphaValue: number = color.getColorWithAlpha();
const red: number = color.getRed();
const greenArithmetic: number = color.getGreenArithmetic();
const blueHex: string = color.getBlueHex();
const alphaHexShorthand: string = color.getAlphaHexShorthand();
const opacity: number = color.getOpacity();
const hslValue: number[] = color.getHSL();
const hue: number = color.getHue();
const saturation: number = color.getSaturation();
const lightness: number = color.getLightness();

```

### Build ###

![Build & Test](https://github.com/ngageoint/color-js/actions/workflows/run-tests.yml/badge.svg)

Build this repository using Node.js:

npm install
npm run build
Loading

0 comments on commit 1cde06a

Please sign in to comment.