Created
September 21, 2020 11:56
-
-
Save Nekodigi/c165eff641e544241188adad4c1d4f63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //have to include javaFX | |
| //references https://github.com/davidbouchard/keystone | |
| //https://stackoverflow.com/questions/43004770/how-to-add-external-libraries-in-processing | |
| import javax.media.jai.*; | |
| import javax.media.jai.iterator.*; | |
| import javax.media.jai.operator.*; | |
| import javax.media.jai.registry.*; | |
| import javax.media.jai.remote.*; | |
| import javax.media.jai.tilecodec.*; | |
| import javax.media.jai.util.*; | |
| import javax.media.jai.widget.*; | |
| import com.sun.media.jai.iterator.*; | |
| import com.sun.media.jai.mlib.*; | |
| import com.sun.media.jai.opimage.*; | |
| import com.sun.media.jai.remote.*; | |
| import com.sun.media.jai.rmi.*; | |
| import com.sun.media.jai.tilecodec.*; | |
| import com.sun.media.jai.util.*; | |
| import com.sun.media.jai.widget.*; | |
| import javax.media.jai.PerspectiveTransform; | |
| import javax.media.jai.WarpPerspective; | |
| import java.awt.Point; | |
| import java.awt.geom.Point2D; | |
| WarpPerspective warpPerspective; | |
| void setup() { | |
| size(500, 500); | |
| PerspectiveTransform transform = PerspectiveTransform.getQuadToQuad(0, 0, width, 0, width, height, 0, height, 0, 0, 400, 100, 300, 400, 200, 500); | |
| warpPerspective = new WarpPerspective(transform); | |
| background(0); | |
| stroke(255); | |
| //draw example grid | |
| int gi = 10; | |
| int gj = 10; | |
| for(int i=0; i<=gi; i++){ | |
| Point2D point1 = warpPerspective.mapDestPoint(new Point((int)map(i, 0, gi, 0, width), 0)); | |
| Point2D point2 = warpPerspective.mapDestPoint(new Point((int)map(i, 0, gi, 0, width), height)); | |
| line((float)point1.getX(), (float)point1.getY(), (float)point2.getX(), (float)point2.getY()); | |
| } | |
| for(int j=0; j<=gj; j++){ | |
| Point2D point1 = warpPerspective.mapDestPoint(new Point(0, (int)map(j, 0, gj, 0, width))); | |
| Point2D point2 = warpPerspective.mapDestPoint(new Point(width, (int)map(j, 0, gj, 0, width))); | |
| line((float)point1.getX(), (float)point1.getY(), (float)point2.getX(), (float)point2.getY()); | |
| } | |
| } | |
| void draw() { | |
| Point2D point = warpPerspective.mapDestPoint(new Point(mouseX, mouseY)); | |
| ellipse((float)point.getX(), (float)point.getY(), 10, 10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment