Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
/
SVG + Images (de)

SVG + Images (de)

Sep 22, 2017

In Processing können auch SVG-Daten genutzt werden, doch muss man hierbei beachten, dass nur ein Teil der SVG-Befehle von Processing unterstützt werden.

PShape elShape;
PShape warningShape;
float  rotAngle = 0.0;
 
void setup()
{
  size(600,600);      // def. fenstergroesse
 
  // lade die svg files
  elShape       = loadShape("High_voltage_warning.svg");
  warningShape  = loadShape("Achtung.svg");
 
  shapeMode(CENTER);    // nullpunkt des svg-objekts liegt in der mitte
  smooth();
}
 
void draw()
{
  background(255);
 
  pushMatrix();
    translate(width *.5,height *.5);
    rotate(rotAngle);
    shape(elShape,0,0,200,200);
  popMatrix();
  rotAngle+=.01;
 
  shape(warningShape,mouseX,mouseY,100,100);
}

Download source

In diesem Beispiel werden 2.D Bilder(Bitmap) dargestellt und es werden Arrays genutzt.  Hier nutzen wir ein 1.Dimensionales Array. Ein Array ist ein Feld mit n-Datenfelder eines definierten Datentypes. Um auf ein Element dieses Array zuzugreifen benutzt man diese ‘[index]‘-Klammern.

PImage[] imageList = null;    // variable sauber initialisieren
 
void setup()
{
  size(600,600);      // def. fenstergroesse
 
  imageList = new PImage[3];
  imageList[0] = loadImage("./images/1.jpg");
  imageList[1] = loadImage("./images/2.jpg");
  imageList[2] = loadImage("./images/3.jpg");
}
 
void draw()
{
  background(255);
 
  pushMatrix();
    translate(10,100);
    for(int i=0;i < imageList.length; i++)
    {
       image(imageList[i],0,0,140,140);
       translate(150,0);
    }
  popMatrix();
}

Download source

Aufgabe

Zeichne einen 4.Planeten(4.jpg) und lass diesen Planeten der Maus folgen. Verändere das Programm und die Daten in der Weise, dass der 4.Planet und nur der 4.Planet dargestellt wird (kein eckiges Bild, sondern nur der Planet).


, multiple selections available,
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
  • Programming in Processing (java)
    • Starting with Processing (en)
    • Variables (en)
    • Classes and Objects (en)
    • Events und Functions (en)
    • Writing our own Functions (en)
    • Random Numbers (en)
    • Conditionals (en)
    • Loops (en)
    • Nested Loops (en)
    • Coordinates (en)
    • Arrays and Lists (en)
    • SVG + Images (en)
      • SVG + Images (de)
    • Motion and Temporality
    • Gesture Interactions
    • Using bitmaps as modifiers
    • Vectors
    • Animation
    • Animation 2
    • Simple Collision Detection
    • Sound
    • Typography

{"serverDuration": 34, "requestCorrelationId": "6cc7dbda08ea4458b80dfd04571f6e78"}