@sealpixel/ui 1.0.0-rc.21 → 1.0.0-rc.23
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/components/editor/empty-state.d.ts +14 -0
- package/dist/components/editor/empty-state.js +38 -0
- package/dist/components/editor/empty-state.js.map +1 -0
- package/dist/components/editor/json-attribute.d.ts +5 -0
- package/dist/components/editor/json-attribute.js +18 -0
- package/dist/components/editor/json-attribute.js.map +1 -0
- package/dist/components/editor/panel-fit.d.ts +20 -0
- package/dist/components/editor/panel-fit.js +60 -0
- package/dist/components/editor/panel-fit.js.map +1 -0
- package/dist/components/editor/styles.d.ts +2 -0
- package/dist/components/editor/styles.js +697 -0
- package/dist/components/editor/styles.js.map +1 -0
- package/dist/components/editor/toast.d.ts +8 -0
- package/dist/components/editor/toast.js +21 -0
- package/dist/components/editor/toast.js.map +1 -0
- package/dist/components/sealpixel-editor.d.ts +9 -44
- package/dist/components/sealpixel-editor.js +45 -888
- package/dist/components/sealpixel-editor.js.map +1 -1
- package/dist/components/sealpixel-stage.js +11 -2
- package/dist/components/sealpixel-stage.js.map +1 -1
- package/dist/controllers/history-shortcuts-controller.d.ts +18 -0
- package/dist/controllers/history-shortcuts-controller.js +68 -0
- package/dist/controllers/history-shortcuts-controller.js.map +1 -0
- package/dist/locales/de.js +16 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.js +16 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +16 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +16 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/ja.js +16 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/pt.js +16 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/tools/annotate.d.ts +58 -0
- package/dist/tools/annotate.js +136 -12
- package/dist/tools/annotate.js.map +1 -1
- package/dist/tools/assist.d.ts +3 -0
- package/dist/tools/assist.js +44 -9
- package/dist/tools/assist.js.map +1 -1
- package/dist/tools/crop-mask.d.ts +2 -0
- package/dist/tools/crop-mask.js +11 -0
- package/dist/tools/crop-mask.js.map +1 -1
- package/dist/tools/crop.d.ts +9 -0
- package/dist/tools/crop.js +117 -48
- package/dist/tools/crop.js.map +1 -1
- package/dist/tools/filter.js +41 -19
- package/dist/tools/filter.js.map +1 -1
- package/dist/tools/finetune.js +10 -7
- package/dist/tools/finetune.js.map +1 -1
- package/dist/tools/frame.js +10 -10
- package/dist/tools/frame.js.map +1 -1
- package/dist/tools/instance-state.d.ts +8 -0
- package/dist/tools/instance-state.js +32 -0
- package/dist/tools/instance-state.js.map +1 -0
- package/dist/tools/keys.d.ts +95 -3
- package/dist/tools/keys.js +135 -2
- package/dist/tools/keys.js.map +1 -1
- package/dist/tools/redact.d.ts +18 -10
- package/dist/tools/redact.js +233 -35
- package/dist/tools/redact.js.map +1 -1
- package/dist/tools/region-transform.d.ts +23 -14
- package/dist/tools/region-transform.js +45 -32
- package/dist/tools/region-transform.js.map +1 -1
- package/dist/tools/resize.js +11 -9
- package/dist/tools/resize.js.map +1 -1
- package/dist/tools/sticker.js +7 -3
- package/dist/tools/sticker.js.map +1 -1
- package/package.json +4 -4
package/dist/locales/pt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pt.js","sourceRoot":"","sources":["../../src/locales/pt.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG;IACT,gBAAgB,EAAE,mBAAmB;IACrC,cAAc,EAAE,+CAA+C;IAC/D,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,4BAA4B;IAC5C,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,SAAS;IACrB,aAAa,EAAE,sBAAsB;IACrC,YAAY,EAAE,UAAU;IACxB,cAAc,EAAE,YAAY;IAC5B,WAAW,EAAE,YAAY;IACzB,eAAe,EAAE,YAAY;IAC7B,iBAAiB,EAAE,wCAAwC;IAC3D,gBAAgB,EA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AE,iBAAiB;CAC/B,CAAC;AACF,eAAe,EAA4B,CAAC","sourcesContent":["const pt = {\n 'editor.loading': 'A carregar imagem',\n 'editor.empty': 'Largue uma imagem aqui ou escolha um ficheiro',\n 'editor.choose': 'Escolher imagem',\n 'editor.error': 'Algo correu mal: {message}',\n 'nav.undo': 'Anular',\n 'nav.redo': 'Refazer',\n 'nav.history': 'Posição no histórico',\n 'nav.export': 'Exportar',\n 'nav.download': 'Transferir',\n 'nav.reset': 'Repor tudo',\n 'nav.exporting': 'A exportar',\n 'status.exported': '{width} por {height} píxeis exportados',\n 'resize.presets': 'Predefinições',\n 'watermark.locked': \"A marca d'água está fixada pela configuração deste editor.\",\n 'annotate.font': 'Fonte',\n 'toast.exported': '{format} exportado, {width} × {height}, {size}',\n 'toast.downloaded': '{format} baixado, {width} × {height}, {size}',\n 'status.dimensions': 'Saída {width} por {height} píxeis',\n 'tool.crop': 'Recortar',\n 'tool.finetune': 'Afinar',\n 'tool.filter': 'Filtro',\n 'tool.resize': 'Tamanho',\n 'crop.rotation': 'Rotação',\n 'crop.flipX': 'Inverter horizontalmente',\n 'crop.flipY': 'Inverter verticalmente',\n 'crop.aspect': 'Proporção',\n 'crop.aspect.free': 'Livre',\n 'crop.aspect.square': 'Quadrado',\n 'crop.aspect.original': 'Original',\n 'crop.reset': 'Repor recorte',\n 'finetune.brightness': 'Brilho',\n 'finetune.contrast': 'Contraste',\n 'finetune.saturation': 'Saturação',\n 'finetune.exposure': 'Exposição',\n 'finetune.gamma': 'Gama',\n 'finetune.clarity': 'Nitidez',\n 'finetune.vignette': 'Vinheta',\n 'finetune.reset': 'Repor afinação',\n 'filter.none': 'Nenhum',\n 'filter.grayscale': 'Escala de cinzentos',\n 'filter.sepia': 'Sépia',\n 'filter.vintage': 'Vintage',\n 'filter.cool': 'Frio',\n 'filter.warm': 'Quente',\n 'filter.invert': 'Inverter',\n 'filter.strength': 'Intensidade',\n 'resize.size': 'Tamanho',\n 'resize.linked': 'Manter proporções',\n 'resize.unlinked': 'Proporções livres',\n 'resize.width': 'Largura',\n 'resize.height': 'Altura',\n 'resize.fit': 'Ajuste',\n 'resize.fit.contain': 'Conter',\n 'resize.fit.cover': 'Cobrir',\n 'resize.fit.fill': 'Esticar',\n 'resize.upscale': 'Permitir ampliar',\n 'resize.clear': 'Limpar tamanho',\n 'resize.pixels': 'px',\n 'tool.redact': 'Ocultar',\n 'redact.shape': 'Forma',\n 'redact.shape.rect': 'Retângulo',\n 'redact.shape.path': 'Mão livre',\n 'redact.mode': 'Modo',\n 'redact.mode.pixelate': 'Pixelizar',\n 'redact.mode.blur': 'Desfocar',\n 'redact.mode.mosaic': 'Mosaico seguro',\n 'redact.remove': 'Remover área',\n 'redact.region': 'Área {n}',\n 'redact.rotate': 'Girar região',\n 'tool.assist': 'Assistente',\n 'tool.badge': '{count} sugestões',\n 'assist.detect': 'Detetar novamente',\n 'assist.loading': 'A carregar o detetor…',\n 'assist.detecting': 'À procura de regiões…',\n 'assist.found': '{count} sugestões',\n 'assist.none': 'Nada encontrado',\n 'assist.error': 'A deteção falhou: {message}',\n 'assist.timeout': 'A deteção demorou demasiado',\n 'assist.refused': 'Não aceite: as opções de redact não o permitem ({message})',\n 'assist.unavailable': 'Nenhum detetor configurado',\n 'assist.accept': 'Aceitar sugestão',\n 'assist.reject': 'Rejeitar sugestão',\n 'assist.acceptAll': 'Aceitar todas',\n 'assist.rejectAll': 'Rejeitar todas',\n 'assist.needsRedact': 'Requer o plugin redact',\n 'tool.annotate': 'Anotar',\n 'annotate.shape': 'Forma',\n 'annotate.kind.rect': 'Retângulo',\n 'annotate.kind.ellipse': 'Elipse',\n 'annotate.kind.line': 'Linha',\n 'annotate.kind.arrow': 'Seta',\n 'annotate.kind.path': 'Mão livre',\n 'annotate.kind.text': 'Texto',\n 'annotate.stroke': 'Cor',\n 'annotate.width': 'Espessura da linha',\n 'annotate.fill': 'Preenchimento',\n 'annotate.fillColor': 'Cor de preenchimento',\n 'annotate.color': 'Cor',\n 'annotate.background': 'Fundo',\n 'annotate.noBackground': 'Sem fundo',\n 'annotate.lineHeight': 'Entrelinha',\n 'annotate.align': 'Alinhamento',\n 'annotate.align.left': 'Alinhar à esquerda',\n 'annotate.align.center': 'Centralizar',\n 'annotate.align.right': 'Alinhar à direita',\n 'annotate.text': 'Texto',\n 'annotate.size': 'Tamanho da letra',\n 'annotate.delete': 'Eliminar forma',\n 'annotate.shapeLabel': '{kind} {n}',\n 'annotate.rotate': 'Girar forma',\n 'annotate.defaultText': 'Texto',\n 'tool.sticker': 'Autocolante',\n 'sticker.upload': 'Carregar imagem de autocolante',\n 'sticker.library': 'Autocolantes',\n 'sticker.hint.empty': 'Carregue um PNG, JPEG ou WebP para o usar como autocolante.',\n 'sticker.rotation': 'Rotação',\n 'sticker.opacity': 'Opacidade',\n 'sticker.delete': 'Eliminar autocolante',\n 'sticker.item': 'Autocolante {n}',\n 'tool.frame': 'Moldura',\n 'frame.style': 'Estilo',\n 'frame.none': 'Nenhuma',\n 'frame.style.solid': 'Sólida',\n 'frame.style.inset': 'Linha interior',\n 'frame.style.polaroid': 'Polaroid',\n 'frame.color': 'Cor',\n 'frame.radius': 'Raio dos cantos',\n 'tool.watermark': 'Marca de água',\n 'watermark.text': 'Texto',\n 'watermark.textValue': 'Texto',\n 'watermark.color': 'Cor',\n 'watermark.defaultText': '© sealpixel',\n 'watermark.clear': 'Remover marca de água',\n 'watermark.anchor': 'Posição',\n 'watermark.anchor.tl': 'Superior esquerdo',\n 'watermark.anchor.tc': 'Superior',\n 'watermark.anchor.tr': 'Superior direito',\n 'watermark.anchor.cl': 'Esquerda',\n 'watermark.anchor.c': 'Centro',\n 'watermark.anchor.cr': 'Direita',\n 'watermark.anchor.bl': 'Inferior esquerdo',\n 'watermark.anchor.bc': 'Inferior',\n 'watermark.anchor.br': 'Inferior direito',\n 'watermark.scale': 'Tamanho',\n 'watermark.margin': 'Margem',\n 'watermark.tile': 'Repetir por toda a imagem',\n 'watermark.tileRotation': 'Rotação dos mosaicos',\n 'watermark.tileGap': 'Espaçamento dos mosaicos',\n 'stage.zoom': 'Zoom {percent} %',\n 'stage.fit': 'Ajustar à vista',\n};\nexport default pt as Record<string, string>;\n"]}
|
|
1
|
+
{"version":3,"file":"pt.js","sourceRoot":"","sources":["../../src/locales/pt.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG;IACT,gBAAgB,EAAE,mBAAmB;IACrC,cAAc,EAAE,+CAA+C;IAC/D,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,4BAA4B;IAC5C,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,SAAS;IACrB,aAAa,EAAE,sBAAsB;IACrC,YAAY,EAAE,UAAU;IACxB,cAAc,EAAE,YAAY;IAC5B,WAAW,EAAE,YAAY;IACzB,eAAe,EAAE,YAAY;IAC7B,iBAAiB,EAAE,wCAAwC;IAC3D,gBAAgB,EAAE,eAAe;IACjC,kBAAkB,EAAE,4DAA4D;IAChF,eAAe,EAAE,OAAO;IACxB,gBAAgB,EAAE,gDAAgD;IAClE,kBAAkB,EAAE,8CAA8C;IAClE,mBAAmB,EAAE,mCAAmC;IACxD,WAAW,EAAE,UAAU;IACvB,eAAe,EAAE,QAAQ;IACzB,aAAa,EAAE,QAAQ;IACvB,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,SAAS;IAC1B,YAAY,EAAE,0BAA0B;IACxC,YAAY,EAAE,wBAAwB;IACtC,aAAa,EAAE,WAAW;IAC1B,kBAAkB,EAAE,OAAO;IAC3B,oBAAoB,EAAE,UAAU;IAChC,sBAAsB,EAAE,UAAU;IAClC,YAAY,EAAE,eAAe;IAC7B,qBAAqB,EAAE,QAAQ;IAC/B,mBAAmB,EAAE,WAAW;IAChC,qBAAqB,EAAE,WAAW;IAClC,mBAAmB,EAAE,WAAW;IAChC,gBAAgB,EAAE,MAAM;IACxB,kBAAkB,EAAE,SAAS;IAC7B,mBAAmB,EAAE,SAAS;IAC9B,gBAAgB,EAAE,gBAAgB;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,eAAe;IACjC,gBAAgB,EAAE,OAAO;IACzB,qBAAqB,EAAE,OAAO;IAC9B,iBAAiB,EAAE,KAAK;IACxB,uBAAuB,EAAE,aAAa;IACtC,iBAAiB,EAAE,uBAAuB;IAC1C,kBAAkB,EAAE,SAAS;IAC7B,qBAAqB,EAAE,mBAAmB;IAC1C,qBAAqB,EAAE,UAAU;IACjC,qBAAqB,EAAE,kBAAkB;IACzC,qBAAqB,EAAE,UAAU;IACjC,oBAAoB,EAAE,QAAQ;IAC9B,qBAAqB,EAAE,SAAS;IAChC,qBAAqB,EAAE,mBAAmB;IAC1C,qBAAqB,EAAE,UAAU;IACjC,qBAAqB,EAAE,kBAAkB;IACzC,iBAAiB,EAAE,SAAS;IAC5B,kBAAkB,EAAE,QAAQ;IAC5B,gBAAgB,EAAE,2BAA2B;IAC7C,wBAAwB,EAAE,sBAAsB;IAChD,mBAAmB,EAAE,0BAA0B;IAC/C,YAAY,EAAE,kBAAkB;IAChC,WAAW,EAAE,iBAAiB;IAC9B,YAAY,EAAE,oBAAoB;IAClC,cAAc,EAAE,qBAAqB;IACrC,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,4CAA4C;IACzD,UAAU,EAAE,mCAAmC;IAC/C,WAAW,EAAE,2CAA2C;IACxD,UAAU,EAAE,kCAAkC;IAC9C,WAAW,EAAE,2CAA2C;IACxD,UAAU,EAAE,mCAAmC;IAC/C,WAAW,EAAE,4CAA4C;IACzD,UAAU,EAAE,mCAAmC;IAC/C,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,6BAA6B;CAC5C,CAAC;AACF,eAAe,EAA4B,CAAC","sourcesContent":["const pt = {\n 'editor.loading': 'A carregar imagem',\n 'editor.empty': 'Largue uma imagem aqui ou escolha um ficheiro',\n 'editor.choose': 'Escolher imagem',\n 'editor.error': 'Algo correu mal: {message}',\n 'nav.undo': 'Anular',\n 'nav.redo': 'Refazer',\n 'nav.history': 'Posição no histórico',\n 'nav.export': 'Exportar',\n 'nav.download': 'Transferir',\n 'nav.reset': 'Repor tudo',\n 'nav.exporting': 'A exportar',\n 'status.exported': '{width} por {height} píxeis exportados',\n 'resize.presets': 'Predefinições',\n 'watermark.locked': \"A marca d'água está fixada pela configuração deste editor.\",\n 'annotate.font': 'Fonte',\n 'toast.exported': '{format} exportado, {width} × {height}, {size}',\n 'toast.downloaded': '{format} baixado, {width} × {height}, {size}',\n 'status.dimensions': 'Saída {width} por {height} píxeis',\n 'tool.crop': 'Recortar',\n 'tool.finetune': 'Afinar',\n 'tool.filter': 'Filtro',\n 'tool.resize': 'Tamanho',\n 'crop.rotation': 'Rotação',\n 'crop.flipX': 'Inverter horizontalmente',\n 'crop.flipY': 'Inverter verticalmente',\n 'crop.aspect': 'Proporção',\n 'crop.aspect.free': 'Livre',\n 'crop.aspect.square': 'Quadrado',\n 'crop.aspect.original': 'Original',\n 'crop.reset': 'Repor recorte',\n 'finetune.brightness': 'Brilho',\n 'finetune.contrast': 'Contraste',\n 'finetune.saturation': 'Saturação',\n 'finetune.exposure': 'Exposição',\n 'finetune.gamma': 'Gama',\n 'finetune.clarity': 'Nitidez',\n 'finetune.vignette': 'Vinheta',\n 'finetune.reset': 'Repor afinação',\n 'filter.none': 'Nenhum',\n 'filter.grayscale': 'Escala de cinzentos',\n 'filter.sepia': 'Sépia',\n 'filter.vintage': 'Vintage',\n 'filter.cool': 'Frio',\n 'filter.warm': 'Quente',\n 'filter.invert': 'Inverter',\n 'filter.strength': 'Intensidade',\n 'resize.size': 'Tamanho',\n 'resize.linked': 'Manter proporções',\n 'resize.unlinked': 'Proporções livres',\n 'resize.width': 'Largura',\n 'resize.height': 'Altura',\n 'resize.fit': 'Ajuste',\n 'resize.fit.contain': 'Conter',\n 'resize.fit.cover': 'Cobrir',\n 'resize.fit.fill': 'Esticar',\n 'resize.upscale': 'Permitir ampliar',\n 'resize.clear': 'Limpar tamanho',\n 'resize.pixels': 'px',\n 'tool.redact': 'Ocultar',\n 'redact.shape': 'Forma',\n 'redact.shape.rect': 'Retângulo',\n 'redact.shape.ellipse': 'Elipse',\n 'redact.shape.path': 'Mão livre',\n 'redact.mode': 'Modo',\n 'redact.mode.pixelate': 'Pixelizar',\n 'redact.mode.blur': 'Desfocar',\n 'redact.mode.mosaic': 'Mosaico seguro',\n 'redact.remove': 'Remover área',\n 'redact.region': 'Área {n}',\n 'redact.rotate': 'Girar região',\n 'redact.feather': 'Borda suave',\n 'tool.assist': 'Assistente',\n 'tool.badge': '{count} sugestões',\n 'assist.detect': 'Detetar novamente',\n 'assist.loading': 'A carregar o detetor…',\n 'assist.detecting': 'À procura de regiões…',\n 'assist.found': '{count} sugestões',\n 'assist.none': 'Nada encontrado',\n 'assist.error': 'A deteção falhou: {message}',\n 'assist.timeout': 'A deteção demorou demasiado',\n 'assist.refused': 'Não aceite: as opções de redact não o permitem ({message})',\n 'assist.unavailable': 'Nenhum detetor configurado',\n 'assist.accept': 'Aceitar sugestão',\n 'assist.reject': 'Rejeitar sugestão',\n 'assist.acceptAll': 'Aceitar todas',\n 'assist.rejectAll': 'Rejeitar todas',\n 'assist.needsRedact': 'Requer o plugin redact',\n 'tool.annotate': 'Anotar',\n 'annotate.shape': 'Forma',\n 'annotate.kind.rect': 'Retângulo',\n 'annotate.kind.ellipse': 'Elipse',\n 'annotate.kind.line': 'Linha',\n 'annotate.kind.arrow': 'Seta',\n 'annotate.kind.path': 'Mão livre',\n 'annotate.kind.text': 'Texto',\n 'annotate.stroke': 'Cor',\n 'annotate.width': 'Espessura da linha',\n 'annotate.fill': 'Preenchimento',\n 'annotate.fillColor': 'Cor de preenchimento',\n 'annotate.color': 'Cor',\n 'annotate.background': 'Fundo',\n 'annotate.noBackground': 'Sem fundo',\n 'annotate.lineHeight': 'Entrelinha',\n 'annotate.align': 'Alinhamento',\n 'annotate.align.left': 'Alinhar à esquerda',\n 'annotate.align.center': 'Centralizar',\n 'annotate.align.right': 'Alinhar à direita',\n 'annotate.text': 'Texto',\n 'annotate.size': 'Tamanho da letra',\n 'annotate.delete': 'Eliminar forma',\n 'annotate.shapeLabel': '{kind} {n}',\n 'annotate.rotate': 'Girar forma',\n 'annotate.defaultText': 'Texto',\n 'tool.sticker': 'Autocolante',\n 'sticker.upload': 'Carregar imagem de autocolante',\n 'sticker.library': 'Autocolantes',\n 'sticker.hint.empty': 'Carregue um PNG, JPEG ou WebP para o usar como autocolante.',\n 'sticker.rotation': 'Rotação',\n 'sticker.opacity': 'Opacidade',\n 'sticker.delete': 'Eliminar autocolante',\n 'sticker.item': 'Autocolante {n}',\n 'tool.frame': 'Moldura',\n 'frame.style': 'Estilo',\n 'frame.none': 'Nenhuma',\n 'frame.style.solid': 'Sólida',\n 'frame.style.inset': 'Linha interior',\n 'frame.style.polaroid': 'Polaroid',\n 'frame.color': 'Cor',\n 'frame.radius': 'Raio dos cantos',\n 'tool.watermark': 'Marca de água',\n 'watermark.text': 'Texto',\n 'watermark.textValue': 'Texto',\n 'watermark.color': 'Cor',\n 'watermark.defaultText': '© sealpixel',\n 'watermark.clear': 'Remover marca de água',\n 'watermark.anchor': 'Posição',\n 'watermark.anchor.tl': 'Superior esquerdo',\n 'watermark.anchor.tc': 'Superior',\n 'watermark.anchor.tr': 'Superior direito',\n 'watermark.anchor.cl': 'Esquerda',\n 'watermark.anchor.c': 'Centro',\n 'watermark.anchor.cr': 'Direita',\n 'watermark.anchor.bl': 'Inferior esquerdo',\n 'watermark.anchor.bc': 'Inferior',\n 'watermark.anchor.br': 'Inferior direito',\n 'watermark.scale': 'Tamanho',\n 'watermark.margin': 'Margem',\n 'watermark.tile': 'Repetir por toda a imagem',\n 'watermark.tileRotation': 'Rotação dos mosaicos',\n 'watermark.tileGap': 'Espaçamento dos mosaicos',\n 'stage.zoom': 'Zoom {percent} %',\n 'stage.fit': 'Ajustar à vista',\n 'redact.add': 'Adicionar uma área',\n 'annotate.add': 'Adicionar uma forma',\n 'crop.area': 'Área de recorte',\n 'handle.nw': 'Redimensionar pelo canto superior esquerdo',\n 'handle.n': 'Redimensionar pela borda superior',\n 'handle.ne': 'Redimensionar pelo canto superior direito',\n 'handle.e': 'Redimensionar pela borda direita',\n 'handle.se': 'Redimensionar pelo canto inferior direito',\n 'handle.s': 'Redimensionar pela borda inferior',\n 'handle.sw': 'Redimensionar pelo canto inferior esquerdo',\n 'handle.w': 'Redimensionar pela borda esquerda',\n 'handle.from': 'Ponto inicial',\n 'handle.to': 'Ponto final',\n 'stage.size': '{width} por {height} píxeis',\n};\nexport default pt as Record<string, string>;\n"]}
|
package/dist/tools/annotate.d.ts
CHANGED
|
@@ -1,2 +1,60 @@
|
|
|
1
|
+
import type { Color, Rect } from '@sealpixel/core';
|
|
1
2
|
import type { UiTool } from '../tool.js';
|
|
3
|
+
import { type Frame } from './region-transform.js';
|
|
4
|
+
type Point = [number, number];
|
|
5
|
+
interface Stroke {
|
|
6
|
+
color: Color;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
type Shape = {
|
|
10
|
+
kind: 'rect';
|
|
11
|
+
rect: Rect;
|
|
12
|
+
stroke?: Stroke | undefined;
|
|
13
|
+
fill?: Color | undefined;
|
|
14
|
+
radius?: number | undefined;
|
|
15
|
+
rotation?: number | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'ellipse';
|
|
18
|
+
rect: Rect;
|
|
19
|
+
stroke?: Stroke | undefined;
|
|
20
|
+
fill?: Color | undefined;
|
|
21
|
+
rotation?: number | undefined;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'line';
|
|
24
|
+
from: Point;
|
|
25
|
+
to: Point;
|
|
26
|
+
stroke: Stroke;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'arrow';
|
|
29
|
+
from: Point;
|
|
30
|
+
to: Point;
|
|
31
|
+
stroke: Stroke;
|
|
32
|
+
head?: number | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'path';
|
|
35
|
+
points: Point[];
|
|
36
|
+
stroke: Stroke;
|
|
37
|
+
closed?: boolean | undefined;
|
|
38
|
+
fill?: Color | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'text';
|
|
41
|
+
rect: Rect;
|
|
42
|
+
text: string;
|
|
43
|
+
font: string;
|
|
44
|
+
size: number;
|
|
45
|
+
color: Color;
|
|
46
|
+
align?: 'left' | 'center' | 'right' | undefined;
|
|
47
|
+
lineHeight?: number | undefined;
|
|
48
|
+
background?: Color | undefined;
|
|
49
|
+
padding?: number | undefined;
|
|
50
|
+
rotation?: number | undefined;
|
|
51
|
+
};
|
|
2
52
|
export declare const annotateTool: UiTool;
|
|
53
|
+
/**
|
|
54
|
+
* The shape a frame stands for. A boxed shape takes the frame's rect and its
|
|
55
|
+
* rotation, the field left out at zero so an unturned shape reads as before;
|
|
56
|
+
* a path maps its points from the old frame into the new one. Null when the
|
|
57
|
+
* result would leave the image: the last one that fit stays.
|
|
58
|
+
*/
|
|
59
|
+
export declare function shapeInFrame(origin: Shape, from: Frame, to: Frame, W: number, H: number): Shape | null;
|
|
60
|
+
export {};
|
package/dist/tools/annotate.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ANNOTATE_DEFAULT_OPTIONS, colorFromHex } from '@sealpixel/plugins';
|
|
2
2
|
import { html, nothing, svg } from 'lit';
|
|
3
3
|
import { icons } from '../icons.js';
|
|
4
|
-
import { cropClipPath } from './crop-mask.js';
|
|
4
|
+
import { cropBox, cropClipPath } from './crop-mask.js';
|
|
5
5
|
import { deleteHandle, pointsBox, toPx } from './delete-handle.js';
|
|
6
6
|
import { opId } from './finetune.js';
|
|
7
|
-
import {
|
|
7
|
+
import { toolState } from './instance-state.js';
|
|
8
|
+
import { announce, elementKeys, focusEditor, focusWhen, newShapeBox, octagonIn, sliderAngle, sliderKeys, viewOf, } from './keys.js';
|
|
8
9
|
import { corners, mapPoints, resize, slide, snapAngle, } from './region-transform.js';
|
|
9
10
|
const KINDS = ['rect', 'ellipse', 'line', 'arrow', 'path', 'text'];
|
|
10
11
|
/** Annotate coordinates live in image space: show the image before crop and resize. */
|
|
@@ -18,7 +19,7 @@ function beforeCrop(log) {
|
|
|
18
19
|
],
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
+
const createAnnotateState = () => ({
|
|
22
23
|
kind: 'rect',
|
|
23
24
|
stroke: [1, 0.2, 0.2, 1],
|
|
24
25
|
width: 4,
|
|
@@ -28,9 +29,10 @@ const state = {
|
|
|
28
29
|
drawing: null,
|
|
29
30
|
drag: null,
|
|
30
31
|
transform: null,
|
|
32
|
+
angle: null,
|
|
31
33
|
editingText: null,
|
|
32
34
|
focusPending: null,
|
|
33
|
-
};
|
|
35
|
+
});
|
|
34
36
|
const hex = (c) => `#${[c[0], c[1], c[2]]
|
|
35
37
|
.map((v) => Math.round(v * 255)
|
|
36
38
|
.toString(16)
|
|
@@ -66,16 +68,19 @@ export const annotateTool = {
|
|
|
66
68
|
ctx.session.setPreviewTransform(beforeCrop);
|
|
67
69
|
},
|
|
68
70
|
deactivate: (ctx) => {
|
|
71
|
+
const state = toolState(ctx, createAnnotateState);
|
|
69
72
|
state.drawing = null;
|
|
70
73
|
state.drag = null;
|
|
71
74
|
state.transform = null;
|
|
72
75
|
state.selected = null;
|
|
73
76
|
state.editingText = null;
|
|
74
77
|
state.focusPending = null;
|
|
78
|
+
state.angle = null;
|
|
75
79
|
ctx.clipPreview(null);
|
|
76
80
|
ctx.session.setPreviewTransform(null);
|
|
77
81
|
},
|
|
78
82
|
panel: (ctx) => {
|
|
83
|
+
const state = toolState(ctx, createAnnotateState);
|
|
79
84
|
clipToCrop(ctx);
|
|
80
85
|
const doc = ctx.document.annotate;
|
|
81
86
|
const options = ctx.options('annotate') ?? ANNOTATE_DEFAULT_OPTIONS;
|
|
@@ -208,6 +213,7 @@ export const annotateTool = {
|
|
|
208
213
|
`;
|
|
209
214
|
},
|
|
210
215
|
overlay: (ctx) => {
|
|
216
|
+
const state = toolState(ctx, createAnnotateState);
|
|
211
217
|
const doc = ctx.document.annotate;
|
|
212
218
|
const { width: W, height: H, zoom } = ctx.stage;
|
|
213
219
|
if (!W || !H)
|
|
@@ -217,6 +223,33 @@ export const annotateTool = {
|
|
|
217
223
|
const p = ctx.stage.toImage(e.clientX, e.clientY);
|
|
218
224
|
return [clamp01(p.x / W), clamp01(p.y / H)];
|
|
219
225
|
};
|
|
226
|
+
// Enter or Space on the focused image adds a shape of the current kind in
|
|
227
|
+
// the middle of what is in view; the arrow keys and the handles take it
|
|
228
|
+
// from there.
|
|
229
|
+
const addKey = (e) => {
|
|
230
|
+
if (e.altKey || e.ctrlKey || e.metaKey || e.repeat)
|
|
231
|
+
return;
|
|
232
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
233
|
+
return;
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
if (state.drawing || state.drag || state.transform)
|
|
236
|
+
return;
|
|
237
|
+
const crop = ctx.session.getDocument().crop;
|
|
238
|
+
const box = newShapeBox(W, H, viewOf(e.currentTarget, ctx.stage.toImage), cropBox(crop, W, H));
|
|
239
|
+
const points = octagonIn(box);
|
|
240
|
+
const shape = shapeFromDrawing({
|
|
241
|
+
start: [box.x, box.y],
|
|
242
|
+
current: [box.x + box.width, box.y + box.height],
|
|
243
|
+
points: [...points, points[0]],
|
|
244
|
+
}, state.kind, ctx);
|
|
245
|
+
if (!shape)
|
|
246
|
+
return;
|
|
247
|
+
const id = opId();
|
|
248
|
+
ctx.dispatch({ type: 'annotate.add', id, shape });
|
|
249
|
+
state.selected = id;
|
|
250
|
+
state.focusPending = id;
|
|
251
|
+
ctx.refresh();
|
|
252
|
+
};
|
|
220
253
|
const down = (e) => {
|
|
221
254
|
e.stopPropagation();
|
|
222
255
|
e.preventDefault();
|
|
@@ -436,15 +469,78 @@ export const annotateTool = {
|
|
|
436
469
|
window.addEventListener('pointercancel', up);
|
|
437
470
|
};
|
|
438
471
|
const origin = a.shape;
|
|
472
|
+
// The keys on a focused handle drive the same transient transform as a
|
|
473
|
+
// pointer drag and the release commits one update. A step that would
|
|
474
|
+
// leave the image is skipped.
|
|
475
|
+
const keyed = state.transform?.keys && state.transform.id === a.id ? state.transform : null;
|
|
476
|
+
const setKeyed = (shape, frame, degrees) => {
|
|
477
|
+
if (!shape)
|
|
478
|
+
return;
|
|
479
|
+
state.transform = {
|
|
480
|
+
id: a.id,
|
|
481
|
+
origin: keyed?.origin ?? origin,
|
|
482
|
+
shape,
|
|
483
|
+
keys: true,
|
|
484
|
+
...(frame ? { frame } : {}),
|
|
485
|
+
...(degrees === undefined ? {} : { degrees }),
|
|
486
|
+
};
|
|
487
|
+
ctx.refresh();
|
|
488
|
+
};
|
|
489
|
+
const busy = () => !!(state.drawing || state.drag || (state.transform && !keyed));
|
|
490
|
+
const commitKeys = (e) => {
|
|
491
|
+
const t = state.transform;
|
|
492
|
+
if (!t?.keys || t.id !== a.id)
|
|
493
|
+
return;
|
|
494
|
+
state.transform = null;
|
|
495
|
+
if (t.degrees !== undefined) {
|
|
496
|
+
state.angle = { id: a.id, degrees: t.degrees, of: JSON.stringify(t.shape) };
|
|
497
|
+
}
|
|
498
|
+
if (JSON.stringify(t.shape) !== JSON.stringify(t.origin)) {
|
|
499
|
+
ctx.dispatch({ type: 'annotate.update', id: opId(), shapeId: a.id, shape: t.shape });
|
|
500
|
+
const src = ctx.state.source;
|
|
501
|
+
const turned = t.frame && t.frame.rotation !== frameOf(t.origin, 1, 1).rotation;
|
|
502
|
+
if (src && t.frame && !turned) {
|
|
503
|
+
const size = frameOf(t.shape, src.width, src.height);
|
|
504
|
+
announce(e.target, ctx.t('stage.size', {
|
|
505
|
+
width: Math.round(size.width),
|
|
506
|
+
height: Math.round(size.height),
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
ctx.refresh();
|
|
511
|
+
};
|
|
512
|
+
const cancelKeys = () => {
|
|
513
|
+
if (!state.transform?.keys)
|
|
514
|
+
return false;
|
|
515
|
+
state.transform = null;
|
|
516
|
+
ctx.refresh();
|
|
517
|
+
return true;
|
|
518
|
+
};
|
|
519
|
+
const handleKeys = (move) => elementKeys(ctx.stage, {
|
|
520
|
+
select: () => { },
|
|
521
|
+
move: (dx, dy) => {
|
|
522
|
+
if (!busy())
|
|
523
|
+
move(dx, dy);
|
|
524
|
+
},
|
|
525
|
+
commit: commitKeys,
|
|
526
|
+
remove: () => { },
|
|
527
|
+
escape: cancelKeys,
|
|
528
|
+
});
|
|
439
529
|
if (origin.kind === 'line' || origin.kind === 'arrow') {
|
|
440
530
|
const ends = s;
|
|
441
531
|
const end = (which) => (e) => track(e, (q) => ({
|
|
442
532
|
...origin,
|
|
443
533
|
[which]: [clamp01(q.x / W), clamp01(q.y / H)],
|
|
444
534
|
}));
|
|
535
|
+
const endKeys = (which) => handleKeys((dx, dy) => {
|
|
536
|
+
const p = ends[which];
|
|
537
|
+
setKeyed({ ...ends, [which]: [clamp01(p[0] + dx), clamp01(p[1] + dy)] });
|
|
538
|
+
});
|
|
539
|
+
const fk = endKeys('from');
|
|
540
|
+
const tk = endKeys('to');
|
|
445
541
|
return svg `
|
|
446
|
-
<circle data-interactive data-handle="from" cx=${ends.from[0] * W} cy=${ends.from[1] * H} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style="cursor:move" @pointerdown=${end('from')} />
|
|
447
|
-
<circle data-interactive data-handle="to" cx=${ends.to[0] * W} cy=${ends.to[1] * H} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style="cursor:move" @pointerdown=${end('to')} />
|
|
542
|
+
<circle data-interactive data-handle="from" tabindex="0" role="button" aria-label=${ctx.t('handle.from')} cx=${ends.from[0] * W} cy=${ends.from[1] * H} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style="cursor:move" @pointerdown=${end('from')} @keydown=${fk.keydown} @keyup=${fk.keyup} @blur=${fk.blur} />
|
|
543
|
+
<circle data-interactive data-handle="to" tabindex="0" role="button" aria-label=${ctx.t('handle.to')} cx=${ends.to[0] * W} cy=${ends.to[1] * H} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style="cursor:move" @pointerdown=${end('to')} @keydown=${tk.keydown} @keyup=${tk.keyup} @blur=${tk.blur} />
|
|
448
544
|
`;
|
|
449
545
|
}
|
|
450
546
|
const from = frameOf(origin, W, H);
|
|
@@ -467,7 +563,28 @@ export const annotateTool = {
|
|
|
467
563
|
const bottom = mid(se, sw2);
|
|
468
564
|
const stem = 28 / zoom;
|
|
469
565
|
const knob = [bottom[0] - sin * stem, bottom[1] + cos * stem];
|
|
470
|
-
|
|
566
|
+
// The slider shows the angle the keys set last, not the angle of the
|
|
567
|
+
// stored shape, so its value never jumps and Home and End are absolute.
|
|
568
|
+
const angle = keyed?.degrees ?? sliderAngle(state.angle, a.id, origin, (from.rotation * 180) / Math.PI);
|
|
569
|
+
const degrees = Math.round(angle);
|
|
570
|
+
const stepFrame = (next, degrees) => {
|
|
571
|
+
const to = next(keyed?.frame ?? from);
|
|
572
|
+
const shape = shapeInFrame(origin, from, to, W, H);
|
|
573
|
+
if (shape)
|
|
574
|
+
setKeyed(shape, to, degrees);
|
|
575
|
+
};
|
|
576
|
+
const turnKeys = sliderKeys({ min: -180, max: 180, step: 1, largeStep: 15 }, {
|
|
577
|
+
// No snap to the quarter here: it would swallow every small step.
|
|
578
|
+
// The step turns the frame by the change of the slider's value.
|
|
579
|
+
set: (next) => {
|
|
580
|
+
if (busy())
|
|
581
|
+
return;
|
|
582
|
+
const degrees = next(angle);
|
|
583
|
+
stepFrame((f) => ({ ...f, rotation: f.rotation + ((degrees - angle) * Math.PI) / 180 }), degrees);
|
|
584
|
+
},
|
|
585
|
+
commit: commitKeys,
|
|
586
|
+
escape: cancelKeys,
|
|
587
|
+
});
|
|
471
588
|
const cursor = {
|
|
472
589
|
nw: 'nwse-resize',
|
|
473
590
|
se: 'nwse-resize',
|
|
@@ -489,13 +606,16 @@ export const annotateTool = {
|
|
|
489
606
|
};
|
|
490
607
|
return svg `
|
|
491
608
|
<line x1=${bottom[0]} y1=${bottom[1]} x2=${knob[0]} y2=${knob[1]} stroke="var(--sealpixel-color-accent)" stroke-width=${sw} pointer-events="none" />
|
|
492
|
-
${at.map(([id, p]) =>
|
|
493
|
-
|
|
609
|
+
${at.map(([id, p]) => {
|
|
610
|
+
const k = handleKeys((dx, dy) => stepFrame((f) => resize(f, id, dx * W, dy * H, 6 / zoom)));
|
|
611
|
+
return svg `<circle data-interactive data-handle=${id} tabindex="0" role="button" aria-label=${ctx.t(`handle.${id}`)} cx=${p[0]} cy=${p[1]} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style=${`cursor:${cursor[id]}`} @pointerdown=${grab(id)} @keydown=${k.keydown} @keyup=${k.keyup} @blur=${k.blur} />`;
|
|
612
|
+
})}
|
|
613
|
+
<circle data-interactive data-handle="rotate" tabindex="0" role="slider" aria-label=${ctx.t('annotate.rotate')} aria-valuemin="-180" aria-valuemax="180" aria-valuenow=${degrees} aria-valuetext=${`${degrees}°`} cx=${knob[0]} cy=${knob[1]} r=${hr * 1.15} fill="var(--sealpixel-color-accent)" stroke="white" stroke-width=${sw} style="cursor:grab" @pointerdown=${turn} @keydown=${turnKeys.keydown} @keyup=${turnKeys.keyup} @blur=${turnKeys.blur} />
|
|
494
614
|
`;
|
|
495
615
|
};
|
|
496
616
|
const options = ctx.options('annotate') ?? ANNOTATE_DEFAULT_OPTIONS;
|
|
497
617
|
return svg `
|
|
498
|
-
<rect data-interactive data-canvas x="0" y="0" width=${W} height=${H} fill="transparent" style="cursor:crosshair" @pointerdown=${down} />
|
|
618
|
+
<rect data-interactive data-canvas tabindex="0" role="button" aria-label=${ctx.t('annotate.add')} x="0" y="0" width=${W} height=${H} fill="transparent" stroke-width=${2 / zoom} style="cursor:crosshair" @pointerdown=${down} @keydown=${addKey} />
|
|
499
619
|
${doc.shapes.map(outline)}
|
|
500
620
|
${selected && options.transform && !state.drag ? transformHandles(selected) : nothing}
|
|
501
621
|
${selected
|
|
@@ -542,7 +662,7 @@ function frameOf(s, W, H) {
|
|
|
542
662
|
* a path maps its points from the old frame into the new one. Null when the
|
|
543
663
|
* result would leave the image: the last one that fit stays.
|
|
544
664
|
*/
|
|
545
|
-
function shapeInFrame(origin, from, to, W, H) {
|
|
665
|
+
export function shapeInFrame(origin, from, to, W, H) {
|
|
546
666
|
const inside = (p) => p[0] >= -1e-9 && p[0] <= 1 + 1e-9 && p[1] >= -1e-9 && p[1] <= 1 + 1e-9;
|
|
547
667
|
if (origin.kind === 'rect' || origin.kind === 'ellipse' || origin.kind === 'text') {
|
|
548
668
|
if (!corners(to).every((p) => inside([p[0] / W, p[1] / H])))
|
|
@@ -554,7 +674,10 @@ function shapeInFrame(origin, from, to, W, H) {
|
|
|
554
674
|
width: to.width / W,
|
|
555
675
|
height: to.height / H,
|
|
556
676
|
};
|
|
557
|
-
|
|
677
|
+
// Turns add up over drags: keep the angle within -180 to 180 degrees, as
|
|
678
|
+
// the log accepts one full turn at most.
|
|
679
|
+
const rotation = Math.atan2(Math.sin(to.rotation), Math.cos(to.rotation));
|
|
680
|
+
return to.rotation === 0 ? { ...rest, rect } : { ...rest, rect, rotation };
|
|
558
681
|
}
|
|
559
682
|
const src = origin.kind === 'path' ? origin.points : [origin.from, origin.to];
|
|
560
683
|
const mapped = mapPoints(src.map((p) => [p[0] * W, p[1] * H]), from, to).map((p) => [p[0] / W, p[1] / H]);
|
|
@@ -586,6 +709,7 @@ const ICONS = {
|
|
|
586
709
|
text: 'T',
|
|
587
710
|
};
|
|
588
711
|
function shapeFromDrawing(d, kind, ctx) {
|
|
712
|
+
const state = toolState(ctx, createAnnotateState);
|
|
589
713
|
const stroke = { color: state.stroke, width: state.width };
|
|
590
714
|
const x = Math.min(d.start[0], d.current[0]);
|
|
591
715
|
const y = Math.min(d.start[1], d.current[1]);
|