✨ Moved debug formatting to debug plugin
This commit is contained in:
parent
7f7688c566
commit
74ef91fe08
3 changed files with 10 additions and 36 deletions
|
@ -39,7 +39,7 @@ Part.prototype.macroClosure = function(args) {
|
|||
self[macro](args);
|
||||
} else {
|
||||
self.debug(
|
||||
utils.debugStyle("warning", "🔎 Macro not found"),
|
||||
{ style: "warning", label: "🔍 Macro not found" },
|
||||
`Macro ${macro.substr(7)} is not registered`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { macroName, debugStyle, round, sampleStyle } from "./utils";
|
||||
import { macroName, round, sampleStyle } from "./utils";
|
||||
import Part from "./part";
|
||||
import Point from "./point";
|
||||
import Path from "./path";
|
||||
|
@ -156,7 +156,6 @@ Pattern.prototype.sampleOption = function(optionName) {
|
|||
let parts = this.sampleParts();
|
||||
let option = this.config.options[optionName];
|
||||
if (typeof option.list === "object") {
|
||||
console.log("sampling list");
|
||||
return this.sampleListOption(optionName);
|
||||
}
|
||||
if (typeof option.min === "undefined" || typeof option.max === "undefined") {
|
||||
|
@ -170,7 +169,7 @@ Pattern.prototype.sampleOption = function(optionName) {
|
|||
for (let run = 1; run < 11; run++) {
|
||||
this.options[optionName] = val;
|
||||
this.debug(
|
||||
debugStyle("info", "🔬 Sample run"),
|
||||
{ style: "info", label: "🔬 Sample run" },
|
||||
`Sampling option ${optionName} with value ${round(val)}`
|
||||
);
|
||||
this.sampleRun(parts, anchors, run, 10);
|
||||
|
@ -190,7 +189,7 @@ Pattern.prototype.sampleListOption = function(optionName) {
|
|||
for (let val of option.list) {
|
||||
this.options[optionName] = val;
|
||||
this.debug(
|
||||
debugStyle("info", "🔬 Sample run"),
|
||||
{ style: "info", label: "🔬 Sample run" },
|
||||
`Sampling option ${optionName} with value ${round(val)}`
|
||||
);
|
||||
this.sampleRun(parts, anchors, run, runs);
|
||||
|
@ -214,7 +213,7 @@ Pattern.prototype.sampleMeasurement = function(measurementName) {
|
|||
for (let run = 1; run < 11; run++) {
|
||||
this.settings.measurements[measurementName] = val;
|
||||
this.debug(
|
||||
debugStyle("info", "🔬 Sample run"),
|
||||
{ style: "info", label: "🔬 Sample run" },
|
||||
`Sampling measurement ${measurementName} with value ${round(val)}`
|
||||
);
|
||||
this.sampleRun(parts, anchors, run, 10);
|
||||
|
@ -236,7 +235,10 @@ Pattern.prototype.sampleModels = function(models, focus = false) {
|
|||
for (let l in models) {
|
||||
run++;
|
||||
this.settings.measurements = models[l];
|
||||
this.debug(debugStyle("info", "🔬 Sample run"), `Sampling model ${l}`);
|
||||
this.debug(
|
||||
{ style: "info", label: "🔬 Sample run" },
|
||||
`Sampling model ${l}`
|
||||
);
|
||||
let className = l === focus ? "sample-focus" : "";
|
||||
this.sampleRun(parts, anchors, run, runs, className);
|
||||
}
|
||||
|
@ -276,7 +278,7 @@ Pattern.prototype.on = function(hook, method) {
|
|||
|
||||
Pattern.prototype.with = function(plugin) {
|
||||
this.debug(
|
||||
debugStyle("success", "🔌 Plugin loaded"),
|
||||
{ style: "success", label: "🔌 Plugin loaded" },
|
||||
`${plugin.name} v${plugin.version}`
|
||||
);
|
||||
if (plugin.hooks) this.loadPluginHooks(plugin);
|
||||
|
|
28
src/utils.js
28
src/utils.js
|
@ -2,34 +2,6 @@ import Point from "./point";
|
|||
import Attributes from "./attributes";
|
||||
import Bezier from "bezier-js";
|
||||
|
||||
/* Returns an object to style debug output */
|
||||
export function debugStyle(type, text) {
|
||||
const color = {
|
||||
info: "#FFF",
|
||||
warning: "#FFF",
|
||||
error: "#FFF",
|
||||
success: "#FFF"
|
||||
};
|
||||
const background = {
|
||||
info: "#29ABE0",
|
||||
warning: "#F47C3C",
|
||||
error: "#d9534f",
|
||||
success: "#4caf50"
|
||||
};
|
||||
let style = new Attributes();
|
||||
style.set("color", color[type]);
|
||||
style.set("background", background[type]);
|
||||
style.set("font-weight", "bold;");
|
||||
style.set("padding", "5px");
|
||||
style.set("border-radius", "10px");
|
||||
|
||||
return {
|
||||
debug: "custom",
|
||||
text,
|
||||
style: style.renderAsCss()
|
||||
};
|
||||
}
|
||||
|
||||
/** Returns internal hook name for a macro */
|
||||
export function macroName(name) {
|
||||
return `_macro_${name}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue