<commit_before>// VCE Project - Value class
//
// A graphical, interactive valve class.
//
// Requires:
// - vce_utils.js
// - p5.js or p5.min.js
//
// <NAME> 2018
// <EMAIL>
//----------------------------------------------------------

function Valve(x, y, options) {

    // Valve attributes (image urls need to hard coded after
    // development)
    this.x = x;
    this.y = y;
    this.images = {};

    this.default_options = {
	scaling : 0.15,
	position : 0.5,
	name : ''}
    options = utils.merge_options(this.default_options, options)
    this.scaling = options.scaling;
    this.position = options.position;
    this.name = options.name;
    this.active = false;

    
    // Valve public methods
    this.set_position = function(new_pos) {
	if (new_pos => 0.0 && new_pos <= 1.0) {
	    this.position = new_pos;
	}
	else {
	    throw new RangeError("Valve position must be a number between 0 and 1. Requested: ", new_pos);
	};
    };


    this.is_on_handle = function(x, y) {
	var psuedo_body = {
	    position : this._handle_pos(),
	    angle : this._handle_angle()
	};
	var rotated_point = utils.rotate_point_with_body(psuedo_body, { x : x, y : y});
	var w = this.images.handle.width*this.scaling;
	var h = this.images.handle.height*this.scaling;
	if (rotated_point.x > psuedo_body.position.x - 0.5*w && rotated_point.x < psuedo_body.position.x + 0.5*w) {
	    if (rotated_point.y > psuedo_body.position.y - 0.5*h && rotated_point.y < psuedo_body.position.y + 0.5*h) {
 		return true;
	    };
	};
	return false
    };


    this.click = function() {
	this.active = true;
    };

    
    this.unclick = function() {
	this.active = false;
    };    
    
    
    this.show = function() {
	this._show_body();
	this._show_handle();
	this._show_position();
	this._show_name();
	if (this.active) { this._highlight() };
    };


    // Valve private methods
    this._show_body = function() {<commit_msg>lib vce_valve.Valve: adding empty drag method<commit_after>// VCE Project - Value class
//
// A graphical, interactive valve class.
//
// Requires:
// - vce_utils.js
// - p5.js or p5.min.js
//
// <NAME> 2018
// <EMAIL>
//----------------------------------------------------------

function Valve(x, y, options) {

    // Valve attributes (image urls need to hard coded after
    // development)
    this.x = x;
    this.y = y;
    this.images = {};

    this.default_options = {
	scaling : 0.15,
	position : 0.5,
	name : ''}
    options = utils.merge_options(this.default_options, options)
    this.scaling = options.scaling;
    this.position = options.position;
    this.name = options.name;
    this.active = false;

    
    // Valve public methods
    this.set_position = function(new_pos) {
	if (new_pos => 0.0 && new_pos <= 1.0) {
	    this.position = new_pos;
	}
	else {
	    throw new RangeError("Valve position must be a number between 0 and 1. Requested: ", new_pos);
	};
    };


    this.is_on_handle = function(x, y) {
	var psuedo_body = {
	    position : this._handle_pos(),
	    angle : this._handle_angle()
	};
	var rotated_point = utils.rotate_point_with_body(psuedo_body, { x : x, y : y});
	var w = this.images.handle.width*this.scaling;
	var h = this.images.handle.height*this.scaling;
	if (rotated_point.x > psuedo_body.position.x - 0.5*w && rotated_point.x < psuedo_body.position.x + 0.5*w) {
	    if (rotated_point.y > psuedo_body.position.y - 0.5*h && rotated_point.y < psuedo_body.position.y + 0.5*h) {
 		return true;
	    };
	};
	return false
    };


    this.click = function() {
	this.active = true;
    };

    
    this.unclick = function() {
	this.active = false;
    };


    this.drag = function() {
	// see https://codepen.io/DonKarlssonSan/pen/wgWyWx
    };
    
    
    this.show = function() {
	this._show_body();
	this._show_handle();
	this._show_position();
	this._show_name();
	if (this.active) { this._highlight() };
    };


    // Valve private methods
    this._show_body = function() {
{'fraction_non_alphanumeric': 0.17481631618951102, 'fraction_numerical': 0.01266784899923993, 'mean_word_length': 2.3486005089058524, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4404480', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1393, 'n_words': 295}