ํฌํ ์ต(PSD) ํ์ผ์ ๋ค๋ฃจ๋ค ๋ณด๋ฉด ๋จ์ํ ๋ ์ด์ด๋ฅผ ๋ฝ๋ ๊ฑธ ๋์ด์,
๋ ์ด์ด ๊ตฌ์กฐ, ์ด๋ฏธ์ง ๋ฒํผ ์ด์, ํ
์คํธ ์คํ์ผ ๊ฐ์ ๋ถ๋ถ์์ ๊ฝค ๋ค์ํ ๋ฌธ์ ๊ฐ ์๊น๋๋ค.
์ค์ ๋ก ๋ถ๋ชํ๋ฉด์ ์ ๋ฆฌํด๋ ๋ด์ฉ์ด๋ผ, ๋น์ทํ ์ํฉ์์ ์ฐธ๊ณ ํ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
PSD ํ์ผ์ ๋ ์ด์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํธ๋ฆฌ ๊ตฌ์กฐ์
๋๋ค.
๋ ์ด์ด ๊ทธ๋ฃน(group) ์์ ๋ ๋ค๋ฅธ ๋ ์ด์ด๋ค์ด ๋ค์ด์๊ณ , ๋ ๊ทธ ์์๋โฆ ์ด๋ฐ ์์ด์์.
๊ทธ๋์ ๊ทธ๋ฃน ๋ด๋ถ๊น์ง ํ์ํ๋ ค๋ฉด ๋ณดํต ์ฌ๊ท๊ฐ ํ์ํฉ๋๋ค.
@webtoon/psd
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ psdFile.layers
๋ผ๋ ํ๋ซํ ๋ฐฐ์ด์ ์ ๊ณตํฉ๋๋ค.
for
๋ฌธ ํ๋๋ก ๋๋ฉ๋๋คfor (const layer of psdFile.layers) {
// group ๋ด๋ถ๊น์ง ํฌํจํด์ ์ ๋ถ ์ํ ๊ฐ๋ฅ
}
๋ณดํต RGBA ๋ฒํผ๋ width * height * 4
๋ฐ์ดํธ์ฌ์ผ ์ ์์ด์ฃ .
๊ทธ๋ฐ๋ฐ ๊ฐํน ์ด ๊ธธ์ด๊ฐ ๋ง์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค.
์๋ฅผ ๋ค๋ฉด:
์ผ๋จ ์บ๋ฒ์ค๋ฅผ ๋ง๋ค๊ณ , ๊ฐ๋ฅํ ๋ฒ์๊น์ง๋ง ๋ณต์ฌํ ๋ค
๋ชจ์๋ผ๋ ๋ถ๋ถ์ ํฌ๋ช
์ผ๋ก ์ฑ์์ ์ฒ๋ฆฌํ์ต๋๋ค.
const layerCanvas = document.createElement('canvas');
layerCanvas.width = layerWidth;
layerCanvas.height = layerHeight;
const ctx = layerCanvas.getContext('2d');
const imageData = ctx.createImageData(layerWidth, layerHeight);
const copyLen = Math.min(layerBuffer.length, imageData.data.length);
for (let i = 0; i < copyLen; i++) {
imageData.data[i] = layerBuffer[i];
}
ctx.putImageData(imageData, 0, 0);
const dataURL = layerCanvas.toDataURL('image/png');
ํ
์คํธ ์คํ์ผ๋ ์๊ฐ๋ณด๋ค ์ ๊ฒฝ ์ธ ๊ฒ ๋ง์ต๋๋ค.
PSD์์ ๊บผ๋ธ ํ
์คํธ๋ฅผ ์น์ ๋ง๊ฒ CSS๋ก ๋ณํํ ๋ ์ฐธ๊ณ ํ ๋งคํ ๋ด์ฉ์
๋๋ค.
์์น:
StyleSheetData.FontSize
(pt ๋จ์)
๋ณํ:
1pt = 1.333px
(96dpi ๊ธฐ์ค)StyleSheetData.Leading
(pt)lineHeightEm = (LeadingPt * 1.333) / fontSizePx
FillColor.Values
โ [R, G, B, A]
(0~1 float)const rgba = values.map(v => Math.round(v * 255));
const cssColor = `rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3] / 255})`;
์์น:
StyleSheetData.Font
โ ์ธ๋ฑ์คResourceDict.FontSet[n].Name
โ ์ค์ ํฐํธ๋ช
์์น:
FauxBold
: true๋ฉด bold
FauxItalic
: true๋ฉด italic
์์น:
ParagraphSheet.Properties.Justification
๊ฐ:
StyleSheetData.Tracking
(1/1000 em ๋จ์)const letterSpacingPx = (Tracking / 1000) * fontSizePx;
const letterSpacingEm = letterSpacingPx / fontSizePx;
์์น:
FontCaps
๊ฐ:
์คํ์ผ ์์ฑ | PSD ์์น | ๋ณํ ๋ฐฉ์ |
---|---|---|
font-size | FontSize (pt) | pt โ px / TySh ์ ์ฉ |
line-height | Leading (pt) | pt โ px โ em |
color | FillColor.Values | 0~1 float โ rgba |
font-family | Font + FontSet.Name | ํฐํธ ์ธ๋ฑ์ค ๋งคํ |
font-weight | FauxBold | true โ bold |
font-style | FauxItalic | true โ italic |
text-align | Justification | 0~3 โ CSS ์ ๋ ฌ |
letter-spacing | Tracking | (Tracking / 1000) * fontSizePx |
text-transform | FontCaps | 0~2 โ normal/small-caps/uppercase |
PSD ํ์ฑ์ ๋จ์ํ ๋ ์ด์ด๋ฅผ ๋ฝ๋ ๊ฑธ ๋์ด์,
ํ์ผ ๊ตฌ์กฐ๋ ์์ธ ์ผ์ด์ค๊น์ง ๊ณ ๋ คํ ์ฒ๋ฆฌ๊ฐ ์ค์ํฉ๋๋ค.
ํนํ ํ
์คํธ ์คํ์ผ ๋ณํ์ด๋ ์ด๋ฏธ์ง ๋ฒํผ ์ฒ๋ฆฌ์ฒ๋ผ,
์ด์ํ ์ผ์ด์ค๊ฐ ์์ฃผ ๋์ค๋ ๋ถ๋ถ์ ์ง์ ๊ฒช์ด๋ด์ผ ๊ฐ์ด ์กํ๋ ๊ฒ ๊ฐ์์.
ํ์ํ์ ๋ถ๊ป ๋์ ๋์ผ๋ฉด ์ข๊ฒ ์ต๋๋ค ๐
ํน์ ๊ถ๊ธํ ์ ์์ผ๋ฉด ๋๊ธ์ด๋ DM ์ฃผ์ธ์!