-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
135 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>pyp5js with Pyodide demo (py5mode)</title> | ||
<title>pyp5js with Pyodide Demo</title> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script> | ||
<script src="https://cdn.jsdelivr.net/pyodide/v0.18.1/full/pyodide.js"></script> | ||
|
@@ -22,7 +22,7 @@ | |
integrity="sha512-S4i/WUGRs22+8rjUVu4kBjfNuBNp8GVsgcK2lbaFdws4q6TF3Nd00LxqnHhuxS9iVDfNcUh0h6OxFUMP5DBD+g==" | ||
crossorigin="anonymous"></script> | ||
<script src="share.js"></script> | ||
|
||
<script src="startpanel.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/basscss.min.css"> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
|
@@ -62,8 +62,11 @@ | |
<!-- You sketch will go here! --> | ||
</div> | ||
</div> | ||
<div id="ScreenConsole"></div> | ||
<div> | ||
<p style="font-family: 'sans'; font-size:14px; margin-left: 20px;">If you execute the code but nothing is being rendered in the browser, please open your browser's console to read the error traceback (usually you can do this by pressing F12 and clicking in the Console tab).</p> | ||
<!-- p style="font-family: 'sans'; font-size:14px; margin-left: 20px;">If you execute the code but nothing is being rendered in the browser, | ||
please open your browser's console to read the error traceback (usually you can do this by pressing F12 and | ||
clicking in the Console tab).</p --> | ||
<p style="background-color: #f6f8fa; font-family: 'sans'; font-size:14px; margin-left: 20px;"><a | ||
href="https://github.com/berinhard/pyp5js"><b>pyp5js</b></a> running on top of <a | ||
href="https://github.com/iodide-project/pyodide" target="_blank">pyodide</a></p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Screen Console | ||
* 2022, Guilherme Ranoya | ||
* | ||
* Just repeat the information at the browser console in a | ||
* <div>, whose id is "ScreenConsole" | ||
* | ||
* Use: | ||
* | ||
* Insert this line in your <head> | ||
<script src="https://www.ranoya.com/Assets/JSLibs/ScreenConsole/startpanel.js"></script> | ||
* OR | ||
* | ||
* Insert this entire code inside a <script> tag in your <head> | ||
* | ||
* | ||
* That's it. | ||
* | ||
*/ | ||
|
||
console.defaultLog = console.log.bind(console); | ||
console.logs = []; | ||
|
||
let screen_console_wrap = document.createElement('div'); | ||
screen_console_wrap.setAttribute('id', 'ScreenConsoleWrap'); | ||
document.lastChild.appendChild(screen_console_wrap); | ||
document.getElementById('ScreenConsoleWrap').style.position = 'fixed'; | ||
document.getElementById('ScreenConsoleWrap').style.bottom = '0'; | ||
document.getElementById('ScreenConsoleWrap').style.width = '100%'; | ||
document.getElementById('ScreenConsoleWrap').style.height = '200px'; | ||
document.getElementById('ScreenConsoleWrap').style.zIndex = '1000'; | ||
document.getElementById('ScreenConsoleWrap').style.backgroundColor = '#FFFFFF'; | ||
|
||
let console_output_title = document.createElement('div'); | ||
console_output_title.setAttribute('id', 'ScreenConsoleTitle'); | ||
screen_console_wrap.appendChild(console_output_title); | ||
document.getElementById('ScreenConsoleTitle').innerHTML = 'Console'; | ||
document.getElementById('ScreenConsoleTitle').style.border = '1px solid grey'; | ||
document.getElementById('ScreenConsoleTitle').style.margin = '8px'; | ||
document.getElementById('ScreenConsoleTitle').style.marginBottom = 0; | ||
document.getElementById('ScreenConsoleTitle').style.padding = '8px'; | ||
document.getElementById('ScreenConsoleTitle').style.display = 'inline-block'; | ||
document.getElementById('ScreenConsoleTitle').style.color = 'white'; | ||
document.getElementById('ScreenConsoleTitle').style.backgroundColor = 'grey'; | ||
document.getElementById('ScreenConsoleTitle').style.fontFamily = 'monospace'; | ||
|
||
let console_output = document.createElement('div'); | ||
console_output.setAttribute('id', 'ScreenConsole'); | ||
screen_console_wrap.appendChild(console_output); | ||
document.getElementById('ScreenConsole').style.border = '1px solid grey'; | ||
document.getElementById('ScreenConsole').style.margin = '8px'; | ||
document.getElementById('ScreenConsole').style.marginTop = 0; | ||
document.getElementById('ScreenConsole').style.padding = '8px'; | ||
document.getElementById('ScreenConsole').style.width = 'calc(100% - 32px)'; | ||
document.getElementById('ScreenConsole').style.height = '130px'; | ||
document.getElementById('ScreenConsole').style.overflowY = 'scroll'; | ||
document.getElementById('ScreenConsole').style.fontFamily = 'monospace'; | ||
|
||
console.log = function () { | ||
console.defaultLog.apply(console, arguments); | ||
console.logs.push(Array.from(arguments)); | ||
document.getElementById('ScreenConsole').innerHTML += arguments[0] + '<br>'; | ||
} | ||
window.onerror = function (msg, url, line) { | ||
document.getElementById('ScreenConsole').innerHTML += 'Line: ' + line + '<br>' + msg + '<br>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters