Skip to content

Instantly share code, notes, and snippets.

View anton-liubushkin's full-sized avatar

Anton Liubushkin anton-liubushkin

View GitHub Profile
@anton-liubushkin
anton-liubushkin / font-fallback.css
Created November 13, 2023 09:31
Default font-family: system font fallback
font-family: {{ custom_sans_font }}, ui-sans-serif, system-ui, -system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-family: {{ custom_serif_font }}, Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-family: {{ custom_mono_font }}, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
@anton-liubushkin
anton-liubushkin / psLayersToBase64.js
Last active December 17, 2020 02:02
Copy base64 data of all selected Photoshop layers into clipboard
init();
funtion init() {
var layerID, pngPath, pngFile, pngData64, pngBase64Image;
layerID = app.activeDocument.activeLayer.id;
pngPath = new File(Folder.temp + "/" + layerID).fsName;
writeLayerPNGfile(pngPath);
// JSON
var result = [...document.querySelectorAll('.n-snippet-cell2')].map(el => {
let item = {}
item.title = el.querySelector('.n-snippet-cell2__title').innerText; // Получить текст элемента
item.img = el.querySelector('img.image').src; // Получить адрес у картинки
// item.bg = el.querySelector('...').style.backgroundImage.replace(/url\(['"]?(.+?)['"]?\)/, '$1'); // Получить адрес фонового изображения
return item;
})
console.log(
@anton-liubushkin
anton-liubushkin / getShapeFillColor.jsx
Created February 11, 2016 13:42
Get fill color of shape
function getFillColor() {
var ref = new ActionReference();
ref.putEnumerated(stringIDToTypeID("contentLayer"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var color = executeActionGet(ref).getList(charIDToTypeID("Adjs")).getObjectValue(0).getObjectValue(charIDToTypeID('Clr '));
return [color.getDouble(charIDToTypeID('Rd ')), color.getDouble(charIDToTypeID('Grn ')), color.getDouble(charIDToTypeID('Bl '))];
}
@anton-liubushkin
anton-liubushkin / getLayersCount.jsx
Last active August 29, 2015 14:23
Return how many layers are there in document — Photoshop script
function getLayersCount() {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID ("property"), charIDToTypeID('NmbL'))
ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL'));
return count
}
@anton-liubushkin
anton-liubushkin / makeSelection.jsx
Created June 29, 2015 15:05
Makes a rectangular selection — Photoshop script
// x, y, width, height
// x & y position from top left corner of document
// width & height of selection
//
// makeSelection(10,50,200,100);
function makeSelection(x,y,sw,sh){
app.activeDocument.selection.select([ [x,y], [x,y+sh], [x+sw,y+sh], [x+sw,y] ]);
}