change width stage from input

可紊 提交于 2019-12-13 03:58:39

问题


Could someone help me?

I have a stage and image and i want to change width and height from input. this is code and it does no work :/ help me.)

var stage = new Kinetic.Stage({ container: 'containerCreator', width: imageWidth, height: imageHeight });

var layer = new Kinetic.Layer();

var imageObj = new Image();
imageObj.onload = function(){
  var yoda = new Kinetic.Image({
    x: 0,
    y: 0,
    image: imageObj,
    width: imageWidth,
    height: imageHeight
  });



  layer.add(yoda);
  layer.add(vrchnyText);
  stage.add(layer);  

  };
  imageObj.src = imageSource;

  $('#vrchCreator').keyup(function(){

    stage.width = $(this).val();        
    stage.height= $(this).val();    
    layer.add(yoda);
    stage.add(layer);  

});


回答1:


You want to change this to:

$('#vrchCreator').keyup(function()
{ 
   stage.setWidth(parseInt($(this).val()));
   stage.setHeight(parseInt($(this).val()));
   layer.add(yoda);
   stage.add(layer);  

});


来源:https://stackoverflow.com/questions/14696875/change-width-stage-from-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!