Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Need to make click and drop

$
0
0

Hi, I'm very very new to using processing, I have an idea I want to make a reality, but I'm still a beginner to coding and stuff. I have a long way to go, but here is what I have so far...

import processing.sound.*;
SoundFile file;

PFont Serif;
int gridSize = 100;
PVector object;
float x, y;

final static private int actualGrid = 100; // 100 pixels wide grid

void setup() {
  fullScreen();
  background(52);
  // Load a soundfile from the /data folder of the sketch and play it back
  file = new SoundFile(this, "Giriu Dvasios - Zeme.mp3");
  file.play();
  x = random(width);
  y = random(height);

  //Font Properties
  smooth();
  Serif = createFont("Serif", 60);
}

void draw() {
  background(52);
  //Draw the Interactive Canvas

  noStroke();
  fill(27);
  rect(270, 170, 1800, 1200);

  fill(224);
  stroke(238);
  strokeWeight(1);
  for (int i=0; i<18; i++) {
    for (int j=0; j<12; j++) {
      rect(250+100*i, 150+100*j, 100, 100);
    }
  }
  x-=x%100;
  y-=y%100;
  if (mousePressed) {
    x=mouseX;
    y=mouseY;
  }
  noStroke();
  fill(255, 0, 128);
  ellipse(x, y, 80, 80);

  //Headline

  fill(240);
  textFont(Serif);
  text("THE ARCHITECTURE OF", 255, 85);
  text("COLLABORATIVE DESIGN", 255, 135);

  //Draw the shape of the menu blocks

  //Block1
  noStroke();
  fill(27);
  rect(60, 160, 150, 150);
  noStroke();
  fill(224);
  rect(50, 150, 150, 150);

  //Block2
  noStroke();
  fill(27);
  rect(60, 360, 150, 150);
  noStroke();
  fill(224);
  rect(50, 350, 150, 150);

  //Draw the line-shapes inside the block

  //BlockLine1
  stroke(161);
  strokeWeight(5);
  line(75, 175, 175, 275);

  //BlockLine2
  stroke(161);
  strokeWeight(5);
  line(75, 475, 175, 375);
}

I would like to make it so that you can press on the line shapes on the side menu and press on the grid-canvas to place them. I want it so that the user can drag them around the canvas and then remove them by right-clicking on the shape.

It know it may seem an easy enough idea, but the existing code with the ball is conflicting with it, I copied it from somewhere online and I don't really need it, just unsure which parts to take away.


Viewing all articles
Browse latest Browse all 2896

Trending Articles