From cde6514619ca8afa7a86715a55cd625c2ac3d0fd Mon Sep 17 00:00:00 2001 From: Luke Wilson Date: Sun, 2 Oct 2022 16:16:04 +0100 Subject: [PATCH 1/3] hsl --- libraries/colour.js | 3 ++- libraries/habitat-embed.js | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/colour.js b/libraries/colour.js index 7bd4546..3e7a263 100644 --- a/libraries/colour.js +++ b/libraries/colour.js @@ -46040,4 +46040,5 @@ const PREBUILT_BORDER_COLOURS = [] PREBUILT_BORDER_COLOURS[999] = colour } -Colour.cache = PREBUILT_COLOURS \ No newline at end of file +Colour.splash() +//Colour.cache = PREBUILT_COLOURS \ No newline at end of file diff --git a/libraries/habitat-embed.js b/libraries/habitat-embed.js index 3625512..dab6fa2 100644 --- a/libraries/habitat-embed.js +++ b/libraries/habitat-embed.js @@ -139,11 +139,11 @@ const Habitat = {} const greenId = parseInt(string[1]) const blueId = parseInt(string[2]) - const red = reds[redId] - const green = greens[greenId] - const blue = blues[blueId] + const red = Math.floor((reds[redId] / 255) * 360 + 200) + const green = Math.floor(greens[greenId] / 255 * 100) + const blue = Math.floor(blues[blueId] / 255 * 100) - const rgb = `rgb(${red}, ${green}, ${blue})` + const rgb = `hsl(${red}, ${green}%, ${blue}%)` const colour = Habitat.Colour.make(rgb) colour.splash = style @@ -334,7 +334,7 @@ const Habitat = {} Habitat.Colour.Void = Habitat.Colour.make("rgb(6, 7, 10)") Habitat.Colour.Black = Habitat.Colour.make(000) - Habitat.Colour.Grey = Habitat.Colour.make(112) + Habitat.Colour.Grey = Habitat.Colour.make(11) Habitat.Colour.Silver = Habitat.Colour.make(556) Habitat.Colour.White = Habitat.Colour.make(888) From 1033e192b0fb41535d6badb42d83e217a5fa19d4 Mon Sep 17 00:00:00 2001 From: Luke Wilson Date: Sun, 2 Oct 2022 16:19:02 +0100 Subject: [PATCH 2/3] wraparound hue! --- libraries/habitat-embed.js | 2 +- the-one-true-todey-file-of-cellpond.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/habitat-embed.js b/libraries/habitat-embed.js index dab6fa2..a4bbedc 100644 --- a/libraries/habitat-embed.js +++ b/libraries/habitat-embed.js @@ -335,7 +335,7 @@ const Habitat = {} Habitat.Colour.Void = Habitat.Colour.make("rgb(6, 7, 10)") Habitat.Colour.Black = Habitat.Colour.make(000) Habitat.Colour.Grey = Habitat.Colour.make(11) - Habitat.Colour.Silver = Habitat.Colour.make(556) + Habitat.Colour.Silver = Habitat.Colour.make(956) Habitat.Colour.White = Habitat.Colour.make(888) Habitat.Colour.Green = Habitat.Colour.make(293) diff --git a/the-one-true-todey-file-of-cellpond.js b/the-one-true-todey-file-of-cellpond.js index 448349e..6a15f97 100644 --- a/the-one-true-todey-file-of-cellpond.js +++ b/the-one-true-todey-file-of-cellpond.js @@ -2354,7 +2354,7 @@ on.load(() => { const choices = new Set() for (const augendChoice of augendChoices) { for (const addendChoice of addendChoices) { - const choice = clamp(augendChoice + addendChoice*multiplier, 0, 9) + const choice = wrap(augendChoice + addendChoice*multiplier, 0, 9) choices.add(choice) } } From ef6f6f27aa342e29da2463bbcb5f9f25a8397490 Mon Sep 17 00:00:00 2001 From: Luke Wilson Date: Sun, 2 Oct 2022 16:44:51 +0100 Subject: [PATCH 3/3] wrap only hue --- the-one-true-todey-file-of-cellpond.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/the-one-true-todey-file-of-cellpond.js b/the-one-true-todey-file-of-cellpond.js index 6a15f97..68a9cd7 100644 --- a/the-one-true-todey-file-of-cellpond.js +++ b/the-one-true-todey-file-of-cellpond.js @@ -1595,12 +1595,13 @@ on.load(() => { } let results = VARIABLE_EVALUATOR[number.variable](number, args) + const isHue = number.variable === "red" if (number.add !== undefined) { - results = addChannelToResults(results, number.add, {source: args.source, multiplier: 1}) + results = addChannelToResults(results, number.add, {source: args.source, multiplier: 1, isHue}) } if (number.subtract !== undefined) { - results = addChannelToResults(results, number.subtract, {source: args.source, multiplier: -1}) + results = addChannelToResults(results, number.subtract, {source: args.source, multiplier: -1, isHue}) } return results @@ -2317,11 +2318,12 @@ on.load(() => { const channel = cell.content.channels[i] if (channel.variable === undefined) continue let results = VARIABLE_EVALUATOR[channel.variable](channel, {source}) + const isHue = channel.variable === "red" if (channel.add !== undefined) { - results = addChannelToResults(results, channel.add, {source, multiplier: 1}) + results = addChannelToResults(results, channel.add, {source, multiplier: 1, isHue}) } if (channel.subtract !== undefined) { - results = addChannelToResults(results, channel.subtract, {source, multiplier: -1}) + results = addChannelToResults(results, channel.subtract, {source, multiplier: -1, isHue}) } const choices = results.map((v, i) => v === true? i : false).filter(v => v !== false) const newPart = choices[Random.Uint8 % choices.length] @@ -2342,7 +2344,7 @@ on.load(() => { } DRAGON_INSTRUCTION.recolour.type = "RECOLOUR" - const addChannelToResults = (augendResults, addend, {source, multiplier = 1}) => { + const addChannelToResults = (augendResults, addend, {source, multiplier = 1, isHue = false}) => { let addendResults = addend.values if (addend.variable !== undefined) { addendResults = VARIABLE_EVALUATOR[addend.variable](addend, {source}) @@ -2354,7 +2356,7 @@ on.load(() => { const choices = new Set() for (const augendChoice of augendChoices) { for (const addendChoice of addendChoices) { - const choice = wrap(augendChoice + addendChoice*multiplier, 0, 9) + const choice = isHue? wrap(augendChoice + addendChoice*multiplier, 0, 9) : clamp(augendChoice + addendChoice*multiplier, 0, 9) choices.add(choice) } } @@ -2365,11 +2367,11 @@ on.load(() => { } if (addend.add !== undefined) { - results = addChannelToResults(results, addend.add, {source, multiplier: 1}) + results = addChannelToResults(results, addend.add, {source, multiplier: 1, isHue}) } if (addend.subtract !== undefined) { - results = addChannelToResults(results, addend.add, {source, multiplier: -1}) + results = addChannelToResults(results, addend.add, {source, multiplier: -1, isHue}) } return results