Package de.fhpotsdam.unfolding.texture

Source Code of de.fhpotsdam.unfolding.texture.ExtrusionDistorter

package de.fhpotsdam.unfolding.texture;

import processing.core.PApplet;
import processing.core.PVector;

public class ExtrusionDistorter implements Distorter {

  public void distort(PVector origCoord, PVector distCoord, int col) {
    distCoord.x = origCoord.x;
    distCoord.y = origCoord.y;

    PApplet p = PAppletFactory.getInstance();

    // Random
    // distCoord.z = (float) (Math.random()) * 10;
    // Wave / Ripple
    // distCoord.z = (float) Math.sin(distCoord.x * 1.1f) * 5f;
    // Perlin Noise
    // distCoord.z = PApplet.sin(p.frameCount / 20f) * p.noise(distCoord.x, distCoord.y) * 50 -
    // 25;

    float brightness = p.brightness(col);
    float z = PApplet.map(brightness, 0, 255, -1, 1);
    // PApplet.println(col + ". " + brightness + "," + z);
    distCoord.z = z * PApplet.sin(p.frameCount / 20f) * 50;
  }

TOP

Related Classes of de.fhpotsdam.unfolding.texture.ExtrusionDistorter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.