Skip to content

Commit

Permalink
Added selectMissingLink.js
Browse files Browse the repository at this point in the history
Updated
libs/UI_Image_Encoder.js
libs/XMP.js
  • Loading branch information
sky-chaser-high committed Dec 7, 2024
1 parent 4a26383 commit bf84765
Show file tree
Hide file tree
Showing 8 changed files with 934 additions and 403 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,20 +774,28 @@
### 1.0.1 (2024-10-19)
### Bug Fixes
- Fixed a bug in which the point text did not toggle in version 2023 or later.
- Fixed a bug in settings that could not toggle when no document was open.
<br><br>


## togglePasteRemembersLayers.js
### 1.0.1 (2024-10-19)
### Bug Fixes
- Fixed a bug in which settings could not toggle when no document is open.
- Fixed a bug in settings that could not toggle when no document was open.
<br><br>


## toggleShowHandles.js
### 1.0.1 (2024-10-19)
### Bug Fixes
- Fixed a bug in which settings could not be changed when no document was open.
- Fixed a bug in settings that could not toggle when no document was open.
<br><br>


## UI_Image_Encoder.js
### 1.1.0 (2024-12-07)
### Added
- Added the function to escape quotation marks.
<br><br>


Expand Down
375 changes: 250 additions & 125 deletions README.md

Large diffs are not rendered by default.

693 changes: 453 additions & 240 deletions README_ja.md

Large diffs are not rendered by default.

Binary file modified images/UI_Image_Encoder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 38 additions & 6 deletions libs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Libs | Adobe Illustrator Scripts
Frequently used features were grouped into functions.

[![Download Libs.zip](https://img.shields.io/badge/Download-Libs.zip-e60012)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Libs.zip)
[![Download Libs.zip](https://img.shields.io/badge/Download-Libs.zip-e60012?style=flat-square)](https://github.com/sky-chaser-high/adobe-illustrator-scripts/releases/latest/download/Libs.zip)
- [Map.js](#Mapjs)
- [Matrix.js](#Matrixjs)
- [UI_Image_Encoder.js](#UI_Image_Encoderjs)
- [UI_Image_Encoder.js](#UI_Image_Encoderjs) `Update`
- [Vector.js](#Vectorjs)
- [XMP.js](#XMPjs)
- [XMP.js](#XMPjs) `Update`

## Usage
You can include this script or copy the function to use it.
Expand All @@ -20,9 +20,15 @@ var value = map(num, 0, 100, 0, 255);
## Requirements
Illustrator CS or higher

## License
All scripts are licensed under the MIT license.
See the included LICENSE file for more details.



# <a name="Mapjs">Map.js</a>
<img src="https://img.shields.io/badge/version-1.1.0-e8e8e8?style=flat-square">

This script summarizes functions related to maps.

## Functions
Expand Down Expand Up @@ -115,6 +121,8 @@ var value = norm(num, 0, 100);


# <a name="Matrixjs">Matrix.js</a>
<img src="https://img.shields.io/badge/version-1.0.0-e8e8e8?style=flat-square">

These functions get the object's scale, rotation, or shear value from the matrix.

## Functions
Expand Down Expand Up @@ -266,6 +274,8 @@ var isReflected = isReflectedY(matrix);


# <a name="UI_Image_Encoderjs">UI_Image_Encoder.js</a>
<img src="https://img.shields.io/badge/version-1.1.0-e8e8e8?style=flat-square">

This script converts a image file to binary for use within the ScriptUI.

<img src="../images/UI_Image_Encoder.png" alt="UI Image Encoder" width="50%">
Expand All @@ -274,8 +284,9 @@ This script converts a image file to binary for use within the ScriptUI.
1. Run this script.
2. Select an image file. Only JPEG and PNG format image files are supported.
3. Select the encoding method, either the Unicode or the Percent-encoding.
4. Click the Convert button.
5. Copy the string converted to binary and paste it into the code you are creating.
4. Select whether to escape quotation marks.
5. Click the Convert button.
6. Copy the string converted to binary and paste it into the code you are creating.
Escape quotation marks if necessary.

```javascript
Expand All @@ -294,6 +305,8 @@ Illustrator CS4 or higher


# <a name="Vectorjs">Vector.js</a>
<img src="https://img.shields.io/badge/version-1.0.0-e8e8e8?style=flat-square">

This script summarizes functions related to vectors.

## Functions
Expand All @@ -314,8 +327,10 @@ This script summarizes functions related to vectors.


# <a name="XMPjs">XMP.js</a>
<img src="https://img.shields.io/badge/version-2.1.0-e8e8e8?style=flat-square">

These functions get the font, color, or history properties used in the document from XMP.
**See also:** [Adobe XMP Document](https://www.adobe.io/xmp/docs/)
**See also:** [Adobe XMP Document](https://developer.adobe.com/xmp/docs/)

> **Note** XMP can also be used for linked files.
> ```javascript
Expand All @@ -329,6 +344,7 @@ These functions get the font, color, or history properties used in the document
- [getHistory(src)](#getHistorysrc)
- [getLinkedFiles(src)](#getLinkedFilessrc)
- [getPlateNames(src)](#getPlateNamessrc)
- [getRulerUnits(src)](#getRulerUnitssrc) `New`
- [getSwatches(src)](#getSwatchessrc)
## <a name="getFontssrc">getFonts(src)</a>
Expand Down Expand Up @@ -409,6 +425,22 @@ alert(platenames[0]);
<div align="right">[ <a href="#XMPjs">↑ Back to Top ↑</a> ]</div>


## <a name="getRulerUnitssrc">getRulerUnits(src)</a>
Get ruler units that are used in the document from XMP.

**Param**: `src` `<File>`
**Returns**: `<string>` Ruler units.

```javascript
// @include '/foo/bar/XMP.js'
var src = app.activeDocument.fullName;
var units = getRulerUnits(src);
alert(units);
```

<div align="right">[ <a href="#XMPjs">↑ Back to Top ↑</a> ]</div>


## <a name="getSwatchessrc">getSwatches(src)</a>
Get swatch properties that are used in the document from XMP.

Expand Down
116 changes: 95 additions & 21 deletions libs/UI_Image_Encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
1. Run this script from File > Scripts > Other Script...
2. Select an image file. Only JPEG and PNG format image files are supported.
3. Select the encoding method, either the Unicode or the Percent-encoding.
4. Click the Convert button.
5. Copy the string converted to binary and paste it into the code you are creating.
4. Select whether to escape quotation marks.
5. Click the Convert button.
6. Copy the string converted to binary and paste it into the code you are creating.
Escape quotation marks if necessary.
Example
Expand All @@ -26,7 +27,7 @@
Illustrator CS4 or higher
Version
1.0.0
1.1.0
Homepage
github.com/sky-chaser-high/adobe-illustrator-scripts
Expand All @@ -46,7 +47,8 @@ function main() {

dialog.convert.onClick = function() {
var src = dialog.file.text;
var data = encodeFile(src);
var quote = getQuotationMark(dialog);
var data = encodeFile(src, quote);
if (dialog.unicode.value) dialog.binary.text = (data) ? data.unicode : '';
if (dialog.percent.value) dialog.binary.text = (data) ? data.percent : '';

Expand All @@ -58,7 +60,7 @@ function main() {
}


function encodeFile(src) {
function encodeFile(src, quote) {
var file = File(src);
if (!file.exists) return;

Expand All @@ -73,17 +75,31 @@ function encodeFile(src) {
unicode = unicode.replace(/^\(new\sString\("/i, '');
unicode = unicode.replace(/"\)\)/i, '');

if (quote) {
var regex = new RegExp(quote, 'g');
percent = percent.replace(regex, '\\' + quote);
unicode = unicode.replace(regex, '\\' + quote);
}

return {
unicode: unicode,
percent: percent
};
}


function getQuotationMark(dialog) {
var escape = dialog.escape.value;
if (!escape) return '';
var quote = dialog.singleQuote.value;
return (quote) ? '\'' : '"';
}


function isValidVersion() {
var cs4 = 14;
var aiVersion = parseInt(app.version);
if (aiVersion < cs4) return false;
var current = parseInt(app.version);
if (current < cs4) return false;
return true;
}

Expand Down Expand Up @@ -114,7 +130,7 @@ function showDialog() {

var button1 = group1.add('button', undefined, undefined, { name: 'button1' });
button1.text = ui.select;
button1.preferredSize.width = 65;
button1.preferredSize.width = 60;

var statictext1 = group1.add('statictext', undefined, undefined, { name: 'statictext1' });
statictext1.text = '';
Expand All @@ -140,30 +156,60 @@ function showDialog() {
var radiobutton2 = group2.add('radiobutton', undefined, undefined, { name: 'radiobutton2' });
radiobutton2.text = ui.percent;

var group3 = dialog.add('group', undefined, { name: 'group3' });
group3.orientation = 'column';
group3.alignChildren = ['fill', 'center'];
var panel3 = dialog.add('panel', undefined, undefined, { name: 'panel3' });
panel3.text = ui.quotationMark;
panel3.orientation = 'column';
panel3.alignChildren = ['left', 'top'];
panel3.spacing = 10;
panel3.margins = 10;

var group3 = panel3.add('group', undefined, { name: 'group3' });
group3.orientation = 'row';
group3.alignChildren = ['left', 'center'];
group3.spacing = 10;
group3.margins = [0, 10, 0, 4];
group3.margins = [0, 8, 0, 0];

var checkbox1 = group3.add('checkbox', undefined, undefined, { name: 'checkbox1' });
checkbox1.text = ui.escape;

var group4 = group3.add('group', undefined, { name: 'group4' });
group4.orientation = 'row';
group4.alignChildren = ['left', 'center'];
group4.spacing = 10;
group4.margins = 0;
group4.enabled = false;

var radiobutton3 = group4.add('radiobutton', undefined, undefined, { name: 'radiobutton3' });
radiobutton3.text = ui.singleQuote;
radiobutton3.value = true;

var radiobutton4 = group4.add('radiobutton', undefined, undefined, { name: 'radiobutton4' });
radiobutton4.text = ui.doubleQuote;

var statictext2 = group3.add('statictext', undefined, undefined, { name: 'statictext2' });
var group5 = dialog.add('group', undefined, { name: 'group5' });
group5.orientation = 'column';
group5.alignChildren = ['fill', 'center'];
group5.spacing = 10;
group5.margins = [0, 6, 0, 0];

var statictext2 = group5.add('statictext', undefined, undefined, { name: 'statictext2' });
statictext2.text = ui.binary;

var edittext1 = group3.add('edittext', undefined, undefined, { name: 'edittext1', multiline: true });
var edittext1 = group5.add('edittext', undefined, undefined, { name: 'edittext1', multiline: true });
edittext1.text = '';
edittext1.preferredSize.height = 300;

var group4 = dialog.add('group', undefined, { name: 'group4' });
group4.orientation = 'row';
group4.alignChildren = ['right', 'center'];
group4.spacing = 10;
group4.margins = 0;
var group6 = dialog.add('group', undefined, { name: 'group6' });
group6.orientation = 'row';
group6.alignChildren = ['right', 'center'];
group6.spacing = 10;
group6.margins = 0;

var button2 = group4.add('button', undefined, undefined, { name: 'button2' });
var button2 = group6.add('button', undefined, undefined, { name: 'button2' });
button2.text = ui.close;
button2.preferredSize.width = 90;

var button3 = group4.add('button', undefined, undefined, { name: 'button3' });
var button3 = group6.add('button', undefined, undefined, { name: 'button3' });
button3.text = ui.convert;
button3.preferredSize.width = 90;
button3.enabled = false;
Expand All @@ -177,6 +223,15 @@ function showDialog() {
edittext1.active = true;
});

checkbox1.onClick = function() {
if (checkbox1.value) {
group4.enabled = true;
}
else {
group4.enabled = false;
}
}

button1.onClick = function() {
var src = File.openDialog('', filterExtension(), false);
var file = (src) ? src.fsName : ''
Expand All @@ -193,6 +248,9 @@ function showDialog() {
dialog.file = statictext1;
dialog.unicode = radiobutton1;
dialog.percent = radiobutton2;
dialog.escape = checkbox1;
dialog.singleQuote = radiobutton3;
dialog.doubleQuote = radiobutton4;
dialog.binary = edittext1;
dialog.convert = button3;
return dialog;
Expand Down Expand Up @@ -244,6 +302,22 @@ function localizeUI() {
en: 'Percent-encoding',
ja: 'パーセントエンコーディング'
},
quotationMark: {
en: 'Quotation Marks',
ja: 'クォーテーションマーク'
},
escape: {
en: 'Escape:',
ja: 'エスケープ:'
},
singleQuote: {
en: '\\\'',
ja: '\\\''
},
doubleQuote: {
en: '\\\"',
ja: '\\\"'
},
binary: {
en: 'Binary:',
ja: 'バイナリー:'
Expand Down
Loading

0 comments on commit bf84765

Please sign in to comment.