Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@
<head>
<meta charset="utf-8">

<title>Example</title>

<script src="https://cdn.rawgit.com/dynobo/snapjs/master/snap.js"></script>
<script src="program.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">


<title>Example</title>
</head>

<body>

<h1 id="mytitle">Beispiel</h1>
<div id="something">Drück auf den Knopf, um die Funktion auszulösen.</div>
<button type="button" onclick="myFunction()">Klick mich!</button>
<button id="pink" type="button" onclick="Flower()">Klick mich! und ich male eine Blume</button>
<button type="button" onclick="Clearall()">Reset</button>
<p>
<canvas id="stage" width=480px; height=360px; ></canvas>
<div id="variables"></div>
</p>
</body>
</html>

54 changes: 53 additions & 1 deletion program.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,56 @@
function myFunction() {
document.getElementById("mytitle").innerHTML = "Dieser Text wurde vom Skript geschrieben";
var c = document.getElementById("stage");
var ctx = c.getContext("2d");
ctx.fillStyle = "#021561";
ctx.fillRect(0, 0, 480, 360);
goToXY(20,20);
setPenSizeTo(1);
//setPenColorTo("#F3FF05");
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
penUp ()
for (var Sprung = 1; Sprung <= 15; Sprung++) {
var randomX = Math.floor(Math.random() * 361) -180
var randomY = Math.floor(Math.random() * 271) -135
goToXY(randomX,randomY);
setPenColorTo(getRandomColor());
penDown();
for (var zahl = 1; zahl <= 5; zahl++) {
move (50);
turnRight (144);
}
penUp ();
}

}

function Flower() {
goToXY(20,20);
setPenSizeTo(1);
setPenColorTo("#9C0303");
penDown();
for (var zahl = 1; zahl <= 25; zahl++) {
for (var kreis = 1; kreis <= 360; kreis++) {
move (1);
turnRight (1);
}
turnLeft (15);
}

}
function Clearall(){
var c = document.getElementById("stage");
var ctx = c.getContext("2d");
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 300, 150);
ctx.clearRect(0, 0, 480, 360);
}



9 changes: 8 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
body {
background-color: yellow;
background-color: pink;
}
#stage {
/*background-color: #021561;*/
border: 1px solid black;
}
#pink {
background-color: pink;
}