Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <html>
  <head>
    <meta charset="UTF-8">
    <title>Beratungs-Menü</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/addons/p5.dom.js"></script>
    <script src="beratungsmenue.js"></script>

    <style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style>
  </head>
  <body>
    <div id="p5-program"></div>
  </body>
</html>

              
            
!

CSS

              
                
              
            
!

JS

              
                //Beratungsmenue V1.1 - 2018_04_13
//
//MIT-Lizenz: Copyright (c) 2018 Matthias Perenthaler
//
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


/*global p5*/
let p5sketch = function(p) {

let cnv;
let canvasHoehe = 0;
let canvasBreite = 0;
let RandLinks = 30;

let konzeptmenueRund = true;

let buttonDurchmesser = 130;
let buttonKleinDurchmesser = 30;

let miniMenueBreite = 600;
let anzahlButtons = 9;
let buttonsAbstandZentrum = 240;
let ortsvektorZentrum;
let rotationsVektor;
let zielButtonVektor;
let zielPfeilVektor;

let buttonKoordinaten = [];
let buttonKoordinatenArray = [];
let buttonKleinKoordinaten = [];
let buttonKleinKoordinatenArray = [];
let pfeilKoordinaten = [];
let pfeilKoordinatenArray = [];  
let farbenArray = [];

let deltaY = 45;
let deltaX = 20;

let buttonTextArray = [
    "Beratungs-\nkonzept",
    "Klassen-\nlehrerinnen\nund -lehrer",
    "Tutorinnen\nund\nTutoren",
    "Laufbahn-\nberatung",
    "Berufs-\nberatung",
    "Externe\nUnterstützungs-\nsysteme",
    "Schüler-\nvertretung",
    "Mediation",
    "Coaching\nJg. 9+10",
    "Beratungs-\nteam"
];  

let buttonKleinTextArray = [
    "Beratungskonzept",
    "Klassenlehrerinnen und -lehrer",
    "Tutorinnen und Tutoren",
    "Laufbahnberatung",
    "Berufsberatung",
    "Externe Unterstützungssysteme",
    "Schülervertretung",
    "Mediation",
    "Coaching Jg. 9+10",
    "Beratungsteam"
]; 

let buttonLinks = [
  ["#", "_blank"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_self"],
  ["#", "_blank"],
  ["https://www.gymnasium-westerstede.de", "_self"]
];
  
  p.aktualisiereCanvas = function() {
    // canvasBreite = document.getElementById('rt-main').clientWidth-70;
    canvasBreite = p.windowWidth-2*RandLinks;
    if(canvasBreite < miniMenueBreite) { 
      konzeptmenueRund = false;
      canvasHoehe = 480;
    } 
    else { 
      konzeptmenueRund = true;
      canvasHoehe = 680;
    }    
    cnv.size(canvasBreite,canvasHoehe);
    
    ortsvektorZentrum.set(cnv.size().width/2,cnv.size().height/2);
    rotationsVektor.set(0,-buttonsAbstandZentrum);
    zielButtonVektor.set(0,0);
    zielPfeilVektor.set(0,0);   
    buttonKoordinaten = [];
    buttonKoordinatenArray = [];
    pfeilKoordinatenArray = [];
    
    buttonKoordinaten.push(ortsvektorZentrum.x,ortsvektorZentrum.y);
    buttonKoordinatenArray.push(buttonKoordinaten);
    for (let i = 0; i < anzahlButtons; i++) {
      buttonKoordinaten = [];
      pfeilKoordinaten = [];
      zielButtonVektor.set(0,0);
      zielPfeilVektor.set(0,0);
      rotationsVektor.set(0,-buttonsAbstandZentrum);
      rotationsVektor.rotate(p.TWO_PI/anzahlButtons*i);
      zielButtonVektor.add(ortsvektorZentrum);
      zielButtonVektor.add(rotationsVektor);
      buttonKoordinaten.push(zielButtonVektor.x,zielButtonVektor.y);
      buttonKoordinatenArray.push(buttonKoordinaten);
      rotationsVektor.set(0,-0.46*buttonsAbstandZentrum);
      rotationsVektor.rotate(p.TWO_PI/anzahlButtons*i);      
      zielPfeilVektor.add(ortsvektorZentrum);
      zielPfeilVektor.add(rotationsVektor);
      pfeilKoordinaten.push(zielPfeilVektor.x,zielPfeilVektor.y);
      pfeilKoordinatenArray.push(pfeilKoordinaten);     
    }
    buttonKleinKoordinatenArray = [];
    for (let i = 0; i < anzahlButtons+1; i++) {
      buttonKleinKoordinaten = [];
      buttonKleinKoordinaten.push(5+(i+1)*deltaY-buttonKleinDurchmesser/2,5+(i+1)*deltaY+buttonKleinDurchmesser/2);
      buttonKleinKoordinatenArray.push(buttonKleinKoordinaten);
    }
  };
  
  p.windowResized = function() {
    p.aktualisiereCanvas();
  };  

  p.setup = function() {
    // canvasBreite = document.getElementById('rt-main').clientWidth-70;
    canvasBreite = p.windowWidth-2*RandLinks;
    if(canvasBreite < miniMenueBreite) { 
      konzeptmenueRund = false;
      canvasHoehe = 480;
    } 
    else { 
      konzeptmenueRund = true;
      canvasHoehe = 680;
    }
    cnv = p.createCanvas(canvasBreite, canvasHoehe);
    p.frameRate(24);

    let c = p.color(64, 64, 64);
    farbenArray.push(c);
    c = p.color(0, 176, 240);
    farbenArray.push(c);
    farbenArray.push(c);
    c = p.color(78, 129, 200);
    farbenArray.push(c);
    farbenArray.push(c);
    c = p.color(115, 153, 129);
    farbenArray.push(c);
    c = p.color(102, 176, 80);
    farbenArray.push(c);
    c = p.color(146, 208, 80);
    farbenArray.push(c);
    c = p.color(228, 183, 10);
    farbenArray.push(c);
    c = p.color(232, 108, 10);
    farbenArray.push(c);
    
    ortsvektorZentrum = p.createVector(cnv.size().width/2,cnv.size().height/2);
    rotationsVektor = p.createVector(0,-buttonsAbstandZentrum);
    zielButtonVektor = p.createVector(0,0);
    zielPfeilVektor = p.createVector(0,0);    
    
    p.aktualisiereCanvas();
  };

  let ursprungsX = 0;
  let ursprungsY = 0;
  let zielX = 0;
  let zielY = 0;
  let aktuelleX = 0;
  let aktuelleY = 0;
  let klickAbstand = canvasBreite;
  let buttonAngeklicktStart = -1;
  let buttonAngeklicktEnde = -1;
  let scrollPos = 0;
    
  p.mouseClicked = p.touchStarted = function() {
    scrollPos = 0;
    ursprungsX = p.mouseX;
    ursprungsY = p.mouseY;
    if (konzeptmenueRund) {
      for (let i = 0; i < buttonKoordinatenArray.length; i++) {    
        klickAbstand = p.dist(ursprungsX, ursprungsY, buttonKoordinatenArray[i][0], buttonKoordinatenArray[i][1]);
        if(klickAbstand < buttonDurchmesser/2) {
          buttonAngeklicktStart = i; 
        }
      }
    }
    if (!konzeptmenueRund) {
      for (let i = 0; i < buttonKleinKoordinatenArray.length; i++) {
        if(buttonKleinKoordinatenArray[i][0] < ursprungsY && ursprungsY < buttonKleinKoordinatenArray[i][1]) {
          buttonAngeklicktStart = i;
        }
      }
    }
  };
  
  p.mouseDragged = p.touchMoved = function() {
    aktuelleX = p.mouseX;
    aktuelleY = p.mouseY;
  };
  
  p.mouseWheel = function(event) {
    scrollPos += event.delta;
  };
  
  p.mouseReleased = p.touchEnded = function() {
    zielX = p.mouseX;
    zielY = p.mouseY;
    let urlText = "https://www.gymnasium-westerstede.de";
    let zielTarget = "_self";
    if (konzeptmenueRund) {
      for (let i = 0; i < buttonKoordinatenArray.length; i++) {    
        klickAbstand = p.dist(zielX, zielY, buttonKoordinatenArray[i][0], buttonKoordinatenArray[i][1]);
        if(klickAbstand < buttonDurchmesser/2) {
          buttonAngeklicktEnde = i;
          if (buttonAngeklicktStart === buttonAngeklicktEnde && scrollPos === 0) {
            switch(buttonAngeklicktEnde) {
              case 0:
                  urlText = buttonLinks[0][0];
                  zielTarget = buttonLinks[0][1];
                  break;
              case 1:
                  urlText = buttonLinks[1][0];
                  zielTarget = buttonLinks[1][1];
                  break;
              case 2:
                  urlText = buttonLinks[2][0];
                  zielTarget = buttonLinks[2][1];
                  break;
              case 3:
                  urlText = buttonLinks[3][0];
                  zielTarget = buttonLinks[3][1];
                  break;
              case 4:
                  urlText = buttonLinks[4][0];
                  zielTarget = buttonLinks[4][1];
                  break;
              case 5:
                  urlText = buttonLinks[5][0];
                  zielTarget = buttonLinks[5][1];
                  break;
              case 6:
                  urlText = buttonLinks[6][0];
                  zielTarget = buttonLinks[6][1];
                  break;
              case 7:
                  urlText = buttonLinks[7][0];
                  zielTarget = buttonLinks[7][1];
                  break;              
              case 8:
                  urlText = buttonLinks[8][0];
                  zielTarget = buttonLinks[8][1];
                  break;              
              case 9:
                  urlText = buttonLinks[9][0];
                  zielTarget = buttonLinks[9][1];
                  break;              
              default:
                  urlText = "https://www.gymnasium-westerstede.de";
                  zielTarget = "_self";
          }
          window.open(urlText, zielTarget);
        }
      }                  
     }
    }
    if (!konzeptmenueRund) {
      for (let i = 0; i < buttonKleinKoordinatenArray.length; i++) {  
        if(buttonKleinKoordinatenArray[i][0] < zielY && zielY < buttonKleinKoordinatenArray[i][1]) {
          buttonAngeklicktEnde = i;
          if (buttonAngeklicktStart === buttonAngeklicktEnde && scrollPos === 0) {
            switch(buttonAngeklicktEnde) {
              case 0:
                  urlText = buttonLinks[0][0];
                  zielTarget = buttonLinks[0][1];
                  break;
              case 1:
                  urlText = buttonLinks[1][0];
                  zielTarget = buttonLinks[1][1];
                  break;
              case 2:
                  urlText = buttonLinks[2][0];
                  zielTarget = buttonLinks[2][1];
                  break;
              case 3:
                  urlText = buttonLinks[3][0];
                  zielTarget = buttonLinks[3][1];
                  break;
              case 4:
                  urlText = buttonLinks[4][0];
                  zielTarget = buttonLinks[4][1];
                  break;
              case 5:
                  urlText = buttonLinks[5][0];
                  zielTarget = buttonLinks[5][1];
                  break;
              case 6:
                  urlText = buttonLinks[6][0];
                  zielTarget = buttonLinks[6][1];
                  break;
              case 7:
                  urlText = buttonLinks[7][0];
                  zielTarget = buttonLinks[7][1];
                  break;              
              case 8:
                  urlText = buttonLinks[8][0];
                  zielTarget = buttonLinks[8][1];
                  break;              
              case 9:
                  urlText = buttonLinks[9][0];
                  zielTarget = buttonLinks[9][1];
                  break;              
              default:
                  urlText = "https://www.gymnasium-westerstede.de";
                  zielTarget = "_self";
            }
            window.open(urlText, zielTarget);
          }          
        }
      }    
    }
  };
  
  p.draw = function() {
    p.background(255);
    
    if(cnv.width < miniMenueBreite) { konzeptmenueRund = false } else { konzeptmenueRund = true }
    
    if (konzeptmenueRund) {
      for (let i = 0; i < buttonKoordinatenArray.length; i++) {    
        p.push();
        p.fill(farbenArray[i]);
        p.strokeWeight(0);
        p.ellipse(buttonKoordinatenArray[i][0],buttonKoordinatenArray[i][1],buttonDurchmesser,buttonDurchmesser);
        p.fill(255);
        p.strokeWeight(0);
        p.textSize(16);
        p.textAlign(p.CENTER,p.CENTER);
        p.text(buttonTextArray[i],buttonKoordinatenArray[i][0],buttonKoordinatenArray[i][1]);
        p.pop();      
      } 
      for (let i = 0; i < pfeilKoordinatenArray.length; i++) {    
        p.push();
        p.fill(178, 193, 219);
        p.strokeWeight(0);
        p.translate(pfeilKoordinatenArray[i][0],pfeilKoordinatenArray[i][1]);
        p.rotate(p.TWO_PI/anzahlButtons*i);
        p.beginShape();
        p.vertex(-14, 15);
        p.vertex(-14, -15);
        p.vertex(-24, -15);
        p.vertex(0, -30);
        p.vertex(24, -15);
        p.vertex(14, -15);
        p.vertex(14, 15);
        p.endShape(p.CLOSE);
        p.pop();      
      } 
      for (let i = 0; i < buttonKoordinatenArray.length; i++) {    
        let moveoverAbstand = p.dist(p.mouseX, p.mouseY, buttonKoordinatenArray[i][0], buttonKoordinatenArray[i][1]);
        if(moveoverAbstand < buttonDurchmesser/2) {
          p.cursor(p.HAND);
          break;
        }
        else {
          p.cursor(p.ARROW);
        }
      }
      p.push();
      p.textAlign(p.CENTER);
      p.strokeWeight(0);
      p.textSize(16);
      p.text("Für Informationen über einzelne Angebote bitte einen der Buttons anklicken.",canvasBreite/2,canvasHoehe-10);
      p.pop();         
    }
    if (!konzeptmenueRund) {
      p.strokeWeight(0);
      p.textSize(20);
      for (let i = 0; i < farbenArray.length; i++) {       
        p.push();
        p.fill(farbenArray[i]);
        p.ellipse(deltaX,5+(i+1)*deltaY,buttonKleinDurchmesser,buttonKleinDurchmesser);
        p.fill(0);
        p.text(buttonKleinTextArray[i],25+deltaX,12+(i+1)*deltaY);
        p.pop();        
      }
      if((buttonKleinKoordinatenArray[0][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[0][1]) ||
         (buttonKleinKoordinatenArray[1][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[1][1]) ||
         (buttonKleinKoordinatenArray[2][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[2][1]) ||
         (buttonKleinKoordinatenArray[3][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[3][1]) ||
         (buttonKleinKoordinatenArray[4][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[4][1]) ||
         (buttonKleinKoordinatenArray[5][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[5][1]) ||
         (buttonKleinKoordinatenArray[6][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[6][1]) ||
         (buttonKleinKoordinatenArray[7][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[7][1]) ||
         (buttonKleinKoordinatenArray[8][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[8][1]) ||
         (buttonKleinKoordinatenArray[9][0]<p.mouseY && p.mouseY < buttonKleinKoordinatenArray[9][1]))
      { 
        p.cursor(p.HAND); 
      } 
      else { 
        p.cursor(p.ARROW); 
      }
    }
 };
 
};

var konzeptmenueApp = new p5(p5sketch,'p5-program');
              
            
!
999px

Console