简体   繁体   English

如何使用JavaScript更新HTML 5画布?

[英]How can I update an HTML 5 canvas with JavaScript?

I'm using HTML5's canvas and javascript to make an interactive pedigree tree. 我正在使用HTML5的canvas和javascript制作交互式谱系树。 I am using ( http://philogb.github.io/jit/static/v20/Jit/Examples/Spacetree/example1.html ) as base for this project. 我正在使用( http://philogb.github.io/jit/static/v20/Jit/Examples/Spacetree/example1.html )作为该项目的基础。

I'm trying to dynamically update some of the canvas elements. 我正在尝试动态更新某些canvas元素。

I have the following javascript 我有以下javascript

function init(){
   ........
Node: {
       height: 100,
        width: 240,
        type: 'rectangle',
        overridable: true,

    },
..........

This Node property, is there a way for me to call and modify this externally? 这个Node属性,有没有办法让我在外部调用和修改它?

Eg. 例如。 I want to be able to change the dimensions, I would like to be able to start running this script from the Node function and changing the node shape /size. 我希望能够更改尺寸,我希望能够从Node函数开始运行此脚本并更改节点形状/ size。

I'm trying to avoid calling the init() function because it will reload all of the data. 我试图避免调用init()函数,因为它将重新加载所有数据。

Is this possible? 这可能吗?

如果您创建了一个新的ST实例,则可以像下面这样访问Node:

st.Node.height = "what you want"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM