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
161
162
163
164
165
166
167
168
169







170
171
172
173
174
175
176
...
181
182
183
184
185
186
187
188

189
190
191
192
193
194
195
				-- print("r"..self.red.."g"..self.green.."b"..self.blue.." is h"..hue.."s"..saturation.."l"..luminosity)
				local temp = from_hsl({hue=hue,saturation=saturation,luminosity=luminosity},self.alpha)
				-- print("back is r"..temp.red.."g"..temp.green.."b"..temp.blue)
				return { hue = hue, saturation = saturation, luminosity = luminosity }
			end;

			readable = function(self, target)
				target = target or 0.5
				local hsl = self:to_hsl()
				hsl.luminosity = target







				return from_hsl(hsl, self.alpha)
			end;

			bg = function(self, text) return
				text .. minetest.get_background_escape_sequence(self:hex())
			end;

................................................................................
			brighten = function(self, fac)
				-- Use HSL to brighten
				-- To HSL
				local hsl = self:to_hsl()
				-- Do the calculation, clamp to 0-1 instead of the clamp fn
				hsl.luminosity = math.min(math.max(hsl.luminosity * fac, 0), 1)
				-- Turn back into RGB color
				local t = from_hsl(hsl, self.alpha)

				-- print("brighten is r"..t.red.."g"..t.green.."b"..t.blue)
				return from_hsl(hsl, self.alpha)
			end;

			darken = warp(function(new, fac)
				-- TODO: is there any point to this being different than brighten? Probably especially not now.
				new.red = clip(new.red - (new.red * fac))







|


>
>
>
>
>
>
>







 







|
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
				-- print("r"..self.red.."g"..self.green.."b"..self.blue.." is h"..hue.."s"..saturation.."l"..luminosity)
				local temp = from_hsl({hue=hue,saturation=saturation,luminosity=luminosity},self.alpha)
				-- print("back is r"..temp.red.."g"..temp.green.."b"..temp.blue)
				return { hue = hue, saturation = saturation, luminosity = luminosity }
			end;

			readable = function(self, target)
				target = target or 0.6
				local hsl = self:to_hsl()
				hsl.luminosity = target
				local worstHue = 230
				local nearness = math.abs(worstHue - hsl.hue)
				if nearness <= 70 then
					local boost = 1.0 - (nearness / 70)
					hsl.luminosity = math.min(1, hsl.luminosity * (1 + (boost*0.4)))
				end

				return from_hsl(hsl, self.alpha)
			end;

			bg = function(self, text) return
				text .. minetest.get_background_escape_sequence(self:hex())
			end;

................................................................................
			brighten = function(self, fac)
				-- Use HSL to brighten
				-- To HSL
				local hsl = self:to_hsl()
				-- Do the calculation, clamp to 0-1 instead of the clamp fn
				hsl.luminosity = math.min(math.max(hsl.luminosity * fac, 0), 1)
				-- Turn back into RGB color
				-- local t = from_hsl(hsl, self.alpha)
				-- print("darker is r"..hsl.red.."g"..hsl.green.."b"..hsl.blue)
				-- print("brighten is r"..t.red.."g"..t.green.."b"..t.blue)
				return from_hsl(hsl, self.alpha)
			end;

			darken = warp(function(new, fac)
				-- TODO: is there any point to this being different than brighten? Probably especially not now.
				new.red = clip(new.red - (new.red * fac))