<commit_before>// Copyright 2018, University of Colorado Boulder

/**
 * Dashed lines that connect the 'point on quadratic' to the focus and directrix.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( require => {
  'use strict';

  // modules
  const GQColors = require( 'GRAPHING_QUADRATICS/common/GQColors' );
  const GQConstants = require( 'GRAPHING_QUADRATICS/common/GQConstants' );
  const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Path = require( 'SCENERY/nodes/Path' );
  const Property = require( 'AXON/Property' );
  const Shape = require( 'KITE/Shape' );

  /**
   * @param {Property.<Quadratic>} quadraticProperty
   * @param {Property.<Vector2>} pointOnQuadraticProperty
   * @param {ModelViewTransform2} modelViewTransform
   * @param {Property.<Boolean>} pointOnQuadraticVisibleProperty
   * @param {Property.<Boolean>} focusVisibleProperty
   * @param {Property.<Boolean>} directrixVisibleProperty
   */
  class PointOnQuadraticLinesNode extends Node {

    constructor( quadraticProperty, pointOnQuadraticProperty, modelViewTransform,
                 pointOnQuadraticVisibleProperty, focusVisibleProperty, directrixVisibleProperty ) {

      const path = new Path( null, {
        stroke: GQColors.POINT_ON_QUADRATIC,
        lineWidth: GQConstants.POINT_ON_QUADRATIC_LINE_WIDTH,
        lineDash: GQConstants.POINT_ON_QUADRATIC_LINE_DASH
      } );
      
      super( { children: [ path ] } );

      // update the lines
      Property.multilink( [ quadraticProperty, pointOnQuadraticProperty ],
        ( quadratic, pointOnQuadratic ) => {

          assert && assert( quadratic.focus !== undefined, 'undefined focus is not supported' );
          assert && assert( quadratic.directrix !== undefined, 'undefined directrix is not supported' );

          path.shape = new Shape()
            .moveToPoint( modelViewTransform.modelToViewPosition( quadratic.focus ) )
            .lineToPoint( modelViewTransform.modelToViewPosition( pointOnQuadratic ) )
            .lineTo( modelViewTransform.modelToViewX( pointOnQuadratic.x ), modelViewTransform.modelToViewY( quadratic.directrix ) );
        } );

      Property.multilink( [ pointOnQuadraticVisibleProperty, focusVisibleProperty, directrixVisibleProperty ],
        ( pointOnQuadraticVisible, focusVisibleProperty, directrixVisible ) => {
        path.visible = ( pointOnQuadraticVisible && focusVisibleProperty && directrixVisible );
        } );<commit_msg>split into 2 lines, so that visibility can be controlled independently<commit_after>// Copyright 2018, University of Colorado Boulder

/**
 * Dashed lines that connect the 'point on quadratic' to the focus and directrix.
 * This is implemented as 2 Lines (rather than 1 Path) so that their visibility can be controlled independently.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( require => {
  'use strict';

  // modules
  const GQColors = require( 'GRAPHING_QUADRATICS/common/GQColors' );
  const GQConstants = require( 'GRAPHING_QUADRATICS/common/GQConstants' );
  const graphingQuadratics = require( 'GRAPHING_QUADRATICS/graphingQuadratics' );
  const Line = require( 'SCENERY/nodes/Line' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Property = require( 'AXON/Property' );

  /**
   * @param {Property.<Quadratic>} quadraticProperty
   * @param {Property.<Vector2>} pointOnQuadraticProperty
   * @param {ModelViewTransform2} modelViewTransform
   * @param {Property.<Boolean>} pointOnQuadraticVisibleProperty
   * @param {Property.<Boolean>} focusVisibleProperty
   * @param {Property.<Boolean>} directrixVisibleProperty
   */
  class PointOnQuadraticLinesNode extends Node {

    constructor( quadraticProperty, pointOnQuadraticProperty, modelViewTransform,
                 pointOnQuadraticVisibleProperty, focusVisibleProperty, directrixVisibleProperty ) {

      const pathOptions = {
        stroke: GQColors.POINT_ON_QUADRATIC,
        lineWidth: GQConstants.POINT_ON_QUADRATIC_LINE_WIDTH,
        lineDash: GQConstants.POINT_ON_QUADRATIC_LINE_DASH
      };

      // line connecting point and focus
      const focusLine = new Line( 0, 0, 0, 1, pathOptions );

      // line connecting point and directrix                                             
      const directrixLine = new Line( 0, 0, 0, 1, pathOptions );

      super( { children: [ focusLine, directrixLine ] } );

      // update the lines
      Property.multilink( [ quadraticProperty, pointOnQuadraticProperty ],
        ( quadratic, pointOnQuadratic ) => {

          assert && assert( quadratic.focus !== undefined, 'undefined focus is not supported' );
          assert && assert( quadratic.directrix !== undefined, 'undefined directrix is not supported' );

          const pointView = modelViewTransform.modelToViewPosition( pointOnQuadratic );
          const focusView = modelViewTransform.modelToViewPosition( quadratic.focus );
          const directrixView = modelViewTransform.modelToViewY( quadratic.directrix );

          focusLine.setLine( pointView.x, pointView.y, focusView.x, focusView.y );
          directrixLine.setLine( pointView.x, pointView.y, pointView.x, directrixView );
        } );

      // visibility
      Property.multilink( [ pointOnQuadraticVisibleProperty, focusVisibleProperty, directrixVisibleProperty ],
        ( pointOnQuadraticVisible, focusVisibleProperty, directrixVisible ) => {
          focusLine.visible = ( pointOnQuadraticVisible && focusVisibleProperty && directrixVisible );
          directrixLine.visible = ( pointOnQuadraticVisible && focusVisibleProperty && directrixVisible );
        } );
{'fraction_non_alphanumeric': 0.09761694616063549, 'fraction_numerical': 0.004060017652250662, 'mean_word_length': 3.6404586404586405, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5932162', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1561, 'n_words': 365}