Skip to content

Conversation

@tolgraven
Copy link
Contributor

A lot faster.

Might not be quite complete, especially after rebase six years later lol.

Will try to port over some of my helpers and convenience stuff from my tolglow project, certainly makes library way more usable since config (at least fixtures and page variants for different fixture groups) becomes data driven rather than (repetitive ass) code hehe.

So could then work towards a setup where a simple config file can be used to run a show.

Copilot AI review requested due to automatic review settings December 20, 2025 13:06
@tolgraven tolgraven marked this pull request as draft December 20, 2025 13:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the color library from com.evocomputing.colors to thi.ng.color.core for performance improvements. The changes update color creation, manipulation, and conversion throughout the codebase to use the new library's API.

Key Changes:

  • Replaced color creation and manipulation functions with thi.ng equivalents across all affected files
  • Updated color value ranges from 0-100/0-255 scales to normalized 0-1 scales for HSL/RGB components
  • Modified type checking to accommodate the new color type (HSLA)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 39 comments.

Show a summary per file
File Description
src/afterglow/web/routes/show_control.clj Updated cue color calculations and display functions to use thi.ng color API with normalized values
src/afterglow/util.clj Modified contrasting text color calculation and changed default color values
src/afterglow/effects/params.clj Added thi.ng imports, updated color parameter handling and type validation
src/afterglow/effects/cues.clj Updated dynamic color parameter type validation
src/afterglow/effects/color.clj Rewrote color assignment, mixing, and transformation logic for thi.ng API
src/afterglow/effects/channel.clj Updated function assignment resolution to track state in movement atom
src/afterglow/controllers/ableton_push_2.clj Extensive updates to color handling for Push 2 display rendering and LED control

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +104 to +105
"#222"
"#edc"))
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The color values returned have changed from hex strings like "#000" and "#fff" to "#222" and "#edc". These are not functionally equivalent color values - the new values are gray and a pinkish color respectively, whereas the originals were pure black and white. If this change is intentional for aesthetic reasons, it should be documented. Otherwise, this appears to be an unintended change that could affect text readability.

Suggested change
"#222"
"#edc"))
"#000"
"#fff"))

Copilot uses AI. Check for mistakes.
(= (type color) :com.evocomputing.colors/color)
(= (type color) thi.ng.color.core.HSLA)
color
(= (type color) :com.evocomputing.colors/color) ;comparing speed
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment ";comparing speed" suggests this is experimental or temporary code. If keeping both color type checks is intentional for backwards compatibility during migration, this should be documented properly. Otherwise, the old color type check should be removed once migration is complete.

Suggested change
(= (type color) :com.evocomputing.colors/color) ;comparing speed
(= (type color) :com.evocomputing.colors/color) ; Support legacy com.evocomputing.colors/color values for backwards compatibility.

Copilot uses AI. Check for mistakes.
(->> (map clr/as-rgba [previous current])
(map deref)
(apply map max)
(apply clr/rgba)) ;get alpha support for free (when we dont need it)! but what about white
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment suggests this gives alpha support "for free (when we dont need it)" and questions "but what about white". This indicates incomplete consideration of the implementation. Alpha channel handling and white color mixing should be explicitly addressed or documented.

Copilot uses AI. Check for mistakes.
there is one, or a default black if both were nil."
[color]
(if color (colors/darken color 100.0) default-color))
(if color (clr/adjust-luminance color -1.0) default-color)) ;does nothing on this lib it resets hue but maybe someday
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment ";does nothing on this lib it resets hue but maybe someday" suggests that clr/adjust-luminance doesn't work as expected. If the function doesn't behave correctly, this needs to be fixed or an alternative approach used. Having known broken functionality is a critical issue.

Suggested change
(if color (clr/adjust-luminance color -1.0) default-color)) ;does nothing on this lib it resets hue but maybe someday
(if color
(let [hsla (clr/as-hsla color)]
;; Preserve hue, saturation, and alpha, but force lightness to 0.0 (fully dark).
(clr/hsla (clr/hue hsla) (clr/saturation hsla) 0.0 (clr/alpha hsla)))
default-color))

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +83
(defn dignify
"Return a version of a color that isn't actively offensive"
[color]
(-> color
(clr/adjust-saturation -0.2)
(clr/adjust-luminance 0.04)
(clr/rotate-hue 0.03)))
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is misspelled as "dignify" but this appears intentional based on the docstring "Return a version of a color that isn't actively offensive". However, this is an unusual function name that doesn't follow standard color manipulation naming conventions. Consider renaming to something more descriptive like "soften-color" or "mute-color".

Copilot uses AI. Check for mistakes.
[afterglow.show-context :refer [*show* with-show]]
[afterglow.util :as util]
[clojure.math.numeric-tower :as math]
[com.evocomputing.colors :as colors]
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old color library is still imported and used in this file. For a complete migration to thi.ng, all references to com.evocomputing.colors should be removed. The old library is used on lines 402, 409, and 419 (via colors/create-color), and the type :com.evocomputing.colors/color is checked on line 409. This creates an unnecessary dependency and prevents a clean migration.

Suggested change
[com.evocomputing.colors :as colors]

Copilot uses AI. Check for mistakes.
evaluates to `nil`, the non-dynamic cue color is returned."
[param]
(params/validate-param-type param :com.evocomputing.colors/color)
(params/validate-param-type param thi.ng.color.core.HSLA)
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type comparison should use instance? or a defined constant. thi.ng.color.core.HSLA as written here is not a valid type reference for the validate-param-type function.

Suggested change
(params/validate-param-type param thi.ng.color.core.HSLA)
(params/validate-param-type param thi.ng.color.core/HSLA)

Copilot uses AI. Check for mistakes.
assigners (if htp?
(build-htp-color-assigners heads color *show*)
(fx/build-head-parameter-assigners :color heads color *show*))]
(fx/build-head-parameter-assigners :color heads color *show*))] ;wont support multiple shows like this right?
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "wont support multiple shows like this right?" indicates uncertainty about the implementation. This concern should be addressed or clarified before merging.

Copilot uses AI. Check for mistakes.
(def amber-color
"The color for bright amber buttons."
(colors/create-color :h 45 :s 100 :l 50))
(clr/hsla 1/8 0.8 0.5))
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hue value is specified as 1/8 (a ratio) which equals 0.125. If hue is expected to be in the range 0-1 (as normalized), this is 45 degrees (1/8 * 360). However, the original code used :h 45 which in the old library was likely degrees. Verify that the thi.ng library expects normalized hue values (0-1) and that 1/8 is the correct conversion.

Copilot uses AI. Check for mistakes.
[overtone.at-at :refer [now]]
[thi.ng.color.core :as clr]
[org.httpkit.server :refer [with-channel on-receive on-close]]
[overtone.at-at :refer [now after]]
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new imports org.httpkit.server and the additional after function from overtone.at-at are added but don't appear to be related to the color library swap. If these are needed for other changes, they should be in a separate commit. If not needed, they should be removed.

Suggested change
[overtone.at-at :refer [now after]]
[overtone.at-at :refer [now]]

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant