@fieldnotes/core 0.1.1 → 0.1.2

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.
package/dist/index.d.cts CHANGED
@@ -114,6 +114,7 @@ declare class Background {
114
114
  private readonly lineWidth;
115
115
  constructor(options?: BackgroundOptions);
116
116
  render(ctx: CanvasRenderingContext2D, camera: Camera): void;
117
+ private adaptSpacing;
117
118
  private renderDots;
118
119
  private renderGrid;
119
120
  }
@@ -577,6 +578,6 @@ declare class ImageTool implements Tool {
577
578
  onPointerUp(state: PointerState, ctx: ToolContext): void;
578
579
  }
579
580
 
580
- declare const VERSION = "0.1.0";
581
+ declare const VERSION = "0.1.2";
581
582
 
582
583
  export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, SelectTool, type Size, type StrokeElement, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, createArrow, createHtmlElement, createId, createImage, createNote, createStroke, exportState, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, isNearBezier, parseState };
package/dist/index.d.ts CHANGED
@@ -114,6 +114,7 @@ declare class Background {
114
114
  private readonly lineWidth;
115
115
  constructor(options?: BackgroundOptions);
116
116
  render(ctx: CanvasRenderingContext2D, camera: Camera): void;
117
+ private adaptSpacing;
117
118
  private renderDots;
118
119
  private renderGrid;
119
120
  }
@@ -577,6 +578,6 @@ declare class ImageTool implements Tool {
577
578
  onPointerUp(state: PointerState, ctx: ToolContext): void;
578
579
  }
579
580
 
580
- declare const VERSION = "0.1.0";
581
+ declare const VERSION = "0.1.2";
581
582
 
582
583
  export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, SelectTool, type Size, type StrokeElement, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, createArrow, createHtmlElement, createId, createImage, createNote, createStroke, exportState, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, isNearBezier, parseState };
package/dist/index.js CHANGED
@@ -158,6 +158,7 @@ var Camera = class {
158
158
  };
159
159
 
160
160
  // src/canvas/background.ts
161
+ var MIN_PATTERN_SPACING = 16;
161
162
  var DEFAULTS = {
162
163
  pattern: "dots",
163
164
  spacing: 24,
@@ -193,8 +194,15 @@ var Background = class {
193
194
  }
194
195
  ctx.restore();
195
196
  }
197
+ adaptSpacing(baseSpacing, zoom) {
198
+ let spacing = baseSpacing * zoom;
199
+ while (spacing < MIN_PATTERN_SPACING) {
200
+ spacing *= 2;
201
+ }
202
+ return spacing;
203
+ }
196
204
  renderDots(ctx, camera, width, height) {
197
- const spacing = this.spacing * camera.zoom;
205
+ const spacing = this.adaptSpacing(this.spacing, camera.zoom);
198
206
  const offsetX = camera.position.x % spacing;
199
207
  const offsetY = camera.position.y % spacing;
200
208
  const radius = this.dotRadius * Math.min(camera.zoom, 2);
@@ -209,7 +217,7 @@ var Background = class {
209
217
  ctx.fill();
210
218
  }
211
219
  renderGrid(ctx, camera, width, height) {
212
- const spacing = this.spacing * camera.zoom;
220
+ const spacing = this.adaptSpacing(this.spacing, camera.zoom);
213
221
  const offsetX = camera.position.x % spacing;
214
222
  const offsetY = camera.position.y % spacing;
215
223
  const lineW = this.lineWidth * Math.min(camera.zoom, 2);
@@ -2150,7 +2158,7 @@ var ImageTool = class {
2150
2158
  };
2151
2159
 
2152
2160
  // src/index.ts
2153
- var VERSION = "0.1.0";
2161
+ var VERSION = "0.1.2";
2154
2162
  export {
2155
2163
  AddElementCommand,
2156
2164
  ArrowTool,