Skip to content

Commit 05146a8

Browse files
committed
Add -mod100 to default Mandelbrot plot, and use plot forcedDefaults
In order to not apply this "-mod100" to the default gradient for sequence plots (when the plot name and URL version param are included, but no gradient is included, in the user's entered URL params) use a different default gradient, without "-mod100" when the plot is a sequence plot. Also use the user-specified plot's "forcedDefaults" to override the default params. If, for example, the user omits the "n" (iterations) parameter from the URL, a sensible default for the plot is used. Previously, the mandelbrot default n=60 would be used, which is not a good default at all for the "Primes-1-Step-90-turn" plot.
1 parent 79bab75 commit 05146a8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

paint.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,12 @@ function parseUrlParams() {
792792
"mag": infNum(1n, 0n),
793793
"centerX": createInfNum("-0.65"),
794794
"centerY": infNum(0n, 0n),
795-
"gradient": "Bbgoyw", // do not include -mod option, which would break sequence plots
795+
// for default mandelbrot set plot, include -mod100 by default to allow
796+
// more zooming for default mandelbrot plot
797+
// if a sequence plot is specified by the URL params, without a
798+
// gradient, a different default gradient will be used below
799+
// since sequence plots cannot use -mod gradients
800+
"gradient": "Bbgoyw-mod100",
796801
"bgColor": "b",
797802
"smooth": "on-show"
798803
};
@@ -811,6 +816,13 @@ function parseUrlParams() {
811816
alert("no such plot [" + plotName + "]");
812817
}
813818
const plot = plotsByName[plotName];
819+
// set a different default gradient for sequence plots
820+
if (plot.calcFrom != "window") {
821+
params.gradient = "Bbgoyw"; // do not include -mod option, which would break sequence plots
822+
}
823+
// override the default params above (which are mandelbrot defaults)
824+
// with any "forcedDefaults" specified by the plot
825+
params = Object.assign(params, plot.forcedDefaults);
814826
if (urlParams.has('n')) {
815827
params.n = parseInt(urlParams.get('n').replaceAll(",", ""));
816828
if (params.n < 0) {

plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ const plots = [{
921921
},
922922
// these settings are auto-applied when this plot is activated
923923
"forcedDefaults": {
924-
"n": 40,
924+
"n": 100,
925925
"mag": infNum(1n, 0n),
926926
"centerX": createInfNum("-0.65"),
927927
"centerY": infNum(0n, 0n)

0 commit comments

Comments
 (0)