Get Viewport Width With JQuery and Use In Processing JS

亡梦爱人 提交于 2020-01-01 03:57:05

问题


I'm writing a processingjs script that I want to resize depending on the users viewport width. As far as I know there's no functionality for this in processing, so I've been looking at JQuery and using $(window).width();.

Only I don't know how to get that value into the size(width, height) function in processing.

Any ideas?

Thanks

Links if you need them: http://processingjs.org/ http://api.jquery.com/width/


回答1:


You can call $(window).width(); in the size function. Mixing js and p5 code is fine in processing.js.

void setup() {
    size( $(window).width(),
        $(window).height() );
    ...
}


来源:https://stackoverflow.com/questions/4631933/get-viewport-width-with-jquery-and-use-in-processing-js

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