最近发现了 KineticJS,因为我一直在尝试将我的 Flash 技能转换为 HTML Canvas。这是一个非常令人印象深刻的工具!问题:如果我正在使用像 Bootstrap 这样的前端,并且我有一个包含几个 div 的页面,其中包含 KineticJS 生成的画布,我可以让这些画布与页面上的其他所有内容一起缩放吗?非常感谢。
----- 由于评论字数限制,我在OP回复。---------
你会设置它,以便有一个最大尺寸,然后让它像浏览器缩放时一样缩放?例如,在 Actionscript 中,我这样做是为了跟踪浏览器的大小并缩放舞台:
stageListener.onResize = function():Void {
// Calculate % of total allowable change for each dimension
var percentWScale:Number = (Stage.width - minStageWSize)/stageWResizeRange;
var percentHScale:Number = (Stage.height - minStageHSize)/stageHResizeRange;
// Test to see if the stage size is in the rescale range
if ((Stage.width < maxStageWSize) || (Stage.height < maxStageHSize)) {
pfarm.stageChanged = true;
// Calculate the scale factor for each dimension, but don't go below the minimum
var percentHScale:Number = Math.max(minimumScale, Stage.width/1024);
var percentVScale:Number = Math.max(minimumScale, Stage.height/768);
//trace ("H Scale Factor: "+percentHScale+". V Scale factor: "+percentVScale);
// Determine which window dimension to use for scaling -
// Use the one which is the most scaled down from the maximum stage size.
var getScaleFrom:String = (percentHScale << percentVScale)? "hScale" : "vScale";
// Scale the object
if (getScaleFrom == "hScale") {
baseParent._width = projectContentXSize * percentHScale;
baseParent._height = projectContentYSize * percentHScale;
} else {
baseParent._width = projectContentXSize * percentVScale;
baseParent._height = projectContentYSize * percentVScale;
}
} // END RESIZE OF SCROLLPANE CONTENT
为了跨越复杂边界进入 HTML5 领域的 Flash 难民(如我)的利益,您能否提供一个示例或 2 个示例?