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.
@@ -40,6 +40,12 @@ declare const info: {
40
40
  default: never[];
41
41
  description: string;
42
42
  };
43
+ /** Array of primitive names in the order they should be displayed */
44
+ primitive_order: {
45
+ type: ParameterType;
46
+ default: string[];
47
+ description: string;
48
+ };
43
49
  /** Callback fired after each interaction (optional analytics hook) */
44
50
  onInteraction: {
45
51
  type: ParameterType;
@@ -109,6 +115,12 @@ declare class TangramPrepPlugin implements JsPsychPlugin<Info> {
109
115
  default: never[];
110
116
  description: string;
111
117
  };
118
+ /** Array of primitive names in the order they should be displayed */
119
+ primitive_order: {
120
+ type: ParameterType;
121
+ default: string[];
122
+ description: string;
123
+ };
112
124
  /** Callback fired after each interaction (optional analytics hook) */
113
125
  onInteraction: {
114
126
  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: {
@@ -3548,9 +3549,11 @@ function startPrepTrial(display_element, params, jsPsych) {
3548
3549
  layoutMode,
3549
3550
  requireAllSlots,
3550
3551
  quickstashMacros,
3552
+ primitiveOrder,
3551
3553
  onInteraction,
3552
3554
  onTrialEnd
3553
3555
  } = params;
3556
+ const PRIMITIVE_BLUEPRINTS_ORDERED = [...PRIMITIVE_BLUEPRINTS].sort((a, b) => primitiveOrder.indexOf(a.kind) - primitiveOrder.indexOf(b.kind));
3554
3557
  const prepSectors = Array.from({ length: numQuickstashSlots }, (_, i) => ({
3555
3558
  id: `prep-sector-${i}`,
3556
3559
  tangramId: `prep-sector-${i}`,
@@ -3564,7 +3567,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3564
3567
  const handleControllerReady = (controller, layout, force) => {
3565
3568
  if (quickstashMacros && quickstashMacros.length > 0 && layout) {
3566
3569
  const primsByKind = /* @__PURE__ */ new Map();
3567
- PRIMITIVE_BLUEPRINTS.forEach((p) => primsByKind.set(p.kind, p));
3570
+ PRIMITIVE_BLUEPRINTS_ORDERED.forEach((p) => primsByKind.set(p.kind, p));
3568
3571
  quickstashMacros.forEach((anchorComposite, macroIndex) => {
3569
3572
  const sectorId = `prep-sector-${macroIndex}`;
3570
3573
  const compositeBlueprint = convertAnchorCompositeToPixels(
@@ -3621,7 +3624,7 @@ function startPrepTrial(display_element, params, jsPsych) {
3621
3624
  sectors: prepSectors,
3622
3625
  quickstash: [],
3623
3626
  // No pre-made macros
3624
- primitives: PRIMITIVE_BLUEPRINTS,
3627
+ primitives: PRIMITIVE_BLUEPRINTS_ORDERED,
3625
3628
  layout: layoutMode,
3626
3629
  target: "workspace",
3627
3630
  // Pieces go in sectors
@@ -3682,6 +3685,12 @@ const info = {
3682
3685
  default: [],
3683
3686
  description: "Array of AnchorComposite objects to edit as primitive pieces"
3684
3687
  },
3688
+ /** Array of primitive names in the order they should be displayed */
3689
+ primitive_order: {
3690
+ type: ParameterType.OBJECT,
3691
+ default: ["square", "smalltriangle", "parallelogram", "medtriangle", "largetriangle"],
3692
+ description: "Array of primitive names in the order they should be displayed"
3693
+ },
3685
3694
  /** Callback fired after each interaction (optional analytics hook) */
3686
3695
  onInteraction: {
3687
3696
  type: ParameterType.FUNCTION,
@@ -3732,6 +3741,7 @@ class TangramPrepPlugin {
3732
3741
  layoutMode: trial.layout,
3733
3742
  requireAllSlots: trial.require_all_slots,
3734
3743
  quickstashMacros: trial.quickstash_macros,
3744
+ primitiveOrder: trial.primitive_order,
3735
3745
  onInteraction: trial.onInteraction,
3736
3746
  onTrialEnd: wrappedOnTrialEnd
3737
3747
  };