Skip to content

Commit

Permalink
Issue #100 fixed tests, haven't implemented set colours yet
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Jul 8, 2022
1 parent 3ff9665 commit 35d58ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions sksurgerybard/visualisation/bard_visualisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def luminance_change(self, y_pos):
Changes the luminance of one of the actors
"""
print("Got signal to change luminance of actor, ", y_pos)
print("Yellow = ", get_yellow(y_pos))
print("green = ", get_green(y_pos))
for actor in self._target_anatomy_actors:
print("Changing luminance for actor ", actor)

Expand Down
11 changes: 6 additions & 5 deletions sksurgerybard/visualisation/colours.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# from here
# Grayscale Design palette: https://grayscale.design/app?lums=100.00,88.89,77.78,66.67,55.56,44.44,33.33,22.22,11.11,0.00&palettes=%23ffff00,%2300ff00&filters=0%7C0,0%7C0&names=Yellow,Greeen&labels=,
# Grayscale Design palette: https://grayscale.design/app

#lets create dictionaries we can use of pre set colours
grayscale = {
Expand Down Expand Up @@ -47,7 +47,7 @@

def y_pos_to_luminance(y_pos):
"""
y_pos is a float between 0 and 1 representing the position of the
y_pos is a float between 0 and 1 representing the position of the
mouse on the screen. High y_pos corresponds to high luminance (50)
low y_pos to low luminance (900)
"""
Expand All @@ -70,14 +70,15 @@ def integer_colour_to_float(colour):
"""
out=[]
for value in colour:
out.append((value)/256.0)
out.append((value)/255.0)

return out



def get_green(y_pos):
return green.get(y_pos_to_luminance(y_pos))
"""Gets a green shade with luminace set by y_pos"""
return integer_colour_to_float(green.get(y_pos_to_luminance(y_pos)))

def get_yellow(y_pos):
"""Gets a yellow shade with luminace set by y_pos"""
return integer_colour_to_float(yellow.get(y_pos_to_luminance(y_pos)))
6 changes: 1 addition & 5 deletions tests/visualisation/test_colours.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
"""Tests for BARD pointer module"""
import pytest
import vtk
import numpy as np
from sksurgerycore.transforms.transform_manager import TransformManager
import sksurgerybard.visualisation.colours as cls

#pylint:disable=no-member
Expand All @@ -27,7 +23,7 @@ def test_y_pos_to_luminance():

def test_integer_colour_to_float():
"""Tests that integer to float colour works"""
assert cls.integer_colour_to_float([255,128,0]) == [1.0, 0.5, 0.0]
assert cls.integer_colour_to_float([255,51,0]) == [1.0, 0.2, 0.0]

def test_get_yellow():
"""Checks that get yellow returns the right value"""
Expand Down

0 comments on commit 35d58ee

Please sign in to comment.