Skip to content

Commit

Permalink
ランダムカットを微調整、無いFanctionを触っていたので削除、実装しなかったサンプルは削除
Browse files Browse the repository at this point in the history
  • Loading branch information
new-sankaku committed Nov 12, 2024
1 parent fc373ca commit 5492c42
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 45 deletions.
2 changes: 1 addition & 1 deletion js/ai/ui/AiUIUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function changeExternalAPI(button) {
} else if ( selectedValue === "comfyUIButton" ) {
API_mode = apis.COMFYUI;
createToast("API CHANGE!", "COMFYUI", 2000);
updateAiModelType();
// updateAiModelType();
$('apiSettingsUrlHelpe').innerHTML = `<a href="html/API_Help/comfyui_settings.html" target="_blank">${help}</a>`;
}

Expand Down
82 changes: 38 additions & 44 deletions js/panel/RandamCut.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
function rundomPanelCut() {
var panel = getRandomPanel();
var maxRetryCount = 1;
if (panel !== null) {
var vRandomCount = $("verticalRandomPanelCount").value;
var hRandomCount = $("horizontalRandamPanelCount").value;
vRandomCount = generateRandomInt(vRandomCount);
hRandomCount = generateRandomInt(hRandomCount);

console.log("vRandomCount", vRandomCount);
console.log("hRandomCount", hRandomCount);

try {
changeDoNotSaveHistory();

var maxRetryCountSum = maxRetryCount * (vRandomCount + hRandomCount);
var retry = 0;
while (vRandomCount > 0 || hRandomCount > 0) {
if (retry > maxRetryCountSum) {
console.log("split retryCount over.");
return;
}

if (vRandomCount > 0) {
var isSplit = blindSplitPanel(panel, true);
if (isSplit) {
vRandomCount--;
panel = getRandomPanel();
} else {
retry++;
}
}
if (hRandomCount > 0) {
var isSplit = blindSplitPanel(panel, false);
if (isSplit) {
panel = getRandomPanel();
hRandomCount--;
} else {
retry++;
}
}
}
} finally {
changeDoSaveHistory();
}
} else {

if (panel === null) {
createToastError("Panel is ZERO.");
console.log("panel is nothing.");
return;
}
}

var vRandomCount = generateRandomInt($("verticalRandomPanelCount").value);
var hRandomCount = generateRandomInt($("horizontalRandamPanelCount").value);

console.log("vRandomCount", vRandomCount);
console.log("hRandomCount", hRandomCount);

try {
changeDoNotSaveHistory();

var cuts = [];
for (var i = 0; i < vRandomCount; i++) cuts.push('vertical');
for (var i = 0; i < hRandomCount; i++) cuts.push('horizontal');

cuts.sort(() => Math.random() - 0.5);

var maxRetryCountSum = maxRetryCount * cuts.length;
var retry = 0;

while (cuts.length > 0) {
if (retry > maxRetryCountSum) {
console.log("split retryCount over.");
return;
}

var currentCut = cuts[0];
var isSplit = blindSplitPanel(panel, currentCut === 'vertical');

if (isSplit) {
cuts.shift();
panel = getRandomPanel();
} else {
retry++;
}
}
} finally {
changeDoSaveHistory();
}
}


async function generateMultipage(){
Expand Down

0 comments on commit 5492c42

Please sign in to comment.