Category

2017년 7월 7일 금요일

import ketai.ui.*;
import android.view.MotionEvent;

KetaiGesture gesture;

PImage compass_img,compass_img2;

int r, y;
float scaleFactor = .04;
PFont f;

void setup() {
  size(displayWidth, displayHeight,P3D);
  // background(20);
  //size((displayWidth-30),(displayHeight-30), P3D);
  background(20);
  f = createFont("Arial",24,true);
  orientation(LANDSCAPE);
  gesture = new KetaiGesture(this);
  noStroke();
                         // 1
  y = height;
}

void draw() {
  background(0);
  
 textFont(f);       
 
 textAlign(RIGHT);
 fill(0,0,200);
  text("Text_test#1.",width-100,100); 
fill(150,0,0);
text("Text_test#2.",width-100,150); 
fill(0,200,0);
text("Text_test#3.",width-100,200);
fill(200,100,100);
text("Text_test#4.",width-100,250); 
fill(0,200,100);
text("Text_test#5.",width-100,300);

  compass_img= loadImage("HYU_initial_eng.png");
   int img_size = 160;
   image(compass_img, width-200, 320, img_size, img_size/3);
   //image(compass_img, 900-img_size/2, 570-img_size/2, img_size, img_size/3);
   
   compass_img2= loadImage("ljk_logo2.png");
   image(compass_img2, width-200, 400, img_size, img_size/2);
   //image(compass_img2, 900-img_size/2, 470-img_size/2, img_size, img_size/2);

  lights();                                               // 2

  translate(width*0.4, displayHeight*0.3);                                  // 3
  scale(scaleFactor);                                     // 4
  //scale(0.3);  
  //rotateX(PI);                                            // 5
  rotateY(radians(r/10));                                    // 6

  //box(10);                                            // 7
  drawMap();
  
}

void drawMap()
{
  float i=0;
  float j=0;
  float lenth=displayWidth;
  float lenth2=displayHeight;
  float sep=20.0;
    
    strokeWeight(2);
   stroke(lenth); 
   fill(255); //white line 
    
    while(i<lenth) {
    i=i+(lenth/sep);
    j=j+(lenth2/sep);
    
    line(i,lenth2,0,i,lenth2,lenth);
    line(0,lenth2,i,lenth,lenth2,i);
   

    line(0,j,0,lenth,j,0);
    line(i,0,0,i,lenth2,0);  
    
    line(0,j,0,0,j,lenth);
    line(0,0,i,0,lenth2,i);
    }
    
    pushMatrix();
    strokeWeight(5);
  stroke(0,lenth,0); 
  line(0, lenth2, 0, lenth, lenth2, 0);
  fill(0,100,0);
  text("X Axis",lenth2,lenth2,0);
  popMatrix();
  
  pushMatrix();
  strokeWeight(5);
  stroke(lenth,0,0);
  line(0, lenth2, 0, 0, 0, 0);
  rotate(-HALF_PI);
  fill(255,0,0);
  text("Y Axis",-lenth2+100,-5,0);
  popMatrix(); 
  
  pushMatrix();
   strokeWeight(5);
  stroke(0,0,lenth);
  line(0, lenth2, 0, 0, lenth2, lenth);
  rotateY(-HALF_PI);
  fill(0,0,255);
  text("Z Axis",lenth2-100,lenth2,0);
  popMatrix();
  objectdraw();
}

void onPinch(float x, float y, float d)                   // 8
{
  scaleFactor += d/5000;
  //scaleFactor=0.3;
  scaleFactor = constrain(scaleFactor, 0.01, .3);
  //int a=1/100;
  //scaleFactor = constrain(a, 0.01, .3);
  println(scaleFactor);
} //zoom in



void mouseDragged()                                       // 9
{
  if (abs(mouseX - pmouseX) < 50) 
    r += mouseX - pmouseX;
  if (abs(mouseY - pmouseY) < 50) 
    y += mouseY - pmouseY;
} //motion rotated

public boolean surfaceTouchEvent(MotionEvent event) {
  super.surfaceTouchEvent(event);
  return gesture.surfaceTouchEvent(event);
}

void objectdraw(){
  y=displayHeight;
  
  pushMatrix(); //anchor 1
  translate(600, y-600, 600);
  noFill();
  stroke(255,0,0);
  sphere(20);
  popMatrix();
  
  pushMatrix(); //anchor 2
  translate(100, y-100, 100);
  noFill();
  stroke(255,255,200);
  sphere(20);
  popMatrix();

  pushMatrix(); //anchor 3
  translate(250, y-250, 250);
  noFill();
  stroke(0,0,255);
  sphere(20);
  popMatrix();

  pushMatrix(); //anchor 4
  translate(400, y-400, 400);
  noFill();
  stroke(0,255,0);
  sphere(20);
  popMatrix();
}

댓글 없음:

댓글 쓰기