@moonbase-machines/vector 0.8.0 → 0.9.0
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/moonbase-vector.js +1 -1
- package/package.json +2 -2
package/dist/moonbase-vector.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @moonbase-machines/vector 0.
|
|
1
|
+
/*! @moonbase-machines/vector 0.9.0: MIT, (c) 2026 Mark Wharton (its LICENSE) */
|
|
2
2
|
var J=Object.defineProperty;var w=(t,n)=>{for(var o in n)J(t,o,{get:n[o],enumerable:!0})};var L={};w(L,{crossings:()=>E,draw:()=>K,fill:()=>j,inside:()=>B,line:()=>$,outline:()=>I,screen:()=>v,spans:()=>C,under:()=>Q});var v=(t=0)=>Array.from({length:192},()=>new Array(140).fill(t));function $(t,n,o,r){let c=Math.abs(o-t),e=Math.abs(r-n),f=o>=t?1:-1,i=r>=n?1:-1,l=c>=e,s=l?c:e,g=l?e:c,u=2*g-s,h=t,x=n,a=[[h,x]];for(let p=0;p<s;p++)u<0?(l?h+=f:x+=i,u+=2*g):(h+=f,x+=i,u+=2*g-2*s),a.push([h,x]);return a}function E(t){let n=Array.from({length:192},()=>[]),o=(u,h)=>{if(u<0||u>=192)return;let x=n[u],a=0;for(;a<x.length&&h>=x[a];)a++;x.splice(a,0,h)},r=t.length,c=0;for(let u=0;u<r;u++){let[h,x]=t[u],[a,p]=t[(u+1)%r];if(x===p)continue;let d=$(h,x,a,p);for(let m=1;m<d.length;m++)d[m][1]!==d[m-1][1]&&o(d[m-1][1],d[m-1][0]);let S=p>x?1:-1;S!==c&&(c=S,o(x,h))}let e=n.findIndex(u=>u.length);if(e<0)return null;let f=e;for(;f+1<192&&n[f+1].length;)f++;let[i,l]=t[0],s=Math.min(t[1][1],t[r-1][1]),g=Math.max(t[1][1],t[r-1][1]);return l!==e&&l!==f&&l>s&&l<g&&o(l,i),{rows:n,top:e,bottom:f}}function C(t,n){let o=E(t);if(o)for(let r=o.top;r<=o.bottom;r++){let c=o.rows[r];for(let e=(c.length&-2)-2;e>=0;e-=2)n(c[e],c[e+1],r)}}var M=(t,n,o,r)=>{n>=0&&n<140&&o>=0&&o<192&&(t[o][n]=r&15)};function j(t,n){return n.points.length<3||C(n.points,(o,r,c)=>{if(o===r)M(t,o,c,0);else for(let e=o;e<=r;e++)M(t,e,c,n.fill)}),t}function I(t,n){let o=n.points,r=o.length;if(r<2)return t;for(let c=0;c<(r===2?1:r);c++)for(let[e,f]of $(...o[c],...o[(c+1)%r]))M(t,e,f,n.line);return t}function K(t,n=v()){for(let o of t)j(n,o),I(n,o);return n}function B(t,n,o){if(t.points.length===2)return 254;let r=0;return C(t.points,(c,e,f)=>{f===o&&n>=c&&n<=e&&(r=128)}),r}function Q(t,n,o){let r=-1;return t.forEach((c,e)=>{B(c,n,o)&&(r=e)}),r}var G={};w(G,{GLYPHS:()=>y,WIDTHS:()=>b,dots:()=>X,start:()=>V,useFont:()=>Z,width:()=>A});var b=[3,1,3,5,5,5,4,1,3,3,5,5,2,5,1,5,4,3,4,4,4,4,4,4,4,4,1,2,3,3,3,4,8,4,4,4,4,4,4,4,4,3,4,4,4,5,4,4,4,4,4,4,3,4,5,5,4,5,4,5,5,5,5,5,3,4,4,4,4,4,3,4,4,3,4,4,3,5,4,4,4,4,4,4,3,4,5,5,4,4,4,3,1,3,4,5],O=[[6,"78ccccdceccccccc78"],[4,"60e0606060606060f0"],[6,"78cc0c183060c0c0fc"],[6,"78cc0c0c380c0ccc78"],[6,"0c1c2c4cccfc0c0c0c"],[6,"fcc0c0f80c0c0ccc78"],[6,"78ccc0c0f8cccccc78"],[6,"fc0c0c181830303030"],[6,"78cccccc78cccccc78"],[6,"78cccccc7c0c0ccc78"]],A=t=>{let n=t.charCodeAt(0);return n<32?n:n>=128?O[n-128]?.[0]??6:b[n-32]??4};function V(t,n,o,r){if(!r)return o;let c=0;for(let e of t)c+=e.charCodeAt(0)<32?A(e):A(e)+n;return(140-c&255)>>1}var y=["000000000000000000","808080808000800000","a0a0a0000000000000","0050f850f850000000","207080700870200000","808810204088080000","609060909090700000","808080000000000000","204080808040200000","804020202040800000","008850205088000000","002020f82020000000","000000000000408000","000000f80000000000","000000000080800000","000810204080000000","6090b0d09090600000","40c040404040e00000","609010608080f00000","609010201090600000","10305090f010100000","f080e0101090600000","609080e09090600000","f01010202040400000","609090609090600000","609090701090600000","000080800080800000","000040400040404080","002040804020000000","0000e000e000000000","008040204080000000","609010204000400000","ffffffffffffffffff","609090f09090900000","e09090e09090e00000","609080808090600000","e09090909090e00000","f08080c08080f00000","f08080c08080800000","609080b09090700000","909090f09090900000","e04040404040e00000","301010101090600000","90a0c0a0a090900000","808080808080f00000","88d8a8888888880000","90d0b0909090900000","609090909090600000","e09090e08080800000","60909090b0b0700000","e09090e09090900000","609080601090600000","e04040404040400000","909090909090600000","888888888850200000","88888888a8d8880000","909090609090900000","888850202020200000","f01020408080f00000","002060f86020000000","002030f83020000000","002020f87020000000","002070f82020000000","0000000000000000f8","804020000000000000","0000709090b0500000","8080e0909090e00000","000060908090600000","101070909090700000","00006090f080600000","2040e0404040400000","0000709090907010e0","8080e0909090900000","4000c0404040e00000","2000602020202020c0","808090a0c0a0900000","804040404040e00000","0000d0a8a8a8a80000","0000e0909090900000","000060909090600000","0000e0909090e08080","000070909090701010","0000e0908080800000","000070806010e00000","4040e0404040200000","000090909090700000","000088888850200000","00008888a8d8880000","000090906090900000","0000909090907010e0","0000f0106080f00000","204040804040200000","808080808080808080","804040204040800000","106080000000000000","ff0000000000000000"];function X(t){let n=t.charCodeAt(0),o=n>=128?O[n-128]?.[1]:y[n-32],r=[];if(!o)return r;for(let c=0;c<9;c++){let e=parseInt(o.slice(2*c,2*c+2),16);for(let f=0;f<8;f++)e>>7-f&1&&r.push([f,c])}return r}var N={widths:b.slice(),glyphs:y.slice()};function Z(t={}){b.splice(0,b.length,...N.widths),y.splice(0,y.length,...N.glyphs);for(let[n,[o,r]]of Object.entries(t))b[n.charCodeAt(0)-32]=o,y[n.charCodeAt(0)-32]=r}var D={};w(D,{INLINE:()=>t0,name:()=>R,sound:()=>q,text:()=>H});function H(t,n){let o="",r=n;for(let c=0;c<4096;c++){let e=t(r++);if(e===void 0||e===128)break;if(e===27){let f=t(r++),i=f===15||f===12?2:f===6||f===11?4:[7,8,9,10,13,14,16,17].includes(f)?0:1,l=[];for(let s=0;s<i;s++)l.push(t(r+s).toString(16));o+="{"+f.toString(16)+(i?":"+l.join(","):"")+"}",r+=i;continue}o+=e===141?`
|
|
3
3
|
`:String.fromCharCode(e&127)}return{length:r-n,value:o}}function R(t,n){let o=t(n)&127,r="";for(let c=1;c<=o;c++)r+=String.fromCharCode(t(n+c)&127);return{length:o+1,value:r}}function q(t,n){let o=[];for(let r=0;r<5;r++)o.push(t(n+r).toString(16));return{length:5,value:o.join(" ")}}var t0={text:H,picture:R,sound:q};var P={};w(P,{carry:()=>o0,decode:()=>F,put:()=>e0,tables:()=>n0});function F(t,n){let o=t[n],r=t[n+1],c=t[n+2],e=t[n+3],f=n+4,i=0,l=0,s=[];if(o&64){let g=t[f++],u=()=>{if(i)return i--,l;let h=t[f++];return h===g?(i=t[f]-1,l=t[f+1],f+=2,l):h};for(let h=0;h<e;h++){let x=[];for(let a=0;a<c+1>>1;a++){let p=u();x.push(p>>4,p&15)}s.push(x.slice(0,c))}}else{let g=()=>{if(i)return i--,l;let u=t[f++];return u&128?(l=u&127,i=t[f++]-1,l):u};for(let u=0;u<e;u++){let h=[];for(let a=0;a<r;a++){let p=g();for(let d=0;d<7;d++)h.push(p>>d&1)}let x=[];for(let a=0;a<c;a++)x.push(h[a*4]<<3|h[a*4+1]<<2|h[a*4+2]<<1|h[a*4+3]);s.push(x)}}return{flags:o,stride:r,width:c,height:e,packed:o&64?"nibbles":"bytes",clear:o&128?void 0:o&15,rows:s,end:f}}function e0(t,n,o,r,c=!1){return n.rows.forEach((e,f)=>e.forEach((i,l)=>{let s=t[r+f];!s||o+l<0||o+l>=s.length||(c||i!==n.clear)&&(s[o+l]=i)})),t}function n0(t,n){let o=[],r=(e,f)=>e[f]|e[f+1]<<8,c=e=>t.find(f=>e>=f.origin&&e<f.origin+f.bytes.length);for(let e of t){let f=e.bytes;for(let i=0;i+7<=f.length;i++){if(!(f[i]===162&&f[i+2]===160&&f[i+4]===32&&r(f,i+5)===n))continue;let l=f[i+1]|f[i+3]<<8,s=l>=e.origin&&l<e.origin+f.length?e:c(l);if(!s||o.some(u=>u.file===s.name&&u.address===l))continue;let g=[];for(let u=2;;u++){let h=l-s.origin+(u-2)*2;if(h+2>s.bytes.length)break;let x=r(s.bytes,h);if(x<s.origin||x+4>s.origin+s.bytes.length)break;let a=x-s.origin,p=s.bytes[a+2],d=s.bytes[a+3];if(!s.bytes[a+1]||!p||!d||p>140||d>192)break;g.push({number:u,at:x,...F(s.bytes,a)})}g.length&&o.push({file:s.name,setBy:e.name,address:l,objects:g})}}return o}function o0(t,n){let o=Math.floor(2*n/7),r=n%7,c=-(2*o+(r>>1&1))&255,e=0;for(let f=0;f<t.height;f++){let i=c+t.stride+1;e=i>255?1:0,c=i&255}return e}var W={};w(W,{pictures:()=>r0,shapes:()=>U,windows:()=>c0});var T=t=>String.fromCharCode(...Array.from(t,n=>n&127));function U(t,n,o=8192){let r=[],c=null;for(let e=n;e<n+o;e++){let f=t(e);if(f===255&&!c)break;if(f===254){c&&r.push(c),c=null;continue}if(!c){c={fill:f,line:t(e+1),points:[]},e++;continue}c.points.push([f,t(e+1)]),e++}return c&&r.push(c),r}function r0(t){let n=[];for(let o=0;o+16<=t.length;){let r=T(t.subarray(o,o+14)).trimEnd(),c=t[o+14]|t[o+15]<<8;if(c<18||o+c>t.length)break;n.push({name:r,at:o,length:c,shapes:U(e=>t[e],o+16,c-16)}),o+=c}return n}function c0(t,{box:n,picture:o}){let r=new Map,c=(e,f)=>e[f]|e[f+1]<<8;for(let e of t){let f;for(let i=0;i+8<e.length;i++){if(e[i]===169&&e[i+2]===162&&e[i+4]===160&&e[i+6]===32&&c(e,i+7)===n){f=e[i+1],i+=8;continue}if(e[i]===32&&c(e,i+1)===o&&e[i+3]&128){let l=e[i+3]&127,s=T(e.subarray(i+4,i+4+l)).toUpperCase().replace(/_/g," ").replace(/[\x00-\x1f]/g,"").trimEnd();f!==void 0&&!r.has(s)&&r.set(s,f),i+=3+l}}}return e=>r.get(e)??r.get(e.replace(/ ?\d$/,""))}var z={};w(z,{bounds:()=>Y,document:()=>i0,elements:()=>_});import{colors as f0}from"@moonbase-machines/apple2e";var{COLORS:u0,NAMES:a0,rgb:k}=f0;function Y(t){let n=140,o=192,r=-1,c=-1;for(let e of t)for(let[f,i]of e.points)n=Math.min(n,f),o=Math.min(o,i),r=Math.max(r,f),c=Math.max(c,i);return r<0?null:{x0:Math.max(0,n-1),y0:Math.max(0,o-1),x1:Math.min(139,r+1),y1:Math.min(191,c+1)}}function _(t,{background:n,crisp:o=!0}={}){let r=Y(t),c=o?' shape-rendering="crispEdges"':"",e=r&&n!==void 0?`<rect x="${Math.max(0,r.x0-1)}" y="${Math.max(0,r.y0-1)}" width="${r.x1-r.x0+3}" height="${r.y1-r.y0+3}" fill="${k(n)}"/>`:"";for(let f of t){let i=f.points.map(([l,s])=>l+.5+","+(s+.5)).join(" ");f.points.length===2?e+=`<polyline points="${i}" fill="none" stroke="${k(f.line)}" stroke-width="1" stroke-linecap="square"${c}/>`:f.points.length>2&&(e+=`<polygon points="${i}" fill="${k(f.fill)}" stroke="${k(f.line)}" stroke-width="1" stroke-linejoin="round"${c}/>`)}return e}function i0(t,{background:n=0,width:o=560,crisp:r=!1}={}){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 140 192" width="${o}" height="${o*384/560}" preserveAspectRatio="none"><rect width="140" height="192" fill="${k(n)}"/>`+_(t,{crisp:r})+"</svg>"}export{L as draw,G as font,D as inline,P as objects,W as pictures,z as svg};
|
|
4
4
|
//# sourceMappingURL=moonbase-vector.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase-machines/vector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Mark Wharton's vector graphics engine for the Apple IIe (Animal Rescue, Nature Park Adventure, 1989): its pictures, objects, font and drawing, dot for dot.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"./*": "./*"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@moonbase-machines/apple2e": "0.
|
|
13
|
+
"@moonbase-machines/apple2e": "0.9.0"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "node --test test/*.test.js",
|