Store color in one int #1

Closed
opened 2022-11-04 17:16:18 +01:00 by linuskmr · 1 comment
linuskmr commented 2022-11-04 17:16:18 +01:00 (Migrated from github.com)

This code stores a color in its three parts; red, green, and blue.

54eb509d4f/src/models/light.py (L4-L11)

I propose to store the color in a single int, and add getters for the red, green and blue parts.

This code extracts the red, green and blue parts from a color stored in a single int.

r, g, b = color >> 16, color >> 8 & 0xff, color & 0xff
This code stores a color in its three parts; red, green, and blue. https://github.com/mgfcf/MaSH/blob/54eb509d4fc4fc6ca7e0e435e382cbc47956f1df/src/models/light.py#L4-L11 I propose to store the color in a single `int`, and add getters for the red, green and blue parts. This code extracts the red, green and blue parts from a color stored in a single int. ```python3 r, g, b = color >> 16, color >> 8 & 0xff, color & 0xff ```
m.giller added the
enhancement
label 2024-02-06 20:20:21 +01:00

Readability and clarity have priority for now. This potential performance improvement will therefor be closed for now.

Readability and clarity have priority for now. This potential performance improvement will therefor be closed for now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: m.giller/mash-server#1
No description provided.