Skip to content

Commit

Permalink
rename viewToModelPosition, rename position params, #27
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 6, 2021
1 parent e512dbb commit 07b76a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions js/ChartTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ class ChartTransform {

/**
* Transforms a model position to a view position.
* @param {Vector2} vector
* @param {Vector2} position
* @returns {Vector2}
* @public
*/
modelToViewPosition( vector ) {
return this.modelToViewXY( vector.x, vector.y );
modelToViewPosition( position ) {
return this.modelToViewXY( position.x, position.y );
}

/**
Expand Down Expand Up @@ -205,14 +205,14 @@ class ChartTransform {

/**
* Convert a view point to the corresponding model point.
* @param {Vector2} pt
* @param {Vector2} position
* @returns {Vector2}
* @public
*/
viewToModelPoint( pt ) {
viewToModelPosition( position ) {
return new Vector2(
this.viewToModel( Orientation.HORIZONTAL, pt.x ),
this.viewToModel( Orientation.VERTICAL, pt.y )
this.viewToModel( Orientation.HORIZONTAL, position.x ),
this.viewToModel( Orientation.VERTICAL, position.y )
);
}

Expand Down
2 changes: 1 addition & 1 deletion js/demo/DemoMultiplePlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DemoMultiplePlots extends VBox {
const point = event.pointer.point;
const parentPoint = chartRectangle.globalToParentPoint( point );
const constrainedParentPoint = new Bounds2( 0, 0, chartTransform.viewWidth, chartTransform.viewHeight ).closestPointTo( parentPoint );
const modelPt = chartTransform.viewToModelPoint( constrainedParentPoint );
const modelPt = chartTransform.viewToModelPosition( constrainedParentPoint );

readout.text = `x: ${Utils.toFixed( modelPt.x, 1 )}, y: ${Utils.toFixed( modelPt.y, 1 )}`;
};
Expand Down

0 comments on commit 07b76a4

Please sign in to comment.