Skip to content

chooaya/OnionRing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a TypeScript version of OnionRing,can be used in Cocos Creator or other JavaScript APP.

WARNING

Before using the OnionRing,Please install the dependencies first!

dependencies

"@types/node", "@types/pngjs": "^3.3.2" "pngjs": "^3.4.0"

npm install typescript
npm install @types/node
npm install pngjs  --save
npm install --save @types/pngjs

After dependencies all installed , you can use download OnionRing.ts and import OnionRing into you project.

import * as OnionRing from "./OnionRing";

you can get the slice position auto computed by OnionRing.

// rawTextureMetaInfo["assetPath"] can be the url of any png image ex: C:\test\Sample\background.png
let texture: OnionRing.Texture2D = new OnionRing.Texture2D(
        rawTextureMetaInfo["assetPath"]
      );
      let slicedTexture = OnionRing.TextureSlicer.Slice(texture);
      console.log(
        "slicedTexture.Boarder.Left:" +
          slicedTexture.Boarder.Left +
          " slicedTexture.Boarder.Right:" +
          " slicedTexture.Boarder.Top:" +
          slicedTexture.Boarder.Top +
          " slicedTexture.Boarder.Bottom:" +
          slicedTexture.Boarder.Bottom
      );

OnionRing

before before.png

after after.png

And automatic sprite slice!

4c30a682-b636-bd88-b941-8d4a46981625

Sample Code

https://github.com/kyubuns/OnionRingUnity/blob/master/Assets/OnionRingSample/Editor/OnionRingSampleImporter.cs

Licence

MIT

About

based on auto 9 slice sprite generator on Unity

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 62.2%
  • C# 37.8%