processing.js

Using processing libraries in processing.js

孤街醉人 提交于 2019-12-05 00:08:13
问题 For those that don't know, Processing is a great Java library =for rendering nice visualizations of data and serves as a wrapper for JOGL. Processing.js is the Javascript port of this library. In order to create a processing applet inside HTML, you need 3 things. processing.js anything.html anything.pde // Processing program I'm basically trying out the js version and the problem is that if any libraries are included in the pde, it won't load inside the canvas. Here are 2 examples: This is an

save image to a png file using processing.js

孤人 提交于 2019-12-04 15:57:53
问题 I have an small drawing application made in processing.js. I would like to save the image made using the application to a server using a php file (no problem on this). I know the canvas element has a method to get that content, canvas.toDataURL() but I dont know how to do the same with processing.js Any hint? Cheers! 回答1: perhaps var image = document.getElementsByTagName("canvas")[0].toDataURL(); 回答2: So when you use saveFrame() in processing.js. The image opens in a new window and i found it

how can processing.js detect browser's size?

雨燕双飞 提交于 2019-12-04 11:00:18
问题 As mentioned, how can processing.js respond to a browser's size? (responsive design) i've tried screen.width and screen.height but it didn't work well. It seems only detect the size of the computer's screen size. What's more, i want to keep pace with the window's size when dragged and changed the size of the browser 回答1: size(window.innerWidth, window.innerHeight); according to https://groups.google.com/forum/?fromgroups=#!topic/processingjs/2-U_P7_BHlY or void setup() { size( $(window).width

load processing.js sketch with ajax on user click

本小妞迷上赌 提交于 2019-12-03 21:15:59
I'm trying to load a processing.js sketch with ajax on click and it's not working. It works if I load the sketch instantly, but not on a user interaction. Here's my code: $('#clicker').click(function(){ var canvasRef = $('<canvas/>'); canvasRef.attr('data-src','/uploads/processing_js/anything_1.pde'); $('#loader').append(canvasRef); }); I've also tried 'data-processing-sources' and 'datasrc' for the attribute. Anyone know why this doesn't work? We only check the data-processing-sources attribute on DOMContentLoaded. If you want to load a Processing sketch after that, you could use Processing

save image to a png file using processing.js

点点圈 提交于 2019-12-03 09:09:28
I have an small drawing application made in processing.js. I would like to save the image made using the application to a server using a php file (no problem on this). I know the canvas element has a method to get that content, canvas.toDataURL() but I dont know how to do the same with processing.js Any hint? Cheers! perhaps var image = document.getElementsByTagName("canvas")[0].toDataURL(); So when you use saveFrame() in processing.js. The image opens in a new window and i found it hard to intercept the data. The soultion is to get the image from the canvas in javascript. // this grabs the

Get Viewport Width With JQuery and Use In Processing JS

泄露秘密 提交于 2019-12-03 09:07:02
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/ humphd 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:/

How can Khan Academy computer programs be run offline or on my own website?

故事扮演 提交于 2019-12-03 05:11:33
问题 I have developed programs in Khan Academy's Computer Programming lessons that I would like to run outside of Khan Academy. How can that be done? 回答1: Khan Academy uses Processing.js, a JavaScript library for interacting with <canvas> elements. Although Processing is actually a language in its own right, Khan Academy uses JavaScript-only Processing.js code. So you need to set up a web page that imports Processing.js, sets up a <canvas> , and builds a Processing.js instance on the canvas.

How can Khan Academy computer programs be run offline or on my own website?

 ̄綄美尐妖づ 提交于 2019-12-02 19:35:36
I have developed programs in Khan Academy's Computer Programming lessons that I would like to run outside of Khan Academy. How can that be done? Khan Academy uses Processing.js , a JavaScript library for interacting with <canvas> elements. Although Processing is actually a language in its own right, Khan Academy uses JavaScript-only Processing.js code . So you need to set up a web page that imports Processing.js, sets up a <canvas> , and builds a Processing.js instance on the canvas. Finally you need to make sure your Khan Academy code has all the members of the Processing.js instance in scope

Processing.js array of pictures not showing properly

末鹿安然 提交于 2019-12-02 12:09:20
I am trying to take picture path data from my database and show it on the processing sketch like so this is Javascript file: <script type="text/javascript"> function send() { function setPath(d) { var s = d; var processingInstance; if (!processingInstance) { processingInstance = Processing.getInstanceById('canvas'); } processingInstance.change(s); } var variable = 2; $.ajax({ method: "POST", tupe: "POST", url: "take.php", data: ({val: variable}), success: function (data) { $('#msg').html(data); setPath(data); }, }); }</script> this is PHP file: <?php $con = mysqli_connect('localhost', 'Admin',

How to run Processing+Twitter4j sketch in broswer

泪湿孤枕 提交于 2019-12-02 06:46:57
I'm a newbie programmer practicing Processing and I recently developed a sketch that uses Twitter4j. When I run the sketch in Java mode from the Processing Development Environment it works perfectly. Also, when I export the sketch from Java mode the resulting application runs perfectly. However, when I switch to JavaScript mode and try to run the sketch the browser preview does not display anything. I believe the problem is related to Twitter4j because when I remove the Twitter4j-related code from the sketch and run it (in JavaScript mode) the browser preview then displays the Processing