charts.lines: add calc-line-slope
parent
cdc321cd93
commit
8510b351cf
|
@ -1,8 +1,10 @@
|
||||||
! Copyright (C) 2017 Alexander Ilin.
|
! Copyright (C) 2017 Alexander Ilin.
|
||||||
|
|
||||||
USING: tools.test charts.lines ;
|
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
|
||||||
|
|
||||||
{ { } }
|
{ { } }
|
||||||
[ { } { } clip-data ] unit-test
|
[ { } { } clip-data ] unit-test
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
USING: accessors arrays binary-search charts
|
USING: accessors arrays binary-search charts
|
||||||
combinators.short-circuit kernel locals math math.order
|
combinators.short-circuit kernel locals math math.order
|
||||||
math.statistics opengl opengl.gl sequences
|
math.statistics math.vectors opengl opengl.gl sequences
|
||||||
specialized-arrays.instances.alien.c-types.float ui.gadgets
|
specialized-arrays.instances.alien.c-types.float ui.gadgets
|
||||||
ui.render ;
|
ui.render ;
|
||||||
IN: charts.lines
|
IN: charts.lines
|
||||||
|
@ -61,6 +61,8 @@ TUPLE: line < gadget color data ;
|
||||||
! [ [ second ] dip second-in-bounds? ]
|
! [ [ second ] dip second-in-bounds? ]
|
||||||
! } 2&& ;
|
! } 2&& ;
|
||||||
|
|
||||||
|
: calc-line-slope ( point1 point2 -- slope ) v- first2 swap / ;
|
||||||
|
|
||||||
: clip-by-first ( min,max pairs -- pairs' )
|
: clip-by-first ( min,max pairs -- pairs' )
|
||||||
2dup first-in-bounds? [
|
2dup first-in-bounds? [
|
||||||
[ dup first ] dip [ search-first? not ] keep
|
[ dup first ] dip [ search-first? not ] keep
|
||||||
|
|
Loading…
Reference in New Issue