Skip to content

Commit

Permalink
add two more ratios by request
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fletcher committed Oct 20, 2021
1 parent c93b64c commit dcefd24
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ An Aseprite extension to create a new file that has ratio presets to make file c
Currently, the ratios supported are:

* 1:1
* 4:3
* 4:7
* 7:8
* 16:9
* Custom (no ratio enforced)

I'm open to adding more ratios to the script, so please let me know if you'd like to see another ratio in this dialog as well! It's minimal effort to add new ones, so don't be shy!

Expand Down
127 changes: 127 additions & 0 deletions extension/new-with-ratios.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ local function mainWindow()
id="fourtoseven",
enabled=true
}

dialog:modify {
id="fourtothree",
enabled=true
}

dialog:modify {
id="seventoeight",
Expand All @@ -82,6 +87,11 @@ local function mainWindow()
id="sixteentonine",
enabled=true
}

dialog:modify {
id="noratio",
enabled=true
}
end
}

Expand All @@ -107,6 +117,11 @@ local function mainWindow()
enabled=false
}

dialog:modify {
id="fourtothree",
enabled=true
}

dialog:modify {
id="seventoeight",
enabled=true
Expand All @@ -116,11 +131,60 @@ local function mainWindow()
id="sixteentonine",
enabled=true
}

dialog:modify {
id="noratio",
enabled=true
}
end
}

dialog:newrow()

dialog:button {
id="fourtothree",
text="4 : 3",
onclick=function()
ratio_width = 4
ratio_height = 3
local new_height = adjust_for_ratio(dialog.data.width, ratio_width, ratio_height)
dialog:modify {
id="height",
text=new_height
}

dialog:modify {
id="onetoone",
enabled=true
}

dialog:modify {
id="fourtoseven",
enabled=true
}

dialog:modify {
id="fourtothree",
enabled=false
}

dialog:modify {
id="seventoeight",
enabled=true
}

dialog:modify {
id="sixteentonine",
enabled=true
}

dialog:modify {
id="noratio",
enabled=true
}
end
}

dialog:button {
id="seventoeight",
text="7 : 8",
Expand All @@ -143,6 +207,11 @@ local function mainWindow()
enabled=true
}

dialog:modify {
id="fourtothree",
enabled=true
}

dialog:modify {
id="seventoeight",
enabled=false
Expand All @@ -152,9 +221,16 @@ local function mainWindow()
id="sixteentonine",
enabled=true
}

dialog:modify {
id="noratio",
enabled=true
}
end
}

dialog:newrow()

dialog:button {
id="sixteentonine",
text="16 : 9",
Expand All @@ -177,13 +253,62 @@ local function mainWindow()
enabled=true
}

dialog:modify {
id="fourtothree",
enabled=true
}

dialog:modify {
id="seventoeight",
enabled=true
}

dialog:modify {
id="sixteentonine",
enabled=false
}

dialog:modify {
id="noratio",
enabled=true
}
end
}

dialog:button {
id="noratio",
text="Custom",
onclick=function()
ratio_width = -1
ratio_height = -1

dialog:modify {
id="onetoone",
enabled=true
}

dialog:modify {
id="fourtoseven",
enabled=true
}

dialog:modify {
id="fourtothree",
enabled=true
}

dialog:modify {
id="seventoeight",
enabled=true
}

dialog:modify {
id="sixteentonine",
enabled=true
}

dialog:modify {
id="noratio",
enabled=false
}
end
Expand All @@ -202,6 +327,7 @@ local function mainWindow()
label="Width:",
decimals=0,
onchange=function()
if (ratio_width == -1) then return end
local new_height = adjust_for_ratio(dialog.data.width, ratio_width, ratio_height)
dialog:modify {
id="height",
Expand All @@ -215,6 +341,7 @@ local function mainWindow()
label="Height:",
decimals=0,
onchange=function()
if (ratio_height == -1) then return end
local new_width = adjust_for_ratio(dialog.data.height, ratio_height, ratio_width)
dialog:modify {
id="width",
Expand Down
2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "new-with-ratios",
"displayName": "New With Ratios",
"description": "Create new sprites with pre-defined ratios",
"version": "1.0",
"version": "1.1",
"author": { "name": "David Fletcher",
"email": "david.login@aol.com",
"url": "https://github.com/david-fletcher" },
Expand Down
Binary file modified new-with-ratios.aseprite-extension
Binary file not shown.

0 comments on commit dcefd24

Please sign in to comment.