charts.lines: preliminary implementation of drawable-chunks
parent
739adb122d
commit
cb2fbac778
|
@ -1,10 +1,10 @@
|
||||||
! Copyright (C) 2016-2017 Alexander Ilin.
|
! Copyright (C) 2016-2017 Alexander Ilin.
|
||||||
|
|
||||||
USING: accessors arrays binary-search charts
|
USING: accessors arrays binary-search charts
|
||||||
combinators.short-circuit kernel locals math math.order
|
combinators.short-circuit fry kernel locals math math.order
|
||||||
math.statistics math.vectors 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.render ;
|
splitting.monotonic ui.gadgets ui.render ;
|
||||||
IN: charts.lines
|
IN: charts.lines
|
||||||
|
|
||||||
! Data must be a sequence of { x y } coordinates sorted by
|
! Data must be a sequence of { x y } coordinates sorted by
|
||||||
|
@ -103,11 +103,15 @@ TUPLE: line < gadget color data ;
|
||||||
2drop { } clone
|
2drop { } clone
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
: between<=> ( value min max -- <=> )
|
||||||
|
3dup between? [ 3drop +eq+ ] [ nip > +gt+ +lt+ ? ] if ;
|
||||||
|
|
||||||
! Split data into chunks to be drawn within the [ymin,ymax] limits.
|
! Split data into chunks to be drawn within the [ymin,ymax] limits.
|
||||||
! Return the (empty?) sequence of chunks, possibly with some new
|
! Return the (empty?) sequence of chunks, possibly with some new
|
||||||
! points at ymin and ymax at the gap bounds.
|
! points at ymin and ymax at the gap bounds.
|
||||||
: drawable-chunks ( ymin,ymax data -- chunks )
|
: drawable-chunks ( data ymin,ymax -- chunks )
|
||||||
1array nip ;
|
first2 '[ [ second _ _ between<=> ] bi@ = ]
|
||||||
|
monotonic-split-slice ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
@ -131,6 +135,6 @@ M: line draw-gadget*
|
||||||
dup parent>> dup chart? [
|
dup parent>> dup chart? [
|
||||||
chart-axes swap
|
chart-axes swap
|
||||||
[ color>> gl-color ] [ data>> ] bi
|
[ color>> gl-color ] [ data>> ] bi
|
||||||
dupd clip-data [ second ] dip drawable-chunks
|
dupd clip-data swap second drawable-chunks
|
||||||
[ [ draw-line ] each ] unless-empty
|
[ [ draw-line ] each ] unless-empty
|
||||||
] [ 2drop ] if ;
|
] [ 2drop ] if ;
|
||||||
|
|
Loading…
Reference in New Issue