mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-15 04:25:27 +07:00
Fix convertSelectionToBitmap for big item (over 4000px)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
* Fix locked elements problem
|
* Fix locked elements problem
|
||||||
* Fix optimizator bitmap trim problems
|
* Fix optimizator bitmap trim problems
|
||||||
* Fix Unity 5.6 submesh sorting bug
|
* Fix Unity 5.6 submesh sorting bug
|
||||||
|
* Fix convertSelectionToBitmap for big item (over 4000px)
|
||||||
* Add shape tween warning
|
* Add shape tween warning
|
||||||
* Add SwfClip bounds functions (currentLocalBounds, currentWorldBounds)
|
* Add SwfClip bounds functions (currentLocalBounds, currentWorldBounds)
|
||||||
* Remove excess "if" instruction from shaders
|
* Remove excess "if" instruction from shaders
|
||||||
|
|||||||
@@ -15,18 +15,20 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
var ft = {
|
var ft = {
|
||||||
profile_mode : false,
|
profile_mode : false,
|
||||||
verbose_mode : false,
|
verbose_mode : false,
|
||||||
|
|
||||||
graphics_scale : 1.0,
|
graphics_scale : 1.0,
|
||||||
scale_precision : 0.01,
|
scale_precision : 0.01,
|
||||||
|
|
||||||
optimize_big_items : true,
|
optimize_big_items : true,
|
||||||
optimize_small_items : true,
|
optimize_small_items : true,
|
||||||
optimize_static_items : true,
|
optimize_static_items : true,
|
||||||
optimize_single_graphics : true,
|
optimize_single_graphics : true,
|
||||||
|
|
||||||
export_path_postfix : "_export"
|
export_path_postfix : "_export",
|
||||||
|
revert_after_conversion : true,
|
||||||
|
max_convertible_selection : 3900
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -264,7 +266,7 @@
|
|||||||
return ftdoc["temp"];
|
return ftdoc["temp"];
|
||||||
};
|
};
|
||||||
|
|
||||||
ftdoc.calculate_item_final_scale = function (doc, optional_item) {
|
ftdoc.calculate_item_prefer_scale = function (doc, optional_item) {
|
||||||
ft.type_assert(doc, Document);
|
ft.type_assert(doc, Document);
|
||||||
ft.type_assert_if_defined(optional_item, LibraryItem);
|
ft.type_assert_if_defined(optional_item, LibraryItem);
|
||||||
var final_scale = ft.graphics_scale;
|
var final_scale = ft.graphics_scale;
|
||||||
@@ -283,10 +285,27 @@
|
|||||||
return final_scale;
|
return final_scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
ftdoc.convert_selection_to_bitmap = function (doc, optional_item) {
|
ftdoc.convert_selection_to_bitmap = function (doc, location_name, optional_item) {
|
||||||
ft.type_assert(doc, Document);
|
ft.type_assert(doc, Document);
|
||||||
|
ft.type_assert(location_name, 'string');
|
||||||
ft.type_assert_if_defined(optional_item, LibraryItem);
|
ft.type_assert_if_defined(optional_item, LibraryItem);
|
||||||
var final_scale = ftdoc.calculate_item_final_scale(doc, optional_item);
|
|
||||||
|
var selection_r = doc.getSelectionRect();
|
||||||
|
var selection_w = selection_r.right - selection_r.left;
|
||||||
|
var selection_h = selection_r.bottom - selection_r.top;
|
||||||
|
|
||||||
|
var max_scale = ft.max_convertible_selection / Math.max(selection_w, selection_h);
|
||||||
|
var prefer_scale = ftdoc.calculate_item_prefer_scale(doc, optional_item);
|
||||||
|
var final_scale = Math.min(prefer_scale, max_scale);
|
||||||
|
|
||||||
|
if (final_scale < prefer_scale) {
|
||||||
|
var down_scale = Math.floor(final_scale / prefer_scale * 1000) * 0.001;
|
||||||
|
ft.trace_fmt(
|
||||||
|
"[Warning] {0}\n" +
|
||||||
|
"- Converted element was downscaled ({1}x) to maximum allowed size ({2}px)",
|
||||||
|
location_name, down_scale, ft.max_convertible_selection);
|
||||||
|
}
|
||||||
|
|
||||||
if (ft.approximately(final_scale, 1.0, ft.scale_precision)) {
|
if (ft.approximately(final_scale, 1.0, ft.scale_precision)) {
|
||||||
var elem_r = doc.getSelectionRect();
|
var elem_r = doc.getSelectionRect();
|
||||||
|
|
||||||
@@ -634,7 +653,8 @@
|
|||||||
new_item_elem.setTransformationPoint({x: 0, y: 0});
|
new_item_elem.setTransformationPoint({x: 0, y: 0});
|
||||||
new_item_elem.transformX = 0;
|
new_item_elem.transformX = 0;
|
||||||
new_item_elem.transformY = 0;
|
new_item_elem.transformY = 0;
|
||||||
ftdoc.convert_selection_to_bitmap(doc, item);
|
var location_name = "Symbol: {0}".format(item_name);
|
||||||
|
ftdoc.convert_selection_to_bitmap(doc, location_name, item);
|
||||||
doc.exitEditMode();
|
doc.exitEditMode();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -940,7 +960,8 @@
|
|||||||
doc.selectNone();
|
doc.selectNone();
|
||||||
doc.selection = ft.array_filter(frame.elements, fttim.is_shape_instance);
|
doc.selection = ft.array_filter(frame.elements, fttim.is_shape_instance);
|
||||||
if (doc.selection.length > 0) {
|
if (doc.selection.length > 0) {
|
||||||
ftdoc.convert_selection_to_bitmap(doc, timeline.libraryItem);
|
var location_name = "Timeline: {0}".format(timeline.name);
|
||||||
|
ftdoc.convert_selection_to_bitmap(doc, location_name, timeline.libraryItem);
|
||||||
doc.arrange("back");
|
doc.arrange("back");
|
||||||
++rasterize_count;
|
++rasterize_count;
|
||||||
}
|
}
|
||||||
@@ -967,13 +988,15 @@
|
|||||||
ft.trace_fmt("[Document] '{0}' conversion error: '{1}'", doc.name, e);
|
ft.trace_fmt("[Document] '{0}' conversion error: '{1}'", doc.name, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ft.profile_function(function () {
|
if (ft.revert_after_conversion) {
|
||||||
ft.array_foreach(fl.documents, function (doc) {
|
ft.profile_function(function () {
|
||||||
if (doc.canRevert()) {
|
ft.array_foreach(fl.documents, function (doc) {
|
||||||
fl.revertDocument(doc);
|
if (doc.canRevert()) {
|
||||||
}
|
fl.revertDocument(doc);
|
||||||
});
|
}
|
||||||
}, "Revert documents");
|
});
|
||||||
|
}, "Revert documents");
|
||||||
|
}
|
||||||
ft.trace("[Finish]");
|
ft.trace("[Finish]");
|
||||||
})();
|
})();
|
||||||
})();
|
})();
|
||||||
@@ -64,7 +64,7 @@ dipyalov: фишка в том, что swf обновился, но и собр
|
|||||||
**** DONE В ошибках конвертации писать, что нужно прогнать через скрипт экспорта
|
**** DONE В ошибках конвертации писать, что нужно прогнать через скрипт экспорта
|
||||||
А еще лучше как-то метить прогнанную анимацию и нет
|
А еще лучше как-то метить прогнанную анимацию и нет
|
||||||
*** Баги
|
*** Баги
|
||||||
**** TODO При больших (>= 4000 пикселей) выделениях не работает convertSelectionToBitmap
|
**** DONE При больших (>= 4000 пикселей) выделениях не работает convertSelectionToBitmap
|
||||||
**** TODO Не работает конвертация в batchmod'е
|
**** TODO Не работает конвертация в batchmod'е
|
||||||
**** DONE В ошибках конвертации не пишется путь до swf
|
**** DONE В ошибках конвертации не пишется путь до swf
|
||||||
**** DONE Не растеризуются группы в твинах
|
**** DONE Не растеризуются группы в твинах
|
||||||
|
|||||||
Reference in New Issue
Block a user