Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Aug 21, 2018
2 parents a36f4e1 + 38836c6 commit 63124a7
Show file tree
Hide file tree
Showing 17 changed files with 369 additions and 101 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ RUN /opt/conda/bin/conda install -y \
matplotlib \
scipy \
six

ARG CACHE_DATE

RUN pip install \
gunicorn \
Flask-Caching \
Expand Down
33 changes: 28 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
COLOURSPACE_MODEL, IMAGE_COLOURSPACE, IMAGE_DECODING_CCTF,
PRIMARY_COLOURSPACE, RGB_colourspaces, RGB_colourspace_volume_visual,
RGB_image_scatter_visual, SECONDARY_COLOURSPACE, colourspace_models,
decoding_cctfs, pointer_gamut_visual, spectral_locus_visual, image_data)
decoding_cctfs, image_data, pointer_gamut_visual, spectral_locus_visual,
visible_spectrum_visual)

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2018 - Colour Developers'
Expand All @@ -32,7 +33,7 @@

__major_version__ = '0'
__minor_version__ = '1'
__change_version__ = '2'
__change_version__ = '3'
__version__ = '.'.join(
(__major_version__,
__minor_version__,
Expand All @@ -45,7 +46,7 @@
'colourspace_models_response', 'RGB_colourspaces_response',
'image_data_response', 'RGB_colourspace_volume_visual_response',
'RGB_image_scatter_visual_response', 'spectral_locus_visual_response',
'pointer_gamut_response', 'index', 'after_request'
'pointer_gamut_visual_response', 'index', 'after_request'
]

APP = Flask(__name__)
Expand Down Expand Up @@ -343,7 +344,7 @@ def spectral_locus_visual_response():

@APP.route('/pointer-gamut-visual')
@CACHE.cached(timeout=CACHE_DEFAULT_TIMEOUT, query_string=True)
def pointer_gamut_response():
def pointer_gamut_visual_response():
"""
Returns a *Pointer's Gamut* visual response.
Expand All @@ -363,6 +364,28 @@ def pointer_gamut_response():
return response


@APP.route('/visible-spectrum-visual')
@CACHE.cached(timeout=CACHE_DEFAULT_TIMEOUT, query_string=True)
def visible_spectrum_visual_response():
"""
Returns the visible spectrum visual response.
Returns
-------
Response
visible spectrum visual response.
"""

args = request.args
json_data = visible_spectrum_visual(
colourspace_model=args.get('colourspaceModel', COLOURSPACE_MODEL), )

response = Response(json_data, status=200, mimetype='application/json')
response.headers['X-Content-Length'] = len(json_data)

return response


@APP.route('/')
def index():
"""
Expand Down Expand Up @@ -400,4 +423,4 @@ def after_request(response):

if __name__ == '__main__':
with domain_range_scale(1):
APP.run(debug=True)
APP.run()
34 changes: 30 additions & 4 deletions colour_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
from werkzeug.contrib.cache import SimpleCache

from colour import (Lab_to_XYZ, LCHab_to_Lab, LOG_DECODING_CURVES,
from colour import (ILLUMINANTS, Lab_to_XYZ, LCHab_to_Lab, LOG_DECODING_CURVES,
POINTER_GAMUT_DATA, POINTER_GAMUT_ILLUMINANT,
OETFS_REVERSE, RGB_COLOURSPACES, RGB_to_RGB, RGB_to_XYZ,
XYZ_to_RGB, XYZ_to_JzAzBz, XYZ_to_OSA_UCS,
Expand All @@ -26,6 +26,7 @@
from colour.plotting import filter_cmfs, filter_RGB_colourspaces
from colour.utilities import (CaseInsensitiveMapping, first_item,
normalise_maximum, tsplit, tstack)
from colour.volume import XYZ_outer_surface

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2018 - Colour Developers'
Expand All @@ -43,7 +44,8 @@
'colourspace_model_faces_reorder', 'decoding_cctfs', 'colourspace_models',
'RGB_colourspaces', 'buffer_geometry', 'create_plane', 'create_box',
'image_data', 'RGB_colourspace_volume_visual', 'spectral_locus_visual',
'RGB_image_scatter_visual', 'pointer_gamut_visual'
'RGB_image_scatter_visual', 'pointer_gamut_visual',
'visible_spectrum_visual'
]

LINEAR_FILE_FORMATS = ('.exr', '.hdr')
Expand Down Expand Up @@ -963,6 +965,30 @@ def pointer_gamut_visual(colourspace_model='CIE xyY'):

vertices = np.asarray(vertices)

RGB = np.ones(vertices.shape)
return buffer_geometry(position=vertices)

return buffer_geometry(position=vertices, color=RGB)

def visible_spectrum_visual(colourspace_model='CIE xyY'):
"""
Returns the visible spectrum visual geometry formatted as *JSON*.
Parameters
----------
colourspace_model : unicode, optional
Colourspace model used to generate the visual geometry.
Returns
-------
unicode
Visible spectrum visual geometry formatted as *JSON*.
"""

XYZ = XYZ_outer_surface()
vertices = colourspace_model_axis_reorder(
XYZ_to_colourspace_model_normalised(
XYZ, ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['E'],
colourspace_model), colourspace_model)

vertices = np.array(zip(vertices, vertices[1:]))

return buffer_geometry(position=vertices)
2 changes: 1 addition & 1 deletion dist/colour-analysis.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colour-analysis",
"version": "0.1.0",
"version": "0.1.3",
"description": "Colour - Analysis",
"private": true,
"scripts": {
Expand Down
16 changes: 15 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ function isLinearFileFormat(path) {
}
}

var saveFile = function(data, filename) {
var link = document.createElement('a');
if (typeof link.download === 'string') {
document.body.appendChild(link);
link.download = filename;
link.href = data;
link.click();
document.body.removeChild(link);
} else {
location.replace(uri);
}
};

export {
serverRoute,
removeObjectByName,
Expand All @@ -135,5 +148,6 @@ export {
info,
warning,
loadingCallback,
isLinearFileFormat
isLinearFileFormat,
saveFile
};
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GamutView } from './views/gamut-view.js';
import { ImageView } from './views/image-view.js';
import { updateDropdown, dropdownOptions } from './gui.js';
import { isLinearFileFormat, info, serverRoute, warning } from './common.js';
import { isLinearFileFormat, info, saveFile, serverRoute, warning } from './common.js';

/**
* @author Colour Developers / http://colour-science.org/
Expand All @@ -14,6 +14,7 @@ export {
dropdownOptions,
isLinearFileFormat,
info,
saveFile,
serverRoute,
warning
};
34 changes: 33 additions & 1 deletion src/views/gamut-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ColourspaceVisual } from '../visuals/colourspace-visual.js';
import { ImageScatterVisual } from '../visuals/image-scatter-visual.js';
import { PointerGamutVisual } from '../visuals/pointer-gamut-visual.js';
import { SpectralLocusVisual } from '../visuals/spectral-locus-visual.js';
import { VisibleSpectrumVisual } from '../visuals/visible-spectrum-visual.js';

/**
* @author Colour Developers / http://colour-science.org/
Expand Down Expand Up @@ -89,6 +90,11 @@ class GamutView extends PerspectiveView {
this._viewAxesVisual = undefined;

// The following groups are defining the rendering order.
this._visibleSpectrumVisualGroup = new THREE.Group();
this._visibleSpectrumVisualGroup.name = 'visible-spectrum-visual-group';
this._scene.add(this._visibleSpectrumVisualGroup);
this._visibleSpectrumVisual = undefined;

this._spectralLocusVisualGroup = new THREE.Group();
this._spectralLocusVisualGroup.name = 'spectral-locus-visual-group';
this._scene.add(this._spectralLocusVisualGroup);
Expand Down Expand Up @@ -229,6 +235,10 @@ class GamutView extends PerspectiveView {
this._viewAxesVisual.colourspaceModel = value;
}

if (this._visibleSpectrumVisual != undefined) {
this._visibleSpectrumVisual.colourspaceModel = value;
}

if (this._spectralLocusVisual != undefined) {
this._spectralLocusVisual.colourspaceModel = value;
}
Expand Down Expand Up @@ -262,6 +272,14 @@ class GamutView extends PerspectiveView {
throw new Error('"viewAxesVisual" property is read only!');
}

get visibleSpectrumVisual() {
return this._visibleSpectrumVisual;
}

set visibleSpectrumVisual(value) {
throw new Error('"visibleSpectrumVisual" property is read only!');
}

get spectralLocusVisual() {
return this._spectralLocusVisual;
}
Expand Down Expand Up @@ -320,6 +338,19 @@ class GamutView extends PerspectiveView {
this._viewAxesVisual.add();
}

addVisibleSpectrumVisual(settings) {
this._visibleSpectrumVisual = new VisibleSpectrumVisual(
this._visibleSpectrumVisualGroup,
{
...{
colourspaceModel: this._colourspaceModel
},
...settings
}
);
this._visibleSpectrumVisual.add();
}

addSpectralLocusVisual(settings) {
this._spectralLocusVisual = new SpectralLocusVisual(
this._spectralLocusVisualGroup,
Expand Down Expand Up @@ -420,8 +451,9 @@ class GamutView extends PerspectiveView {
isLoading() {
return (
this._viewAxesVisual.loading ||
this._pointerGamutVisual.loading ||
this._visibleSpectrumVisual.loading ||
this._spectralLocusVisual.loading ||
this._pointerGamutVisual.loading ||
this._secondaryColourspaceVisual.loading ||
this._primaryColourspaceVisual.loading ||
this._imageScatterVisual.loading ||
Expand Down
6 changes: 6 additions & 0 deletions src/views/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class View {
this._observer.observe(this._container, {
attributes: true
});

window.addEventListener(
'resize',
this.resizeToContainer.bind(this),
Expand Down Expand Up @@ -64,6 +65,11 @@ class View {
throw new Error('"scene" property is read only!');
}

capture(){
this.render();
return this._renderer.domElement.toDataURL('image/png');
}

removeObjectByName(name) {
removeObjectByName(this._scene, name);
}
Expand Down
6 changes: 5 additions & 1 deletion src/visuals/colourspace-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class ColourspaceVisual extends Visual {

set uniformColour(value) {
this._uniformColour = value;
this.add();
Object.keys(this.cache).forEach(
function(key) {
this.cache[key].material.color = new THREE.Color(value);
}.bind(this)
);
}

get uniformOpacity() {
Expand Down
6 changes: 5 additions & 1 deletion src/visuals/image-scatter-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ class ImageScatterVisual extends Visual {

set uniformColour(value) {
this._uniformColour = value;
this.add();
Object.keys(this.cache).forEach(
function(key) {
this.cache[key].material.color = new THREE.Color(value);
}.bind(this)
);
}

get uniformOpacity() {
Expand Down
10 changes: 7 additions & 3 deletions src/visuals/pointer-gamut-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PointerGamutVisual extends Visual {
super(parent, { ...{ name: 'pointer-gamut-visual' }, ...settings });

this._colourspaceModel = settings.colourspaceModel || 'CIE xyY';
this._uniformColour = settings.uniformColour || undefined;
this._uniformColour = settings.uniformColour || 0x4fc3f7;
this._uniformOpacity = settings.uniformOpacity || 0.75;
}

Expand All @@ -29,7 +29,11 @@ class PointerGamutVisual extends Visual {

set uniformColour(value) {
this._uniformColour = value;
this.add();
Object.keys(this.cache).forEach(
function(key) {
this.cache[key].material.color = new THREE.Color(value);
}.bind(this)
);
}

get uniformOpacity() {
Expand All @@ -54,7 +58,7 @@ class PointerGamutVisual extends Visual {

create(geometry) {
var material = new THREE.LineBasicMaterial({
vertexColors: THREE.VertexColors,
color: this._uniformColour,
transparent: true,
opacity: this._uniformOpacity
});
Expand Down
6 changes: 5 additions & 1 deletion src/visuals/spectral-locus-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ class SpectralLocusVisual extends Visual {

set uniformColour(value) {
this._uniformColour = value;
this.add();
Object.keys(this.cache).forEach(
function(key) {
this.cache[key].material.color = new THREE.Color(value);
}.bind(this)
);
}

get uniformOpacity() {
Expand Down
Loading

0 comments on commit 63124a7

Please sign in to comment.