I write a processing(2.1.1) project in java and now I want to export it as javascript.but there is a problem,I use the peasycam library,it is a third-party library and offer only jar file(peasycam.jar) and no js file(no peasycam.js).I read something about this in the official website of Processing,it seems to have no solution unless peasycam offer a peasycam.js.
Peasycam does not have a library for Processing.js. There's not much that can be done about that unless the original author or someone else (hint: you) wants to write one.
You have the option of using ArcBall which has a JS version that you can include with your projects.
You can see an example of how it works here: http://www.math.tamu.edu/~romwell/arcball_js/index.html
And see the ArcBall.pde here: https://github.com/motionbank/deborah-hay-processing/blob/master/marker-analysis/scene-probability/backbone_01/arcball.pde
If you don't want to worry about ArcBall then I suggest you learn about Quaternions and write your own code to handle 3D scenes.
Related
I want to make image processing tool, and I have used cv2.pencilSketch() method in python. However, in JavaScript, it is not a function.
How do I do it in JavaScript? In my browser. (OpenCV js CDN)?
If it is not a function, I would like to make it a function with my own image processing, but I need help.
unfortunately, as of now, only a small subset of opencv is exposed to js.
you'll find the complete 'whitelist' here
(and no, pencilSketch() is not included, so you cannot use it)
IF you're able to build it locally, you could try to add the function to the photo section, and build your own.
and IF that works, please make a github PR with it, so others can profit from your effort !
I am working on a webapp(written with react-js) that generates a Latex code which contains information to give to the user. My goal is to let the user download the PDF file directly from my application.
I first tried using this library: texlive.js, that seemed to work but really it's impossible to recompile(their "Makefile" is not meant to handle new packages) if you try to add new packages(only some basic ones work).
So I thought about using the overleaf APIs but they don't let you obtain the pdf without sending the user to their website.
Any advice to make one of them work or any other way to achieve my goal?
You can install your package in texlive.js without using MakeFile
Sorry I am not expert in answering but here is how i made it work
I wanted to implement exam paper generation using javascript
Required Package/Class : exam
I created "\texlive.js\texlive\texmf-dist\tex\latex\exam\exam.cls"
Added this to
"\texlive.js\texlive\texmf-dist\ls-R"
./tex/latex/exam:
exam.cls
And Then \texlive.js\texlive.lst
/texmf-dist/tex/latex/exam/.
And
/texmf-dist/tex/latex/exam/exam.cls
I've recently found this project:
https://github.com/SwiftLaTeX/SwiftLaTeX
I've tested it with a few documents and it seems to work. It downloads the needed packages from the web, see available packages: https://www.ctan.org/. I haven't gone deeper into passing images to the engine but it should be possible. See the official demo: https://www.swiftlatex.com/#demo
Here is the official guide with the download link for the already compiled wasm files and with the js bindings: https://www.swiftlatex.com/#install
I've made a simple programming language and compiler using Flex and Yacc, and I want to be able to convert my code for use in the browser.
I've already taken a look at projects like Jison, but I don't think that would work for me as I'd then have to maintain two different codebases.
Looking around some more, I'm pretty sure compiling my compiler to WebAssembly and running that in the browser would be the solution. Only problem is that I'm not sure how to go about doing that. Can the Flex library that I pass when linking the lexer and the parser together (-lfl) also be compiled along with my compiler?
I really have no experience with WASM and I'm pretty new to Flex/Yacc too, so there may be some very obvious solution, but I can't seem to find anything.
If you want to take a look at my code: https://github.com/inobulles/aqua-compiler/tree/master/langs/amber
Thanks alot for your time!
There is nothing of much use in -lfl; you shouldn't need it in any real application.
If you don't define yywrap() in your flex file, then add
%option noyywrap
to your flex prologue, so that flex doesn't put a reference to yywrap into the generated code. If you do define yywrap then you already don't need -lfl, but you still might think about %option noyywrap so that you don't need the definition.
I don't know how WASM deals with stdio.h functions; presumably, your intent is to use some other mechanism to feed text into your lexer, but the generated code will still contain references to standard library I/O functions (as does the code generated by Bison).
I would like to use the Glimpse client viewer in a web application in order to render some JSON. I am unable to use the Glimpse server implementation on the site in question. However, I can implement my own IHttpHandler to render the information using the Glimpse JSON format.
Has anyone done this and posted details on how to do it? If not, can anyone tell me the steps required to get this up and running? Alternatively, are there any other similar viewer frameworks out there?
Note: I am poking around the source and have seen the client js etc. I will continue down the source hacking route, but was hoping someone may have some shortcuts for me!
As Nik said I would be interested in what you are trying to do. But in the mean time the best place to look is http://getglimpse.com/Protocol.
If you look on this page you will see that we have built a protocol tester. This allows you to put in any JSON and see the output.
If you want to do this yourself, have a look at http://getglimpse.com/Scripts/Protocol/LayoutExample.js and you will see how we do this without using the whole of Glimpse.
You will see that we are doing something like the following:
var data = { test : 'test', hello : 'hello' };
var html = $Glimpse.glimpseProcessor.build(data, 0, false)
$('.panel').html(html);
I know this isn't as nice as it could be but it wasn't designed with this in mind.
We are currently working on refactoring the client code to make this all better.
We haven't really documented all of this yet.
Your best bet is to look at first glimpse javascript file that gets rendered to a page - it is the data file. If you can output data in that format, which is basically just one object of key value pairs, then the client will pick up the data and render it.
You might also want to look at the Glimpse.PHP implementation, since they'vve had to do the same thing you are.
I've been playing with node.js for a while, and I've really come to appreciate how awesome it is. However, one thing I'm struggling to understand is how I should structure my code so that it is maintainable. Most tutorials I've seen on the internet have all the JS in one file, which is hardly a nice way to manage your code. I am aware there is no such thing in real-terms as a "class" in javascript, but is there a (standard) way for me to format my code for maintainability in the same way I'd structure a PHP project, for example?
I'd add that as far as maintainability goes, I believe the typical style of deeply-nesting callbacks using closures is the single greatest impediment to the understandability of Node programs, as well as being completely unnecessary.
For every:
a.doSomething(val, function(err,result){
b.doSomethingElse(result,function(err,res){
...
});
});
There is always a:
a.doSomething(val, onDoSomething);
function onDoSomething(err,res) {
...
}
My rule of thumb is: a new non-closure callback function is required for anything over three levels of nesting.
(Node.js really needs a style manual.)
Afaik you can use require to include your own js files (containing exported methods) using:
var req = require('./someJsFile');
Within someJsFile.js you can export methods like this:
exports.someMethod = function(){ /*...*/ };
And in your main file you can address such a method using req.someMethod()
So this way you can split up your code in different files, which you require from some central js file.
Here is an article explaining node.js require
After you learned how require works in node.js (pretty straightforward), as suggested by Kooilnc
You can take a look at the source code of the modules available for Node.js:
https://github.com/joyent/node/wiki/modules
If you're planning to use Express (one of the most robust node.js framework out there) to develop your first node applications, you can take a look at its specific samples here:
https://github.com/visionmedia/express/tree/master/examples
(there's also an mvc sample)