Skip to content

Commit

Permalink
rename to segancha
Browse files Browse the repository at this point in the history
  • Loading branch information
gywn committed Nov 29, 2017
1 parent c78711c commit 02de5c2
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ build/
dist/
draft/
Makefile
perception-default/
segancha-default/
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.1)

project(perception)
project(segancha)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wconversion -Wno-unused-private-field -Wno-unused-variable -Wno-unused-parameter -fno-omit-frame-pointer -fsanitize=address")
Expand All @@ -21,24 +21,24 @@ set_target_properties(native PROPERTIES SUFFIX "${PYTHON_MODULE_EXTENSION}")

if(CMAKE_BUILD_TYPE MATCHES "Debug")

add_library(perception SHARED ${LIB_SOURCES})
target_include_directories(perception PUBLIC include)
add_library(segancha SHARED ${LIB_SOURCES})
target_include_directories(segancha PUBLIC include)

add_executable(testevo1 test/example1.cpp)
target_link_libraries(testevo1 perception)
target_link_libraries(testevo1 segancha)
add_executable(testevo2 test/example2.cpp)
target_link_libraries(testevo2 perception)
target_link_libraries(testevo2 segancha)

add_executable(testlexi test/testlexi.cpp)
target_link_libraries(testlexi perception)
target_link_libraries(testlexi segancha)

add_executable(testCIEDE2000 test/testCIEDE2000.cpp)
target_link_libraries(testCIEDE2000 perception)
target_link_libraries(testCIEDE2000 segancha)
add_executable(testcolorspace test/testcolorspace.cpp)
target_link_libraries(testcolorspace perception)
target_link_libraries(testcolorspace segancha)
add_executable(testfitness test/testfitness.cpp)
target_link_libraries(testfitness perception)
target_link_libraries(testfitness segancha)
add_executable(testfitness2 test/testfitness2.cpp)
target_link_libraries(testfitness2 perception)
target_link_libraries(testfitness2 segancha)

endif(CMAKE_BUILD_TYPE MATCHES "Debug")
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Perception
# Segancha

A Python3 library with CLI that generates the optimal discernible color palette for theme building.

## Installation and Usage

pip3 install https://github.com/gywn/perception/archive/v0.0.2.tar.gz
pip3 install https://github.com/gywn/segancha/archive/v0.0.2.tar.gz

Generate demo page

perception --profile demo
cd ./perception-default/demo/
segancha --profile demo
cd ./segancha-default/demo/

Generate warm & dark theme extension for VSCode

perception --name warm-and-dark --temperature 4500 --background 15 --profile vscode
rsync -a ./perception-warm-and-dark/vscode/ ~/.vscode/extensions/
segancha --name warm-and-dark --temperature 4500 --background 15 --profile vscode
rsync -a ./segancha-warm-and-dark/vscode/ ~/.vscode/extensions/

## Aknowladgement

Expand Down
14 changes: 7 additions & 7 deletions include/fitness.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ double offChroma(const color::LCH &lch, double C);
LexiProduct<double> fitnessFunc(const std::vector<color::LAB> &lab,
size_t M = 0, double maxC = -1.);

struct PerceptionResult {
struct SeganchaResult {
unsigned long flags;
double L;
double maxC;
std::vector<color::LAB> lab;
std::vector<color::RGB> rgb;
LexiProduct<double> fitness;
};
using PerceptionResult = struct PerceptionResult;
using SeganchaResult = struct SeganchaResult;

std::ostream &operator<<(std::ostream &os, const PerceptionResult &res);
std::ostream &operator<<(std::ostream &os, const SeganchaResult &res);

/*
* @param M numbers of free colors
* @param L luminosity constraint, < 0 to be ignored
* @param maxC maximal chroma, < 0 to be ignored
* @param fixed vector of fixed colors, optional
* @param quiet don't write info to stdout
* @return PerceptionResult
* @return SeganchaResult
*/
PerceptionResult perception(size_t M, double L = -1, double maxC = -1,
std::vector<color::LAB> const *fixed = nullptr,
bool quiet = false);
SeganchaResult segancha(size_t M, double L = -1, double maxC = -1,
std::vector<color::LAB> const *fixed = nullptr,
bool quiet = false);

color::LCH maxChroma(const color::LCH &lch, double maxC = -1);
6 changes: 3 additions & 3 deletions python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

def argparser():
ps = ArgumentParser(
prog='perception',
prog='segancha',
description=dedent("""
Generate optimized discernible color palette and themes settings
Example:
perception --temperature -1 --profile demo
perception --background 97 --profile vscode
segancha --temperature -1 --profile demo
segancha --background 97 --profile vscode
"""),
formatter_class=RawDescriptionHelpFormatter)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Perception Theme - {{name}} | Demo</title>
<title>Segancha Theme - {{name}} | Demo</title>
<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700" rel="stylesheet">
<style>
.fg { color: #{{fg-hex}}; }
Expand Down Expand Up @@ -81,7 +81,7 @@
</head>
<body id="home" class='fg bg-0'>
<div id="wrapper">
<img src='perception-{{name}}-thumb.svg' id='thumb' />
<img src='segancha-{{name}}-thumb.svg' id='thumb' />
<div id='hex-wrapper'>
<pre style="width: calc(18px * 14);">
<b>Foreground:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif

" ... 1~15 should be set by the terminal

let g:colors_name = 'perception-{{name}}'
let g:colors_name = 'segancha-{{name}}'

hi NonText ctermfg=7 ctermbg=NONE guifg=#{{bg-1-hex}} guibg=NONE cterm=NONE gui=NONE
hi Normal ctermfg=NONE ctermbg=NONE guifg=#{{fg-hex}} guibg=#{{bg-0-hex}} cterm=NONE gui=NONE
Expand Down Expand Up @@ -63,7 +63,7 @@ hi Cursor guifg=NONE guibg=#{{bg-1-hex}}
hi iCursor guifg=NONE guibg=#{{main-0-hex}}
hi vCursor guifg=NONE guibg=#{{yellow-1-hex}}

augroup ColorSchemePerception
augroup ColorSchemeSegancha
au InsertLeave * hi StatusLine ctermfg=NONE ctermbg=NONE guifg=NONE guibg=NONE cterm=bold,reverse gui=bold,reverse
au InsertEnter * hi StatusLine ctermfg=NONE ctermbg=NONE guifg=#{{main-0-hex}} guibg=NONE cterm=bold,reverse gui=bold,reverse
" au InsertEnter * hi CursorLine ctermfg=NONE ctermbg=NONE cterm=NONE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "perception-theme-{{name}}",
"name": "segancha-theme-{{name}}",
"version": "{{version}}",
"engines": {
"vscode": "^0.9.0"
Expand All @@ -8,9 +8,9 @@
"contributes": {
"themes": [
{
"label": "Perception Colors Theme {{name}}",
"label": "Segancha Colors Theme {{name}}",
"uiTheme": "{{ui-theme}}",
"path": "./themes/perception-theme.json"
"path": "./themes/segancha-theme.json"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Perception Colors Theme",
"name": "Segancha Colors Theme",
"colors": {
// Contrast colors (This is not a high contrast theme)
// "contrastActiveBorder": "#f00",
Expand Down
2 changes: 1 addition & 1 deletion python/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def recursive_render(src_path,
# @param args.verbose
def parse(args, ctx):
srcs = ['.', os.path.join(os.path.dirname(__file__), 'data')]
dest = f'./perception-{args.name}'
dest = f'./segancha-{args.name}'
if not args.profiles:
args.profiles = ['demo']
print('Available builtin profiles:')
Expand Down
4 changes: 2 additions & 2 deletions python/theme.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import product
from .native import LABtoRGB, LCHtoLAB, maxChroma, perception, IlluminantD
from .native import LABtoRGB, LCHtoLAB, maxChroma, segancha, IlluminantD

# D50_x = 0.3457048
SEMANTIC_HUE = {'red': 30, 'yellow': 80, 'green': 120, 'blue': 260}
Expand Down Expand Up @@ -61,7 +61,7 @@ def update_context(args, ctx):
+ f'args.L0={args.L0} Lb={args.Lb} T={args.T}')

sgn = 1 if args.Lf > args.Lb else -1
palette3 = perception(
palette3 = segancha(
7,
L=args.L3,
maxC=args.maxC,
Expand Down
2 changes: 1 addition & 1 deletion python/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.2'
__version__ = '0.0.1'
18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def build_extension(self, ext):
exec(f.read())

setup(
name='perception',
name='segancha',
version=__version__, # noqa: F821
description='Perception colors model',
description='Segancha colors model',
install_requires=['pystache'],
packages=['perception'],
package_dir={'perception': 'python'},
packages=['segancha'],
package_dir={'segancha': 'python'},
ext_modules=[
CMakeExtension(
'perception.native',
'segancha.native',
sources=[
f
for f in
Expand All @@ -94,14 +94,14 @@ def build_extension(self, ext):
])
],
package_data={
'perception': [
'segancha': [
os.path.relpath(p, 'python')
for p in glob('python/data/**', recursive=True)
]
},
entry_points={'console_scripts': [
'perception = perception.cli:main',
'segancha = segancha.cli:main',
]},
cmdclass=dict(build_ext=CMakeBuild),
url='https://github.com/gywn/perception',
download_url='https://github.com/gywn/perception/archive/v0.0.2.tar.gz')
url='https://github.com/gywn/segancha',
download_url='https://github.com/gywn/segancha/archive/v0.0.1.tar.gz')
12 changes: 6 additions & 6 deletions src/fitness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void fill_lab(const std::vector<double> &x, double L,
lab[j] = color::LAB{L, x[2 * j], x[2 * j + 1]};
}

std::ostream &operator<<(std::ostream &os, const PerceptionResult &res) {
std::ostream &operator<<(std::ostream &os, const SeganchaResult &res) {
os << "{" << std::endl << " flags: " << res.flags << std::endl;
os << " L: " << res.L << std::endl;
os << " rgb: [" << std::endl;
Expand All @@ -122,8 +122,8 @@ std::ostream &operator<<(std::ostream &os, const PerceptionResult &res) {
return os;
}

PerceptionResult perception(size_t M, double L, double maxC,
std::vector<color::LAB> const *fixed, bool quiet) {
SeganchaResult segancha(size_t M, double L, double maxC,
std::vector<color::LAB> const *fixed, bool quiet) {
bool freeL = L < 0;
bool noFixed = fixed == nullptr || fixed->size() == 0;
size_t fixedM = fixed == nullptr ? 0 : fixed->size();
Expand Down Expand Up @@ -196,9 +196,9 @@ PerceptionResult perception(size_t M, double L, double maxC,
rgb[i] = color::LABtoRGB(lab[i]);
}

return PerceptionResult{flags, freeL ? xfinal[2 * M] : L,
finalMaxC, std::move(lab),
std::move(rgb), std::move(fitness)};
return SeganchaResult{flags, freeL ? xfinal[2 * M] : L,
finalMaxC, std::move(lab),
std::move(rgb), std::move(fitness)};
}

color::LCH maxChroma(const color::LCH &lch, double maxC) {
Expand Down
12 changes: 6 additions & 6 deletions src/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static PyObject *IlluminantDChromaticity(PyObject *self, PyObject *args) {
return Py_BuildValue("(ddd)", lab.l, lab.a, lab.b);
}

static PyObject *pyperception(PyObject *self, PyObject *args, PyObject *kw) {
static PyObject *pysegancha(PyObject *self, PyObject *args, PyObject *kw) {
// color::LAB fg, bg;
unsigned long M;
double L = -1;
Expand Down Expand Up @@ -139,7 +139,7 @@ static PyObject *pyperception(PyObject *self, PyObject *args, PyObject *kw) {
// std::cout << std::endl;
// }

const auto result = perception(M, L, maxC, &fixed, quiet);
const auto result = segancha(M, L, maxC, &fixed, quiet);
PyObj lab = PyObj(PyList_New(0));
for (const auto &c : result.lab)
PyList_Append(lab.ptr, PyObj(Py_BuildValue("(ddd)", c.l, c.a, c.b)).ptr);
Expand Down Expand Up @@ -171,8 +171,8 @@ static PyObject *pymaxChroma(PyObject *self, PyObject *args, PyObject *kw) {
}

static PyMethodDef methods[] = {
{"perception", (PyCFunction)pyperception, METH_VARARGS | METH_KEYWORDS,
"perception colors anchored by N colors\n"
{"segancha", (PyCFunction)pysegancha, METH_VARARGS | METH_KEYWORDS,
"segancha colors anchored by N colors\n"
"--------------------------------------\n"
"\n"
"@param M number of colors\n"
Expand Down Expand Up @@ -222,7 +222,7 @@ static PyMethodDef methods[] = {
{nullptr, nullptr, 0, nullptr}};

static struct PyModuleDef module = {
PyModuleDef_HEAD_INIT, "perception",
"Python interface for perception colors library", -1, methods};
PyModuleDef_HEAD_INIT, "segancha",
"Python interface for segancha colors library", -1, methods};

PyMODINIT_FUNC PyInit_native(void) { return PyModule_Create(&module); }
2 changes: 1 addition & 1 deletion test/testfitness2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
const size_t M = 7;
const std::vector<color::LAB> fixed{{0, 0, 0}, {90, 0, 0}};
for (const auto L : std::vector<double>{-1, 30, 60}) {
const auto result = perception(M, L, 100, &fixed);
const auto result = segancha(M, L, 100, &fixed);
std::cout << result << std::endl;
}

Expand Down
2 changes: 1 addition & 1 deletion test/testilluminantd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env python3

from perception import IlluminantD
from segancha import IlluminantD

print(IlluminantD(5000, 100))
print(IlluminantD(6500, 100))
2 changes: 1 addition & 1 deletion test/testmaxchroma.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env python3

from perception import maxChroma
from segancha import maxChroma

print(maxChroma((50, 0, 0)))
6 changes: 0 additions & 6 deletions test/testperception.py

This file was deleted.

6 changes: 6 additions & 0 deletions test/testsegancha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env python3

from segancha import segancha

segancha(7, L=90)
segancha(7, L=80)

0 comments on commit 02de5c2

Please sign in to comment.