jspsych-tangram 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,12 @@ declare const info: {
16
16
  default: never[];
17
17
  description: string;
18
18
  };
19
+ /** Array of primitive names in the order they should be displayed */
20
+ primitive_order: {
21
+ type: ParameterType;
22
+ default: string[];
23
+ description: string;
24
+ };
19
25
  /** Whether to place pieces in workspace or directly on silhouette */
20
26
  target: {
21
27
  type: ParameterType;
@@ -118,6 +124,12 @@ declare class TangramConstructPlugin implements JsPsychPlugin<Info> {
118
124
  default: never[];
119
125
  description: string;
120
126
  };
127
+ /** Array of primitive names in the order they should be displayed */
128
+ primitive_order: {
129
+ type: ParameterType;
130
+ default: string[];
131
+ description: string;
132
+ };
121
133
  /** Whether to place pieces in workspace or directly on silhouette */
122
134
  target: {
123
135
  type: ParameterType;
@@ -6,26 +6,27 @@ import { v4 } from 'uuid';
6
6
  const CONFIG = {
7
7
  color: {
8
8
  bands: {
9
- silhouette: { fillEven: "#eef2ff", fillOdd: "#f6f7fb", stroke: "#c7d2fe" },
10
- workspace: { fillEven: "#f3f4f6", fillOdd: "#f9fafb", stroke: "#e5e7eb" }
9
+ silhouette: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" },
10
+ workspace: { fillEven: "#fff2ccff", fillOdd: "#fff2ccff", stroke: "#b1b1b1" }
11
11
  },
12
- completion: { fill: "#dcfce7", stroke: "#86efac" },
13
- silhouetteMask: "#94a3b8",
12
+ completion: { fill: "#ccfff2", stroke: "#13da57" },
13
+ silhouetteMask: "#374151",
14
14
  anchors: { invalid: "#7dd3fc", valid: "#475569" },
15
- piece: { draggingFill: "#1d4ed8", validFill: "#60a5fa", invalidFill: "#ef4444", invalidStroke: "#dc2626", selectedStroke: "#111827", allGreenStroke: "#86efac", borderStroke: "#374151" },
15
+ piece: { draggingFill: "#8e7cc3ff", validFill: "#8e7cc3ff", invalidFill: "#ef4444", invalidStroke: "#dc2626", selectedStroke: "#674ea7", allGreenStroke: "#86efac", borderStroke: "#674ea7" },
16
16
  ui: { light: "#60a5fa", dark: "#1d4ed8" },
17
- blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#eef2ff", labelFill: "#374151" }
17
+ blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#000000", labelFill: "#ffffff" }
18
18
  },
19
19
  opacity: {
20
- blueprint: 0.95,
21
- silhouetteMask: 0.45,
22
- anchors: { valid: 0.8, invalid: 0.5 },
23
- piece: { invalid: 0.35, dragging: 0.6, locked: 0.7, normal: 0.95 }
20
+ blueprint: 0.4,
21
+ silhouetteMask: 0.25,
22
+ //anchors: { valid: 0.80, invalid: 0.50 },
23
+ anchors: { invalid: 0, valid: 0 },
24
+ piece: { invalid: 0.35, dragging: 0.75, locked: 1, normal: 1 }
24
25
  },
25
26
  size: {
26
- stroke: { bandPx: 1, pieceSelectedPx: 1.5, allGreenStrokePx: 6, pieceBorderPx: 1 },
27
+ stroke: { bandPx: 5, pieceSelectedPx: 3, allGreenStrokePx: 10, pieceBorderPx: 2 },
27
28
  anchorRadiusPx: { valid: 1, invalid: 1 },
28
- badgeFontPx: 12,
29
+ badgeFontPx: 16,
29
30
  centerBadge: { fractionOfOuterR: 0.15, minPx: 20, marginPx: 4 }
30
31
  },
31
32
  layout: {
@@ -3547,6 +3548,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3547
3548
  "medtriangle",
3548
3549
  "largetriangle"
3549
3550
  ]);
3551
+ const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => params.primitiveOrder.indexOf(a.kind) - params.primitiveOrder.indexOf(b.kind));
3550
3552
  const sectors = params.tangrams.map((tangramSpec, index) => {
3551
3553
  const filteredTans = tangramSpec.solutionTans.filter((tan) => {
3552
3554
  const tanName = tan.name ?? tan.kind;
@@ -3573,7 +3575,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3573
3575
  const firstMacro = params.quickstash_macros[0];
3574
3576
  if (firstMacro && "parts" in firstMacro && firstMacro.parts && firstMacro.parts[0] && "anchorOffset" in firstMacro.parts[0]) {
3575
3577
  const primsByKind = /* @__PURE__ */ new Map();
3576
- PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
3578
+ PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
3577
3579
  quickstash = params.quickstash_macros.map(
3578
3580
  (anchorComposite) => convertAnchorCompositeToPixels(anchorComposite, primsByKind, CONFIG.layout.grid.stepPx)
3579
3581
  // Use current CONFIG grid step
@@ -3585,7 +3587,7 @@ function startConstructionTrial(display_element, params, _jsPsych) {
3585
3587
  const gameBoardProps = {
3586
3588
  sectors,
3587
3589
  quickstash,
3588
- primitives: PRIMITIVE_BLUEPRINTS,
3590
+ primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
3589
3591
  layout: params.layout,
3590
3592
  target: params.target,
3591
3593
  input: params.input,
@@ -3616,6 +3618,12 @@ const info = {
3616
3618
  default: [],
3617
3619
  description: "Array of MacroSpec objects created in prep trial"
3618
3620
  },
3621
+ /** Array of primitive names in the order they should be displayed */
3622
+ primitive_order: {
3623
+ type: ParameterType.OBJECT,
3624
+ default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
3625
+ description: "Array of primitive names in the order they should be displayed"
3626
+ },
3619
3627
  /** Whether to place pieces in workspace or directly on silhouette */
3620
3628
  target: {
3621
3629
  type: ParameterType.SELECT,
@@ -3717,6 +3725,7 @@ class TangramConstructPlugin {
3717
3725
  const params = {
3718
3726
  tangrams: trial.tangrams,
3719
3727
  quickstash_macros: trial.quickstash_macros,
3728
+ primitiveOrder: trial.primitive_order,
3720
3729
  target: trial.target,
3721
3730
  input: trial.input,
3722
3731
  layout: trial.layout,