Skip to content

Commit

Permalink
Loading constant colors from resources & doc (#6)
Browse files Browse the repository at this point in the history
* ➕Add Kover
♻️Refactor tests
* ➕Move to kotest form pure JUnit
* ✨Reimplement const colors parsing
* 📝Update readme

---------

Co-authored-by: quicklybly <[email protected]>
  • Loading branch information
FelixDes and quicklybly authored Sep 16, 2023
1 parent f45ec25 commit 259c188
Show file tree
Hide file tree
Showing 51 changed files with 1,588 additions and 1,342 deletions.
23 changes: 0 additions & 23 deletions .github/release-drafter.yaml

This file was deleted.

20 changes: 16 additions & 4 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@ tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '✨New Features'
labels:
- 'type:features'
- 'features'

- title: '🐛Bugs Fixes'
labels:
- 'type:fix'
- 'fix'

- title: '📖Documentation'
labels:
- 'type:documentation'
- 'documentation'

- title: '⚙️Configuration'
labels:
- 'type:config'
- 'config'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/label_verify.yaml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Verify PR labels

on:
pull_request:
types: [ opened, labeled, unlabeled, synchronize ]

jobs:
label_check:
runs-on: ubuntu-latest
steps:
- uses: zwaldowski/match-label-action@v2
with:
allowed: fix, features, documentation, config

build_and_test:
runs-on: ubuntu-latest
steps:
- name: ⚡️Checkout
uses: actions/checkout@v3
- name: 🐘Setup Gradle
uses: gradle/gradle-build-action@v2
- name: 🍻Gradle build
run: ./gradlew test executableJar
# - name: 🚀Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: JAR
# path: build/libs/*-executable.jar
# retention-days: 1
kover_report:
runs-on: ubuntu-latest
steps:
- name: ⚡️Checkout
uses: actions/checkout@v3
- name: 🐘Setup Gradle
uses: gradle/gradle-build-action@v2
- name: 📑Generate kover coverage report
run: ./gradlew koverXmlReport
- name: ➕Add coverage report to PR
id: kover
uses: mi-kas/kover-report@v1
with:
path: |
${{ github.workspace }}/colsum/build/reports/kover/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: Code Coverage
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 60
coverage-counter-type: LINE
20 changes: 0 additions & 20 deletions .github/workflows/push.yaml

This file was deleted.

44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# colsum
Simple cli util for intersecting colors
<div style="right:0; position: absolute; width: 100px; height: 150px; opacity: 80%">
<div style="position: absolute; width: 50px; height: 50px; background-color: blue; z-index: 2"></div>
<div style="top: 30px; left: 30px; position: absolute; width: 50px; height: 50px; background-color: aqua; z-index: 1"></div>
<div style="top: 30px; left: 30px; position: absolute; width: 50px; height: 50px; background-color: rgba(0,255,255,0.54); z-index: 3"></div>
</div>

# $ colsum

Simple command line tool for overlaying colors

```shell
java -jar colsum.jar -b "aqua" -e "rgb(55, 12, 2, 0.4) + rgba(1, 50, 217, 0.3)"
```

<div style="font-size: 20px">
Usage:<br>
<div style="margin-left: 25px">
— expression, -e -> Expression for computation (always required) { String }<br>
— background, -b [#FFF] -> background color { String }<br>
— help, -h -> Usage info<br>
</div>
</div>

# 🧑‍💻 For new contributors

🚧 Under construction 🚧

# 🔧 Internals

A brief structural components overview

## 🔍️ Parser

🚧 Under construction 🚧

## 🎨 Alpha composition formulas

Сolors are superimposed like, for example, in the Mozilla Firefox browser. Formulas are presented below:

```
result alpha = background alpha * (1 - new alpha) + new alpha
result color[R,G,B] = background alpha * (1 - new alpha) * background color + new color * new alpha
```
12 changes: 9 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
plugins {
kotlin("jvm") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
id("io.kotest") version "0.4.10"
application
}

group = "org.colsum"
version = "1.0-SNAPSHOT"
val kotestVersion by extra { "5.7.2" }

repositories {
mavenCentral()
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.5")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1")

// ======= TESTS =======
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.0")
testImplementation("org.mockito:mockito-core:4.2.0")
testImplementation("junit:junit:4.13.2")
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-framework-datatest-jvm:$kotestVersion")
}

tasks.test {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun main(args: Array<String>) {
ArgType.String,
shortName = "e",
fullName = "expression",
description = "String for computation"
description = "Expression for computation"
).required()
val backgroundColor by parser.option(
ArgType.String,
Expand All @@ -20,5 +20,5 @@ fun main(args: Array<String>) {
).default("#FFF")
parser.parse(args)

println(translate(mainExpression, backgroundColor).toString())
println(translate(mainExpression, backgroundColor))
}
18 changes: 18 additions & 0 deletions src/main/kotlin/color/ConstantColorsService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package color

import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import utils.ResourcePaths.CONSTANT_COLORS
import java.io.File
import java.util.regex.Pattern
import java.util.regex.Pattern.CASE_INSENSITIVE


object ConstantColorsService {
private val colors: Map<String, CssColor> =
Json.decodeFromString<Map<String, String>>(CONSTANT_COLORS.getResource())
.mapValues { CssColor.fromHEX(it.value) }

fun getNamesRegex() = Pattern.compile(colors.keys.joinToString(separator = "|"), CASE_INSENSITIVE)!!.toRegex()
operator fun get(name: String): CssColor = colors[name]!!
}
Loading

0 comments on commit 259c188

Please sign in to comment.