Skip to content

Commit

Permalink
use native color procs (#6925)
Browse files Browse the repository at this point in the history
title, updated icon helpers
  • Loading branch information
LetterN authored Dec 18, 2024
1 parent cd9c99d commit 6a02353
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 687 deletions.
2 changes: 1 addition & 1 deletion citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "code\__DEFINES\fonts.dm"
#include "code\__DEFINES\frames.dm"
#include "code\__DEFINES\gamemode.dm"
#include "code\__DEFINES\gradient.dm"
#include "code\__DEFINES\holidays.dm"
#include "code\__DEFINES\holomap.dm"
#include "code\__DEFINES\icon_smoothing.dm"
Expand Down Expand Up @@ -428,7 +429,6 @@
#include "code\__HELPERS\game\turfs\offsets.dm"
#include "code\__HELPERS\graphs\astar.dm"
#include "code\__HELPERS\icons\alpha.dm"
#include "code\__HELPERS\icons\color.dm"
#include "code\__HELPERS\icons\download.dm"
#include "code\__HELPERS\icons\flatten.dm"
#include "code\__HELPERS\icons\hologram.dm"
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/gradient.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// spacemandmm doesn't really implement gradient() right, so let's just handle that here yeah?
#define rgb_gradient(index, args...) UNLINT(gradient(args, index))
#define hsl_gradient(index, args...) UNLINT(gradient(args, space = COLORSPACE_HSL, index))
#define hsv_gradient(index, args...) UNLINT(gradient(args, space = COLORSPACE_HSV, index))
900 changes: 257 additions & 643 deletions code/__HELPERS/icons.dm

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions code/__HELPERS/icons/color.dm

This file was deleted.

9 changes: 0 additions & 9 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1372,15 +1372,6 @@ var/list/WALLITEMS = list(
if(337.5)
return "North-Northwest"

/atom/proc/Shake(pixelshiftx = 15, pixelshifty = 15, duration = 250)
var/initialpixelx = pixel_x
var/initialpixely = pixel_y
var/shiftx = rand(-pixelshiftx,pixelshiftx)
var/shifty = rand(-pixelshifty,pixelshifty)
animate(src, pixel_x = pixel_x + shiftx, pixel_y = pixel_y + shifty, time = 0.2, loop = duration)
pixel_x = initialpixelx
pixel_y = initialpixely

/**
* get_holder_at_turf_level(): Similar to get_turf(), will return the "highest up" holder of this atom, excluding the turf.
* Example: A fork inside a box inside a locker will return the locker. Essentially, get_just_before_turf().
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/gear_painter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@

/obj/machinery/gear_painter/proc/check_valid_color(list/cm, mob/user)
if(!islist(cm)) // normal
var/list/HSV = ReadHSV(RGBtoHSV(cm))
var/list/HSV = rgb2hsv(cm)
if(HSV[3] < minimum_normal_lightness)
temp = "[cm] is too dark (Minimum lightness: [minimum_normal_lightness])"
return FALSE
Expand All @@ -294,7 +294,7 @@
// We test using full red, green, blue, and white
// A predefined number of them must pass to be considered valid
var/passed = 0
#define COLORTEST(thestring, thematrix) passed += (ReadHSV(RGBtoHSV(RGBMatrixTransform(thestring, thematrix)))[3] >= minimum_matrix_lightness)
#define COLORTEST(thestring, thematrix) passed += (rgb2hsv(RGBMatrixTransform(thestring, thematrix))[3] >= minimum_matrix_lightness)
COLORTEST("FF0000", cm)
COLORTEST("00FF00", cm)
COLORTEST("0000FF", cm)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/stream_projector/medichine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ GLOBAL_LIST_EMPTY(medichine_cell_datums)
entity_beam.segmentation.color = beam_color

/obj/item/stream_projector/medichine/proc/beam_color(color)
var/list/decoded = ReadRGB(color)
var/list/decoded = rgb2num(color)
return list(
decoded[1] / 255, decoded[2] / 255, decoded[3] / 255,
0, 0, 0,
Expand Down Expand Up @@ -539,7 +539,7 @@ GLOBAL_LIST_EMPTY(medichine_cell_datums)
var/list/color_rgb_list

/datum/medichine_cell/New()
color_rgb_list = ReadRGB(color)
color_rgb_list = rgb2num(color)
for(var/i in 1 to length(effects))
var/datum/medichine_effect/effect = effects[i]
if(istype(effect))
Expand Down
18 changes: 9 additions & 9 deletions code/game/objects/obj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@
color = colors[1]
if(COLORATION_MODE_RG_MATRIX)
ASSERT(length(colors) == 2)
var/list/red_decoded = ReadRGB(colors[1])
var/list/green_decoded = ReadRGB(colors[2])
var/list/red_decoded = rgb2num(colors[1])
var/list/green_decoded = rgb2num(colors[2])
color = list(
red_decoded[1] / 255, red_decoded[2] / 255, red_decoded[3] / 255, 0,
green_decoded[1] / 255, green_decoded[2] / 255, green_decoded[3] / 255, 0,
Expand All @@ -629,8 +629,8 @@
)
if(COLORATION_MODE_GB_MATRIX)
ASSERT(length(colors) == 2)
var/list/green_decoded = ReadRGB(colors[1])
var/list/blue_decoded = ReadRGB(colors[2])
var/list/green_decoded = rgb2num(colors[1])
var/list/blue_decoded = rgb2num(colors[2])
color = list(
0, 0, 0, 0,
green_decoded[1] / 255, green_decoded[2] / 255, green_decoded[3] / 255, 0,
Expand All @@ -639,8 +639,8 @@
)
if(COLORATION_MODE_RB_MATRIX)
ASSERT(length(colors) == 2)
var/list/red_decoded = ReadRGB(colors[1])
var/list/blue_decoded = ReadRGB(colors[2])
var/list/red_decoded = rgb2num(colors[1])
var/list/blue_decoded = rgb2num(colors[2])
color = list(
red_decoded[1] / 255, red_decoded[2] / 255, red_decoded[3] / 255, 0,
0, 0, 0, 0,
Expand All @@ -649,9 +649,9 @@
)
if(COLORATION_MODE_RGB_MATRIX)
ASSERT(length(colors) == 3)
var/list/red_decoded = ReadRGB(colors[1])
var/list/green_decoded = ReadRGB(colors[2])
var/list/blue_decoded = ReadRGB(colors[3])
var/list/red_decoded = rgb2num(colors[1])
var/list/green_decoded = rgb2num(colors[2])
var/list/blue_decoded = rgb2num(colors[3])
color = list(
red_decoded[1] / 255, red_decoded[2] / 255, red_decoded[3] / 255, 0,
green_decoded[1] / 255, green_decoded[2] / 255, green_decoded[3] / 255, 0,
Expand Down
4 changes: 2 additions & 2 deletions code/modules/integrated_electronics/subtypes/converters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@
/obj/item/integrated_circuit/converter/hsv2hex
name = "hsv to hexadecimal converter"
desc = "This circuit can convert a HSV (Hue, Saturation, and Value) color to a Hexadecimal RGB color."
extended_desc = "The first pin controls tint (0-359), the second pin controls how intense the tint is (0-255), \
extended_desc = "The first pin controls tint (0-360), the second pin controls how intense the tint is (0-255), \
and the third controls how bright the tint is (0 for black, 127 for normal, 255 for white)."
icon_state = "hsv-hex"
inputs = list(
Expand All @@ -476,7 +476,7 @@
var/saturation = get_pin_data(IC_INPUT, 2)
var/value = get_pin_data(IC_INPUT, 3)
if(isnum(hue) && isnum(saturation) && isnum(value))
result = HSVtoRGB(hsv(AngleToHue(hue),saturation,value))
result = hsv2rgb(list(hue, saturation, value))

set_pin_data(IC_OUTPUT, 1, result)
push_data()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/rendering.dm
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@
if(husk)
base_icon.ColorTone(husk_color_mod)
else if(hulk)
var/list/tone = ReadRGB(hulk_color_mod)
var/list/tone = rgb2num(hulk_color_mod)
base_icon.MapColors(rgb(tone[1],0,0),rgb(0,tone[2],0),rgb(0,0,tone[3]))

// Handle husk overlay.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/sprite_accessories/sprite_accessory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ GLOBAL_LIST_EMPTY(sprite_accessory_icon_cache)
continue
if(!istext(colors[i]))
stack_trace("attempted to use non-text color string with legacy additive; this is not supported.")
var/list/decoded = ReadRGB(colors[i])
var/list/decoded = rgb2num(colors[i])
var/list/computed = list(
1, 0, 0,
0, 1, 0,
Expand Down

0 comments on commit 6a02353

Please sign in to comment.