sorcery  Diff

Differences From Artifact [818d3ded97]:

  • File lib/color.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 5988) [annotate] [blame] [check-ins using]

To Artifact [9a1b399926]:


   160    160   				-- print("r"..self.red.."g"..self.green.."b"..self.blue.." is h"..hue.."s"..saturation.."l"..luminosity)
   161    161   				local temp = from_hsl({hue=hue,saturation=saturation,luminosity=luminosity},self.alpha)
   162    162   				-- print("back is r"..temp.red.."g"..temp.green.."b"..temp.blue)
   163    163   				return { hue = hue, saturation = saturation, luminosity = luminosity }
   164    164   			end;
   165    165   
   166    166   			readable = function(self, target)
   167         -				target = target or 0.5
          167  +				target = target or 0.6
   168    168   				local hsl = self:to_hsl()
   169    169   				hsl.luminosity = target
          170  +				local worstHue = 230
          171  +				local nearness = math.abs(worstHue - hsl.hue)
          172  +				if nearness <= 70 then
          173  +					local boost = 1.0 - (nearness / 70)
          174  +					hsl.luminosity = math.min(1, hsl.luminosity * (1 + (boost*0.4)))
          175  +				end
          176  +
   170    177   				return from_hsl(hsl, self.alpha)
   171    178   			end;
   172    179   
   173    180   			bg = function(self, text) return
   174    181   				text .. minetest.get_background_escape_sequence(self:hex())
   175    182   			end;
   176    183   
................................................................................
   181    188   			brighten = function(self, fac)
   182    189   				-- Use HSL to brighten
   183    190   				-- To HSL
   184    191   				local hsl = self:to_hsl()
   185    192   				-- Do the calculation, clamp to 0-1 instead of the clamp fn
   186    193   				hsl.luminosity = math.min(math.max(hsl.luminosity * fac, 0), 1)
   187    194   				-- Turn back into RGB color
   188         -				local t = from_hsl(hsl, self.alpha)
          195  +				-- local t = from_hsl(hsl, self.alpha)
          196  +				-- print("darker is r"..hsl.red.."g"..hsl.green.."b"..hsl.blue)
   189    197   				-- print("brighten is r"..t.red.."g"..t.green.."b"..t.blue)
   190    198   				return from_hsl(hsl, self.alpha)
   191    199   			end;
   192    200   
   193    201   			darken = warp(function(new, fac)
   194    202   				-- TODO: is there any point to this being different than brighten? Probably especially not now.
   195    203   				new.red = clip(new.red - (new.red * fac))