fragment-tools 0.1.13 → 0.1.14

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.
Files changed (52) hide show
  1. package/bin/index.js +2 -2
  2. package/package.json +4 -5
  3. package/src/cli/log.js +31 -21
  4. package/src/cli/plugins/check-dependencies.js +47 -30
  5. package/src/cli/plugins/hot-shader-replacement.js +384 -0
  6. package/src/cli/plugins/hot-sketch-reload.js +3 -13
  7. package/src/cli/plugins/screenshot.js +57 -20
  8. package/src/cli/server.js +144 -133
  9. package/src/client/app/App.svelte +3 -3
  10. package/src/client/app/client.js +55 -39
  11. package/src/client/app/components/Init.svelte +12 -9
  12. package/src/client/app/helpers.js +42 -0
  13. package/src/client/app/hooks.js +20 -0
  14. package/src/client/app/inputs/Keyboard.js +13 -15
  15. package/src/client/app/inputs/MIDI.js +14 -15
  16. package/src/client/app/lib/canvas-recorder/CanvasRecorder.js +41 -21
  17. package/src/client/app/lib/gl/Renderer.js +127 -139
  18. package/src/client/app/modules/Exports.svelte +62 -43
  19. package/src/client/app/modules/MidiPanel.svelte +100 -101
  20. package/src/client/app/modules/Params.svelte +116 -103
  21. package/src/client/app/renderers/2DRenderer.js +3 -3
  22. package/src/client/app/renderers/FragmentRenderer.js +30 -23
  23. package/src/client/app/renderers/P5Renderer.js +10 -7
  24. package/src/client/app/renderers/THREERenderer.js +136 -94
  25. package/src/client/app/stores/exports.js +36 -20
  26. package/src/client/app/stores/props.js +28 -5
  27. package/src/client/app/stores/renderers.js +22 -15
  28. package/src/client/app/stores/sketches.js +7 -9
  29. package/src/client/app/stores/utils.js +95 -38
  30. package/src/client/app/triggers/Keyboard.js +88 -79
  31. package/src/client/app/triggers/MIDI.js +110 -84
  32. package/src/client/app/ui/Field.svelte +343 -240
  33. package/src/client/app/ui/FieldGroup.svelte +106 -94
  34. package/src/client/app/ui/FieldSection.svelte +125 -116
  35. package/src/client/app/ui/ParamsMultisampling.svelte +96 -95
  36. package/src/client/app/ui/ParamsOutput.svelte +113 -113
  37. package/src/client/app/ui/SelectChevrons.svelte +27 -15
  38. package/src/client/app/ui/SketchRenderer.svelte +761 -667
  39. package/src/client/app/ui/fields/ButtonInput.svelte +61 -48
  40. package/src/client/app/ui/fields/CheckboxInput.svelte +67 -61
  41. package/src/client/app/ui/fields/ColorInput.svelte +294 -238
  42. package/src/client/app/ui/fields/ImageInput.svelte +123 -121
  43. package/src/client/app/ui/fields/Input.svelte +100 -111
  44. package/src/client/app/ui/fields/ListInput.svelte +96 -96
  45. package/src/client/app/ui/fields/NumberInput.svelte +121 -116
  46. package/src/client/app/ui/fields/ProgressInput.svelte +80 -73
  47. package/src/client/app/ui/fields/Select.svelte +137 -124
  48. package/src/client/app/ui/fields/VectorInput.svelte +86 -82
  49. package/src/client/app/utils/canvas.utils.js +228 -201
  50. package/src/client/app/utils/file.utils.js +38 -34
  51. package/src/client/public/css/global.css +27 -21
  52. package/src/cli/plugins/hot-shader-reload.js +0 -86
@@ -1,139 +1,139 @@
1
1
  <script>
2
- import { rendering, SIZES, monitors } from "../stores/rendering.js";
3
- import { sketchesCount } from "../stores/sketches.js";
4
- import Field from "./Field.svelte";
5
- import presets, { getDimensionsForPreset } from "../lib/presets";
6
- import { exports } from "../stores";
7
- import ParamsMultisampling from "./ParamsMultisampling.svelte";
2
+ import { rendering, SIZES, monitors } from '../stores/rendering.js';
3
+ import { sketchesCount } from '../stores/sketches.js';
4
+ import Field from './Field.svelte';
5
+ import presets, { getDimensionsForPreset } from '../lib/presets';
6
+ import { exports } from '../stores';
7
+ import ParamsMultisampling from './ParamsMultisampling.svelte';
8
8
 
9
- let canvasWidth = $rendering.width;
10
- let canvasHeight = $rendering.height;
9
+ let canvasWidth = $rendering.width;
10
+ let canvasHeight = $rendering.height;
11
11
 
12
- function handleChangeDimensions(event) {
13
- const [width, height] = event.detail;
14
- const needsUpdate = canvasWidth !== width || canvasHeight !== height;
12
+ function handleChangeDimensions(event) {
13
+ const [width, height] = event.detail;
14
+ const needsUpdate = canvasWidth !== width || canvasHeight !== height;
15
15
 
16
- if (needsUpdate) {
17
- canvasWidth = width;
18
- canvasHeight = height;
16
+ if (needsUpdate) {
17
+ canvasWidth = width;
18
+ canvasHeight = height;
19
19
 
20
- rendering.update((curr) => {
21
- return {
22
- ...curr,
23
- width,
24
- height
25
- }
26
- });
27
- }
28
- }
20
+ rendering.update((curr) => {
21
+ return {
22
+ ...curr,
23
+ width,
24
+ height,
25
+ };
26
+ });
27
+ }
28
+ }
29
29
 
30
- let sizes = Object.values(SIZES);
31
- $: dimensionsEnabled = [SIZES.FIXED, SIZES.SCALE].includes($rendering.resizing);
30
+ let sizes = Object.values(SIZES);
31
+ $: dimensionsEnabled = [SIZES.FIXED, SIZES.SCALE].includes(
32
+ $rendering.resizing,
33
+ );
32
34
 
33
- $: {
34
- if ($rendering.resizing === SIZES.PRESET) {
35
- const { preset } = $rendering;
36
- const [ width, height ] = getDimensionsForPreset(preset, { pixelsPerInch: 300 });
37
-
38
- rendering.update((curr) => {
39
- return {
40
- ...curr,
41
- width,
42
- height,
43
- };
44
- });
45
- }
46
- }
35
+ $: {
36
+ if ($rendering.resizing === SIZES.PRESET) {
37
+ const { preset } = $rendering;
38
+ const [width, height] = getDimensionsForPreset(preset, {
39
+ pixelsPerInch: 300,
40
+ });
47
41
 
42
+ rendering.update((curr) => {
43
+ return {
44
+ ...curr,
45
+ width,
46
+ height,
47
+ };
48
+ });
49
+ }
50
+ }
48
51
  </script>
49
52
 
50
53
  <Field
51
- key="dimensions"
52
- value={[
53
- $rendering.width,
54
- $rendering.height,
55
- ]}
56
- on:change={handleChangeDimensions}
57
- params={{
58
- step: 1,
59
- suffix: "px",
60
- locked: false,
61
- disabled: !dimensionsEnabled,
62
- }}
54
+ key="dimensions"
55
+ value={[$rendering.width, $rendering.height]}
56
+ on:change={handleChangeDimensions}
57
+ params={{
58
+ step: 1,
59
+ suffix: 'px',
60
+ locked: false,
61
+ }}
62
+ disabled={!dimensionsEnabled}
63
63
  />
64
64
  <Field
65
- key="canvasSize"
66
- value={$rendering.resizing}
67
- on:change={(event) => {
68
- const resizing = event.detail;
69
- let aspectRatio = 1;
65
+ key="canvasSize"
66
+ value={$rendering.resizing}
67
+ on:change={(event) => {
68
+ const resizing = event.detail;
69
+ let aspectRatio = 1;
70
70
 
71
- if (resizing === SIZES.ASPECT_RATIO) {
72
- // compute aspect ratio based on previous props
73
- aspectRatio = $rendering.width / $rendering.height;
74
- }
71
+ if (resizing === SIZES.ASPECT_RATIO) {
72
+ // compute aspect ratio based on previous props
73
+ aspectRatio = $rendering.width / $rendering.height;
74
+ }
75
75
 
76
- $exports.pixelsPerInch = resizing === SIZES.PRESET ? 300 : 72;
76
+ $exports.pixelsPerInch = resizing === SIZES.PRESET ? 300 : 72;
77
77
 
78
- rendering.update((curr) => {
79
- return {
80
- ...curr,
81
- resizing,
82
- aspectRatio,
83
- }
84
- });
85
- }}
86
- params={{
87
- options: sizes,
88
- }}
78
+ rendering.update((curr) => {
79
+ return {
80
+ ...curr,
81
+ resizing,
82
+ aspectRatio,
83
+ };
84
+ });
85
+ }}
86
+ params={{
87
+ options: sizes,
88
+ }}
89
89
  />
90
90
  {#if $rendering.resizing === SIZES.ASPECT_RATIO}
91
- <Field
92
- key="aspectRatio"
93
- value={$rendering.aspectRatio}
94
- on:change={(event) => {
95
- $rendering.aspectRatio = event.detail;
96
- }}
97
- params={{
98
- step: 0.01,
99
- }}
100
- />
91
+ <Field
92
+ key="aspectRatio"
93
+ value={$rendering.aspectRatio}
94
+ on:change={(event) => {
95
+ $rendering.aspectRatio = event.detail;
96
+ }}
97
+ params={{
98
+ step: 0.01,
99
+ }}
100
+ />
101
101
  {/if}
102
102
  {#if $rendering.resizing === SIZES.SCALE}
103
- <Field
104
- key="zoom"
105
- value={$rendering.scale}
106
- on:change={(event) => {
107
- $rendering.scale = event.detail;
108
- }}
109
- params={{
110
- step: 0.01,
111
- }}
112
- />
103
+ <Field
104
+ key="zoom"
105
+ value={$rendering.scale}
106
+ on:change={(event) => {
107
+ $rendering.scale = event.detail;
108
+ }}
109
+ params={{
110
+ step: 0.01,
111
+ }}
112
+ />
113
113
  {/if}
114
114
  {#if $rendering.resizing === SIZES.PRESET}
115
- <Field
116
- key="preset"
117
- value={$rendering.preset}
118
- on:change={(event) => {
119
- $rendering.preset = event.detail;
120
- }}
121
- params={{
122
- options: presets,
123
- }}
124
- />
115
+ <Field
116
+ key="preset"
117
+ value={$rendering.preset}
118
+ on:change={(event) => {
119
+ $rendering.preset = event.detail;
120
+ }}
121
+ params={{
122
+ options: presets,
123
+ }}
124
+ />
125
125
  {/if}
126
126
 
127
- {#if $rendering.resizing !== SIZES.PRESET }
128
- <Field
129
- key="pixelRatio"
130
- value={Number($rendering.pixelRatio)}
131
- on:change={(event) => $rendering.pixelRatio = event.detail }
132
- params={{
133
- step: 0.1,
134
- }}
135
- />
127
+ {#if $rendering.resizing !== SIZES.PRESET}
128
+ <Field
129
+ key="pixelRatio"
130
+ value={Number($rendering.pixelRatio)}
131
+ on:change={(event) => ($rendering.pixelRatio = event.detail)}
132
+ params={{
133
+ step: 0.1,
134
+ }}
135
+ />
136
136
  {/if}
137
- {#if $sketchesCount > 1 && $monitors.length > 1 }
138
- <ParamsMultisampling />
137
+ {#if $sketchesCount > 1 && $monitors.length > 1}
138
+ <ParamsMultisampling />
139
139
  {/if}
@@ -1,25 +1,37 @@
1
1
  <script>
2
- export let width = 24;
3
- export let height = 24;
2
+ export let width = 24;
3
+ export let height = 24;
4
4
  </script>
5
5
 
6
6
  <div class="chevrons" style={`width: ${width}px;`}>
7
- <svg class="chevron chevron-bottom" width={width} height={height} fill="none" viewBox="0 0 24 24">
8
- <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15.25 10.75L12 14.25L8.75 10.75"></path>
7
+ <svg
8
+ class="chevron chevron-bottom"
9
+ {width}
10
+ {height}
11
+ fill="none"
12
+ viewBox="0 0 24 24"
13
+ >
14
+ <path
15
+ stroke="currentColor"
16
+ stroke-linecap="round"
17
+ stroke-linejoin="round"
18
+ stroke-width="1.5"
19
+ d="M15.25 10.75L12 14.25L8.75 10.75"
20
+ />
9
21
  </svg>
10
22
  </div>
11
23
 
12
24
  <style>
13
- .chevrons {
14
- position: absolute;
15
- top: 0;
16
- right: 0;
17
- bottom: 0;
18
- display: flex;
19
- align-items: center;
20
- width: 15px;
25
+ .chevrons {
26
+ position: absolute;
27
+ top: 0;
28
+ right: 0;
29
+ bottom: 0;
30
+ display: flex;
31
+ align-items: center;
32
+ width: 15px;
21
33
 
22
- color: var(--color, currentColor);
23
- pointer-events: none;
24
- }
34
+ color: inherit;
35
+ pointer-events: none;
36
+ }
25
37
  </style>