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
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

    /
    SVG + Images (en)
    Updated Nov 14, 2019

    SVG + Images (en)

    Nov 14, 2019

    Analytics

    Loading data...

    deutsche Version

    SVG data can also be used in processing, but note that some SVG files may not be supported by processing. Processing can only handle simple SVG graphics, so avoid using radial gradients or complex clipping masks. 

    When exporting SVGs from illustrator, the following settings should produce working results. This does, however, depend on your version of illustrator. 

     

    PShape logo; PShape NASA; float rotAngle = 0.0; void setup() { size(600, 600); // load SVG files logo = loadShape("iadlogo.svg"); NASA = loadShape("nasalogo.svg"); shapeMode(CENTER); // set the images to be drawn from the center point smooth(); } void draw() { background(255); pushMatrix(); translate(width *.5, height *.5); rotate(rotAngle); shape(logo, 0, 0, logo.width, logo.height); popMatrix(); rotAngle+=.01; pushMatrix(); float scaleFactor =dist(mouseX, mouseY, width/2, height/2); scaleFactor = map(scaleFactor, 0, width, 1, 4); translate(mouseX, mouseY); scale(scaleFactor); shape(NASA, 0, 0, NASA.width, NASA.height); popMatrix(); }

    Download source

     

     

    In this example, 2D images (bitmap) are displayed and arrays are used. Here we use a 1. Dimensional array. To access an element of this array, we use these '[index]' brackets.

    PImage[] imageList; void setup() { size(800,800); 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,imageList[i].width/2,imageList[i].height/2); translate(150,0); } popMatrix(); }

    Download source

    Exercise 9

    • Draw a spaceship (spaceShip.jpg) and let this follow the mouse.

    • Make the planets orbit around the a sun in the middle of the screen. 

    • Change the program (and the image file) so that the planet is shown without the black box surrounding it. What file types are best suited for this? 

    Exercise 9 possible solution

     

    {"serverDuration": 60, "requestCorrelationId": "10b0ed199acc44dd9b1da10b57977a39"}