Testp5
Aus exmediawiki
Version vom 2. Februar 2021, 17:04 Uhr von Karin (Diskussion | Beiträge)
How to work locally with p5
If you want to work with p5.js on your computer, you need an editor.
The most simple one being text editor. There are also several code editors you can choose from, e.g. subethaedit, sublime text 2, brackets, https://atom.io/ atom], notepad++ just to name a few.
E.g. in subethaedit you can write, execute and manage different languages, for the purposes of p5.js it is javascript. It enables you to work with javascript locally on your computer. Furthermore you can use it to write your own html-code to execute your js-file and test it directly in your browser. Later on you can embed the html-page on a website.
the html-page can look like this:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" Content-Type: text/javascript;charset=utf-8">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<TITLE>for_example</TITLE>
<script src="https://cdn.jsdelivr.net/npm/p5@1.0.0/lib/p5.min.js"></script>
</HEAD>
<BODY BGCOLOR="#cdcdcd">
<script src="forexample.js"></script>
</BODY>
</HTML>
The line <script src="forexample.js"></script> refers to the file forexample.js, which you work on in the editor. The necessary libraries can accessed directly by referencing to the online repositories. This also ensures that you always work with the most recent update. If you prefer to work with libraries downloaded directled from p5, you'll need to include these in the folder you are also storing your .js-file.
For more information: setup of p5 on your computer, get started.