Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

skinview-utils

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

skinview-utils - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

66

build/process.js

@@ -44,15 +44,54 @@ function copyImage(context, sX, sY, w, h, dX, dY, flipHorizontal) {

}
function fixOpaqueSkin(context, width) {
// Some ancient skins don't have transparent pixels (nor have helm).
// We have to make the helm area transparent, otherwise it will be rendered as black.
if (!hasTransparency(context, 0, 0, width, width / 2)) {
const scale = computeSkinScale(width);
const clearArea = (x, y, w, h) => context.clearRect(x * scale, y * scale, w * scale, h * scale);
clearArea(40, 0, 8, 8); // Helm Top
clearArea(48, 0, 8, 8); // Helm Bottom
clearArea(32, 8, 8, 8); // Helm Right
clearArea(40, 8, 8, 8); // Helm Front
clearArea(48, 8, 8, 8); // Helm Left
clearArea(56, 8, 8, 8); // Helm Back
function fixOpaqueSkin(context, width, format1_8) {
// see https://github.com/bs-community/skinview3d/issues/15
// see https://github.com/bs-community/skinview3d/issues/93
// check whether the skin has opaque background
if (format1_8) {
if (hasTransparency(context, 0, 0, width, width))
return;
}
else {
if (hasTransparency(context, 0, 0, width, width / 2))
return;
}
const scale = computeSkinScale(width);
const clearArea = (x, y, w, h) => context.clearRect(x * scale, y * scale, w * scale, h * scale);
clearArea(40, 0, 8, 8); // Helm Top
clearArea(48, 0, 8, 8); // Helm Bottom
clearArea(32, 8, 8, 8); // Helm Right
clearArea(40, 8, 8, 8); // Helm Front
clearArea(48, 8, 8, 8); // Helm Left
clearArea(56, 8, 8, 8); // Helm Back
if (format1_8) {
clearArea(4, 32, 4, 4); // Right Leg Layer 2 Top
clearArea(8, 32, 4, 4); // Right Leg Layer 2 Bottom
clearArea(0, 36, 4, 12); // Right Leg Layer 2 Right
clearArea(4, 36, 4, 12); // Right Leg Layer 2 Front
clearArea(8, 36, 4, 12); // Right Leg Layer 2 Left
clearArea(12, 36, 4, 12); // Right Leg Layer 2 Back
clearArea(20, 32, 8, 4); // Torso Layer 2 Top
clearArea(28, 32, 8, 4); // Torso Layer 2 Bottom
clearArea(16, 36, 4, 12); // Torso Layer 2 Right
clearArea(20, 36, 8, 12); // Torso Layer 2 Front
clearArea(28, 36, 4, 12); // Torso Layer 2 Left
clearArea(32, 36, 8, 12); // Torso Layer 2 Back
clearArea(44, 32, 4, 4); // Right Arm Layer 2 Top
clearArea(48, 32, 4, 4); // Right Arm Layer 2 Bottom
clearArea(40, 36, 4, 12); // Right Arm Layer 2 Right
clearArea(44, 36, 4, 12); // Right Arm Layer 2 Front
clearArea(48, 36, 4, 12); // Right Arm Layer 2 Left
clearArea(52, 36, 12, 12); // Right Arm Layer 2 Back
clearArea(4, 48, 4, 4); // Left Leg Layer 2 Top
clearArea(8, 48, 4, 4); // Left Leg Layer 2 Bottom
clearArea(0, 52, 4, 12); // Left Leg Layer 2 Right
clearArea(4, 52, 4, 12); // Left Leg Layer 2 Front
clearArea(8, 52, 4, 12); // Left Leg Layer 2 Left
clearArea(12, 52, 4, 12); // Left Leg Layer 2 Back
clearArea(52, 48, 4, 4); // Left Arm Layer 2 Top
clearArea(56, 48, 4, 4); // Left Arm Layer 2 Bottom
clearArea(48, 52, 4, 12); // Left Arm Layer 2 Right
clearArea(52, 52, 4, 12); // Left Arm Layer 2 Front
clearArea(56, 52, 4, 12); // Left Arm Layer 2 Left
clearArea(60, 52, 4, 12); // Left Arm Layer 2 Back
}
}

@@ -62,3 +101,2 @@ function convertSkinTo1_8(context, width) {

const copySkin = (sX, sY, w, h, dX, dY, flipHorizontal) => copyImage(context, sX * scale, sY * scale, w * scale, h * scale, dX * scale, dY * scale, flipHorizontal);
fixOpaqueSkin(context, width);
copySkin(4, 16, 4, 4, 20, 48, true); // Top Leg

@@ -95,2 +133,3 @@ copySkin(8, 16, 4, 4, 24, 48, true); // Bottom Leg

convertSkinTo1_8(context, sideLength);
fixOpaqueSkin(context, canvas.width, false);
}

@@ -102,2 +141,3 @@ else {

context.drawImage(image, 0, 0, canvas.width, canvas.height);
fixOpaqueSkin(context, canvas.width, true);
}

@@ -104,0 +144,0 @@ }

@@ -0,1 +1,2 @@

/// <reference types="offscreencanvas" />
export declare type TextureCanvas = HTMLCanvasElement | OffscreenCanvas;

@@ -2,0 +3,0 @@ export declare type TextureSource = HTMLImageElement | HTMLVideoElement | ImageBitmap | TextureCanvas;

37

package.json
{
"name": "skinview-utils",
"version": "0.6.0",
"version": "0.6.1",
"description": "Utilities for working with Minecraft skins",

@@ -14,21 +14,21 @@ "type": "module",

"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-image": "^2.0.6",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-typescript": "^8.1.0",
"@types/chai": "^4.2.14",
"@types/mocha": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"chai": "^4.2.0",
"eslint": "^7.16.0",
"karma": "^5.2.3",
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-image": "^2.1.1",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-typescript": "^8.2.5",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-rollup-preprocessor": "^7.0.5",
"mocha": "^8.2.1",
"puppeteer": "^5.5.0",
"karma-rollup-preprocessor": "^7.0.7",
"mocha": "^9.1.1",
"puppeteer": "^10.2.0",
"rimraf": "^3.0.2",
"rollup": "^2.35.1",
"typescript": "^4.1.3"
"rollup": "^2.56.3",
"typescript": "^4.4.2"
},

@@ -52,3 +52,6 @@ "files": [

"url": "git+https://github.com/bs-community/skinview-utils.git"
},
"dependencies": {
"@types/offscreencanvas": "^2019.6.3"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc