charts.lines: add calc-y
parent
8510b351cf
commit
fb2538a946
|
@ -4,6 +4,10 @@ USING: tools.test charts.lines charts.lines.private ;
|
||||||
IN: charts.lines.tests
|
IN: charts.lines.tests
|
||||||
|
|
||||||
{ -2/3 } [ { 1 3 } { -2 5 } calc-line-slope ] unit-test
|
{ -2/3 } [ { 1 3 } { -2 5 } calc-line-slope ] unit-test
|
||||||
|
{ 3 } [ -2/3 1 { 1 3 } calc-y ] unit-test
|
||||||
|
{ 5 } [ -2/3 -2 { 1 3 } calc-y ] unit-test
|
||||||
|
{ 3 } [ -2/3 1 { -2 5 } calc-y ] unit-test
|
||||||
|
{ 5 } [ -2/3 -2 { -2 5 } calc-y ] unit-test
|
||||||
|
|
||||||
{ { } }
|
{ { } }
|
||||||
[ { } { } clip-data ] unit-test
|
[ { } { } clip-data ] unit-test
|
||||||
|
|
|
@ -62,6 +62,7 @@ TUPLE: line < gadget color data ;
|
||||||
! } 2&& ;
|
! } 2&& ;
|
||||||
|
|
||||||
: calc-line-slope ( point1 point2 -- slope ) v- first2 swap / ;
|
: calc-line-slope ( point1 point2 -- slope ) v- first2 swap / ;
|
||||||
|
: calc-y ( slope x point -- y ) first2 [ - * ] dip + ;
|
||||||
|
|
||||||
: clip-by-first ( min,max pairs -- pairs' )
|
: clip-by-first ( min,max pairs -- pairs' )
|
||||||
2dup first-in-bounds? [
|
2dup first-in-bounds? [
|
||||||
|
|
Loading…
Reference in New Issue