Something went wrong. Try again.
[PRE-ALPHA] an open source web-based 2D/3D graphing calculator cartesium.org
Something went wrong. Try again.
TypeScript
at mathquill
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { describe, expect, it } from 'vitest';
import type { RenderScene2d } from './types';import { packedPolylineBytes, packTilePolylines } from './packed-polylines';
describe('packTilePolylines', () => { it('moves nested contour geometry into flat transferable buffers', () => { const scene: RenderScene2d = { viewport: { x_min: -1, x_max: 1, y_min: -1, y_max: 1, width: 256, height: 256 }, coverage: { x_min: -1, x_max: 1, y_min: -1, y_max: 1, width: 256, height: 256 }, layers: [ { type: 'polyline', geometry_id: 7, expression_id: 'circle', vertices: [ [-1, 0], [0, 1], [1, 0] ], breaks: [2], color: '#2563eb', line_style: 'solid', source_kind: 'implicit', sampling: { strategy: 'marching_squares', target_samples: 256, vertex_count: 3, segment_count: 1, max_depth: null, max_depth_reached: false, vertex_budget: null, vertex_budget_reached: false, warnings: [] } } ], diagnostics: [], variables: [], expression_roles: {}, model_revisions: {} };
const packed = packTilePolylines(scene);
expect(scene.layers).toEqual([]); expect(packed?.[0].coordinates).toEqual(new Float64Array([-1, 0, 0, 1, 1, 0])); expect(packed?.[0].breaks).toEqual(new Uint32Array([2])); expect(packed?.[0].layer.expression_id).toBe('circle'); expect(packedPolylineBytes(packed)).toBe(52); });});