Sexual Ecologies Diagram

by jude_pinto

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.6/interact.min.js"></script>



<button id= "button_E">Reset
</button>
<div id="container_1" class="resize-container_E">
  <span class="heading"> Gender/Sex Eroticism </span>
  <div id="Porn_E" class="resize-drag">
 

  <span id="Porn_Ea">Porn</span><span id="Porn_Eb">50%</span>
  </div>
  <div id="Fantasy_E" class="resize-drag">
 
    <span id="Fantasy_Ea">Fantasy</span><span id="Fantasy_Eb">50%</span>
  </div>
  <div id="In_Person_E" class="resize-drag">
 <span id="In_Person_Ea">In Person</span><span id="In_Person_Eb">50%</span>
  </div>
</div>
<button id= "submit_button">Submit
</button>

CSS

.resize-drag {
  /* shape parameters */
 border-radius: 50%;
  width: 142px;
  height: 142px;
  min-height: 1px;
  min-width: 1px;
  max-height: 200px;
  max-width: 200px;
  padding: 0px 0px 0px 0px;
  margin: 40px 40px 40px 35px;

  
  align-items: center;

  /* positioning */
  position: relative;

  /* text location */
  display: flex;
  justify-content: center;
  align-items: center;

 
  box-sizing: border-box;

  /* font */
  color: black;
  font-family: sans-serif;
  font-size: 18px;
  user-select: none;
  touch-action: none;
}

.resize-container_E {

  width: 450px;
  height: 400px;
  border-style: solid;
  text-align: center;
  position: relative;
  align-items: center;
  margin: 0 auto;
}



#button_E {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: block;
  font-size: 16px;
  position: relative;
  margin-left: 238px;
}


#submit_button {
  border-radius: 10%;
  background-color: #BD1414; /* Red */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: block;
  font-size: 16px;
  position: relative;
  margin: 20px 510px 100px;
}

.heading {
  color: black;
  font-family: sans-serif;
  font-size: 22px;
}

#Porn_E{
  background-color: rgba(35, 179, 241,.55);
  left: 122px;
  position: absolute;
  mix-blend-mode: multiply;
 
  }
   

#Porn_E span#Porn_Ea {
  display: inline;
}

#Porn_E:hover span#Porn_Ea {
  display: none;
}

#Porn_E span#Porn_Eb {
  display: none;
}

#Porn_E:hover span#Porn_Eb {
  display: inline;
}



#Fantasy_E {
  background-color:rgba(241, 234, 34,.55);
  top: 156px;
  left: 40px;
  position: absolute;
  mix-blend-mode: multiply;
}

#Fantasy_E span#Fantasy_Ea {
  display: inline;
}

#Fantasy_E:hover span#Fantasy_Ea {
  display: none;
}

#Fantasy_E span#Fantasy_Eb {
  display: none;
}

#Fantasy_E:hover span#Fantasy_Eb {
  display: inline;
}



#In_Person_E {
 ...

JavaScript

// Sexual Ecologies Diagram Code
//By: Jude Pinto
//535 lines of code.

// This code was implemented into a survey on Qualtrics for Aki Gormezano's study on Sexual Ecologies.

//This program has imported the library interact.js, created by Taye. 
//https://interactjs.io/


//Instructions: Drag and resize any circle using a mouse or touch screen. 

//To reset circle positions, press "Reset". To obtain the areas of the circles, areas of intersection, radii, and coordinates, click "Submit".

//---------------------------------------------------------------------------------


//Global Variables
//Usually, global variables are not ideal, however, I implemented them to make the program more legible to those conducting the study.

//Variables contain the initial radius and coordinate values of each circle when the program starts.

//PornE Global Start Values
var Porn_E_radius = document.getElementById("Porn_E").clientWidth/2;
var Porn_E_start = findCentroid(getPos1(Porn_E), getPos2(Porn_E));
var Porn_E_startx=  Porn_E_start.x2;
var Porn_E_starty= Porn_E_start.y2;


//FantasyE Global Start Values
var Fantasy_E_radius = document.getElementById("Fantasy_E").clientWidth/2;
var Fantasy_E_start = findCentroid(getPos1(Fantasy_E), getPos2(Fantasy_E));
var Fantasy_E_startx= Fantasy_E_start.x2;
var Fantasy_E_starty= Fantasy_E_start.y2;

//InPersonE Global Start Values
var In_Person_E_radius = document.getElementById("In_Person_E").clientWidth/2;
var In_Person_E_start =  findCentroid(getPos1(In_Person_E), getPos2(In_Person_E));
var In_Person_E_startx= In_Person_E_start.x2;
var In_Person_E_starty= In_Person_E_start.y2;



//Global Coordinate Dictionaries
//Contain the x and y coordinates of each circle

var CoordinatesX_E = {
  Porn_E: Porn_E_startx,
  Fantasy_E: Fantasy_E_startx,
  In_Person_E: In_Person_E_startx
};


var CoordinatesY_E = {
  Porn_E: Porn_E_starty,
  Fantasy_E: Fantasy_E_starty,
  In_Person_E: In_Person_E_starty
};

//Global Intersection Dictionaries:
//Contain...