-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend Brython example to show integration with JS. Add smartdown.inc…
…lude examples to Extensions.md. Change smartdown.use to smartdown.import
- Loading branch information
Showing
15 changed files
with
291 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
digraph "unix" { | ||
graph [ fontname = "Helvetica-Oblique", | ||
fontsize = 36, | ||
label = "\n\n\n\nObject Oriented Graphs\nStephen North, 3/19/93", | ||
size = "12,12" ]; | ||
node [ shape = polygon, | ||
sides = 4, | ||
distortion = "0.0", | ||
orientation = "0.0", | ||
skew = "0.0", | ||
color = white, | ||
style = filled, | ||
fontname = "Helvetica-Outline", | ||
fontsize = "36"]; | ||
"5th Edition" [sides=9, distortion="0.936354", orientation=28, skew="-0.126818", color=salmon2]; | ||
"6th Edition" [sides=5, distortion="0.238792", orientation=11, skew="0.995935", color=deepskyblue]; | ||
"PWB 1.0" [sides=8, distortion="0.019636", orientation=79, skew="-0.440424", color=goldenrod2]; | ||
LSX [sides=9, distortion="-0.698271", orientation=22, skew="-0.195492", color=burlywood2]; | ||
"1 BSD" [sides=7, distortion="0.265084", orientation=26, skew="0.403659", color=gold1]; | ||
"Mini Unix" [distortion="0.039386", orientation=2, skew="-0.461120", color=greenyellow]; | ||
Wollongong [sides=5, distortion="0.228564", orientation=63, skew="-0.062846", color=darkseagreen]; | ||
Interdata [distortion="0.624013", orientation=56, skew="0.101396", color=dodgerblue1]; | ||
"Unix/TS 3.0" [sides=8, distortion="0.731383", orientation=43, skew="-0.824612", color=thistle2]; | ||
"PWB 2.0" [sides=6, distortion="0.592100", orientation=34, skew="-0.719269", color=darkolivegreen3]; | ||
"7th Edition" [sides=10, distortion="0.298417", orientation=65, skew="0.310367", color=chocolate]; | ||
"8th Edition" [distortion="-0.997093", orientation=50, skew="-0.061117", color=turquoise3]; | ||
"32V" [sides=7, distortion="0.878516", orientation=19, skew="0.592905", color=steelblue3]; | ||
V7M [sides=10, distortion="-0.960249", orientation=32, skew="0.460424", color=navy]; | ||
"Ultrix-11" [sides=10, distortion="-0.633186", orientation=10, skew="0.333125", color=darkseagreen4]; | ||
Xenix [sides=8, distortion="-0.337997", orientation=52, skew="-0.760726", color=coral]; | ||
"UniPlus+" [sides=7, distortion="0.788483", orientation=39, skew="-0.526284", color=darkolivegreen3]; | ||
"9th Edition" [sides=7, distortion="0.138690", orientation=55, skew="0.554049", color=coral3]; | ||
"2 BSD" [sides=7, distortion="-0.010661", orientation=84, skew="0.179249", color=blanchedalmond]; | ||
"2.8 BSD" [distortion="-0.239422", orientation=44, skew="0.053841", color=lightskyblue1]; | ||
"2.9 BSD" [distortion="-0.843381", orientation=70, skew="-0.601395", color=aquamarine2]; | ||
"3 BSD" [sides=10, distortion="0.251820", orientation=18, skew="-0.530618", color=lemonchiffon]; | ||
"4 BSD" [sides=5, distortion="-0.772300", orientation=24, skew="-0.028475", color=darkorange1]; | ||
"4.1 BSD" [distortion="-0.226170", orientation=38, skew="0.504053", color=lightyellow1]; | ||
"4.2 BSD" [sides=10, distortion="-0.807349", orientation=50, skew="-0.908842", color=darkorchid4]; | ||
"4.3 BSD" [sides=10, distortion="-0.030619", orientation=76, skew="0.985021", color=lemonchiffon2]; | ||
"Ultrix-32" [distortion="-0.644209", orientation=21, skew="0.307836", color=goldenrod3]; | ||
"PWB 1.2" [sides=7, distortion="0.640971", orientation=84, skew="-0.768455", color=cyan]; | ||
"USG 1.0" [distortion="0.758942", orientation=42, skew="0.039886", color=blue]; | ||
"CB Unix 1" [sides=9, distortion="-0.348692", orientation=42, skew="0.767058", color=firebrick]; | ||
"USG 2.0" [distortion="0.748625", orientation=74, skew="-0.647656", color=chartreuse4]; | ||
"CB Unix 2" [sides=10, distortion="0.851818", orientation=32, skew="-0.020120", color=greenyellow]; | ||
"CB Unix 3" [sides=10, distortion="0.992237", orientation=29, skew="0.256102", color=bisque4]; | ||
"Unix/TS++" [sides=6, distortion="0.545461", orientation=16, skew="0.313589", color=mistyrose2]; | ||
"PDP-11 Sys V" [sides=9, distortion="-0.267769", orientation=40, skew="0.271226", color=cadetblue1]; | ||
"USG 3.0" [distortion="-0.848455", orientation=44, skew="0.267152", color=bisque2]; | ||
"Unix/TS 1.0" [distortion="0.305594", orientation=75, skew="0.070516", color=orangered]; | ||
"TS 4.0" [sides=10, distortion="-0.641701", orientation=50, skew="-0.952502", color=crimson]; | ||
"System V.0" [sides=9, distortion="0.021556", orientation=26, skew="-0.729938", color=darkorange1]; | ||
"System V.2" [sides=6, distortion="0.985153", orientation=33, skew="-0.399752", color=darkolivegreen4]; | ||
"System V.3" [sides=7, distortion="-0.687574", orientation=58, skew="-0.180116", color=lightsteelblue1]; | ||
"5th Edition" -> "6th Edition"; | ||
"5th Edition" -> "PWB 1.0"; | ||
"6th Edition" -> LSX; | ||
"6th Edition" -> "1 BSD"; | ||
"6th Edition" -> "Mini Unix"; | ||
"6th Edition" -> Wollongong; | ||
"6th Edition" -> Interdata; | ||
Interdata -> "Unix/TS 3.0"; | ||
Interdata -> "PWB 2.0"; | ||
Interdata -> "7th Edition"; | ||
"7th Edition" -> "8th Edition"; | ||
"7th Edition" -> "32V"; | ||
"7th Edition" -> V7M; | ||
"7th Edition" -> "Ultrix-11"; | ||
"7th Edition" -> Xenix; | ||
"7th Edition" -> "UniPlus+"; | ||
V7M -> "Ultrix-11"; | ||
"8th Edition" -> "9th Edition"; | ||
"1 BSD" -> "2 BSD"; | ||
"2 BSD" -> "2.8 BSD"; | ||
"2.8 BSD" -> "Ultrix-11"; | ||
"2.8 BSD" -> "2.9 BSD"; | ||
"32V" -> "3 BSD"; | ||
"3 BSD" -> "4 BSD"; | ||
"4 BSD" -> "4.1 BSD"; | ||
"4.1 BSD" -> "4.2 BSD"; | ||
"4.1 BSD" -> "2.8 BSD"; | ||
"4.1 BSD" -> "8th Edition"; | ||
"4.2 BSD" -> "4.3 BSD"; | ||
"4.2 BSD" -> "Ultrix-32"; | ||
"PWB 1.0" -> "PWB 1.2"; | ||
"PWB 1.0" -> "USG 1.0"; | ||
"PWB 1.2" -> "PWB 2.0"; | ||
"USG 1.0" -> "CB Unix 1"; | ||
"USG 1.0" -> "USG 2.0"; | ||
"CB Unix 1" -> "CB Unix 2"; | ||
"CB Unix 2" -> "CB Unix 3"; | ||
"CB Unix 3" -> "Unix/TS++"; | ||
"CB Unix 3" -> "PDP-11 Sys V"; | ||
"USG 2.0" -> "USG 3.0"; | ||
"USG 3.0" -> "Unix/TS 3.0"; | ||
"PWB 2.0" -> "Unix/TS 3.0"; | ||
"Unix/TS 1.0" -> "Unix/TS 3.0"; | ||
"Unix/TS 3.0" -> "TS 4.0"; | ||
"Unix/TS++" -> "TS 4.0"; | ||
"CB Unix 3" -> "TS 4.0"; | ||
"TS 4.0" -> "System V.0"; | ||
"System V.0" -> "System V.2"; | ||
"System V.2" -> "System V.3"; | ||
} | ||
|
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,15 @@ | ||
// | ||
// This playable code has been loaded from ExtensionsPlayableHelloWorld.js | ||
// in the same directory that its likely includer Extensions.md resides in. | ||
// | ||
|
||
console.log('W00t! This is ExtensionsPlayableHelloWorld.js'); | ||
|
||
const playableDiv = this.div; | ||
playableDiv.style.border = '5px solid purple'; | ||
playableDiv.style.background = 'lightgreen'; | ||
playableDiv.innerHTML = '<h1>Hello World</h1>'; | ||
|
||
// | ||
// End of ExtensionsPlayableHelloWorld.js | ||
// |
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,8 @@ | ||
/* global p5 */ | ||
|
||
p5.setup = function setup() { | ||
}; | ||
|
||
p5.draw = function draw() { | ||
p5.ellipse(50, 50, 80, 80); | ||
}; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## p5.play Examples | ||
|
||
[p5.play](https://github.com/molleindustria/p5.play) is a Javascript library that extends the functionality of p5.js with animation, sprites, and collision detection, amongst other features. We will be using the [code.org fork](https://github.com/code-dot-org/p5.play) of p5.play, because it appears to be more maintained currently. | ||
|
||
The following example From [Making Games with p5.play](https://creative-coding.decontextualize.com/making-games-with-p5-play/) uses `smartdown.import` to dynamically load the p5.play library, and then it draws a field of 'coins' which you can gather up by moving your mouse around. | ||
|
||
**Warning** This use of p5.play is at a very early stage, and there are negative interactions between the p5.play library and ordinary p5.js code. For example, p5.play modifies the p5.camera function and turns it into an object. This is not well-behaved and results in other p5.js examples (e.g., Mobius) not working. The workaround for now is to NOT run the p5.play examples except for experimental purposes, and if you do run a p5.play example, remember to reload your Smartdown page to eliminate the negative effects on your p5.js library. This is a fixable problem, but requires more study. | ||
|
||
|
||
```P5JS/playable/debug | ||
//smartdown.import=https://cdn.rawgit.com/code-dot-org/p5.play/master/lib/p5.play.js | ||
window.allowP5PlayInit = false; | ||
var Group = p5.Group; | ||
var createSprite = p5.createSprite.bind(p5); | ||
var drawSprites = p5.drawSprites.bind(p5); | ||
var coins; | ||
var player; | ||
var score = 0; | ||
function setup() { | ||
createCanvas(400, 400); | ||
coins = new Group(); | ||
for (var i = 0; i < 10; i++) { | ||
var c = createSprite( | ||
random(100, width-100), | ||
random(100, height-100), | ||
10, 10); | ||
c.shapeColor = color(255, 255, 0); | ||
coins.add(c); | ||
} | ||
player = createSprite(50, 50, 40, 40); | ||
player.shapeColor = color(255); | ||
} | ||
function draw() { | ||
background(50); | ||
player.velocity.x = | ||
(mouseX-player.position.x)*0.1; | ||
player.velocity.y = | ||
(mouseY-player.position.y)*0.1; | ||
player.overlap(coins, getCoin); | ||
drawSprites(); | ||
fill(255); | ||
noStroke(); | ||
textSize(72); | ||
textAlign(CENTER, CENTER); | ||
if (coins.length > 0) { | ||
text(score, width/2, height/2); | ||
} | ||
else { | ||
text("you win!", width/2, height/2); | ||
} | ||
} | ||
function getCoin(player, coin) { | ||
coin.remove(); | ||
score += 1; | ||
} | ||
``` | ||
|
||
|
||
--- | ||
|
||
[Back to Home](:@Home) | ||
|
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
Oops, something went wrong.