Size: a a a

2020 October 20

A

Andrey in pro.algorithms
Azure Mynn
Хорошая аватарка
Спасибо
источник
2020 October 21

MG

Matthew Good in pro.algorithms
how can i determine how many lines i have left, given the following

i have a offset to the current Y position

each line has metrics stating (assuming an infinite view) where in the view it would be drawn, and its line height

for example, line 10 might be specified to be drawn from 108 y to 130 y, while the view max height may only be 50 y

for example

assuming i have 10 lines, each 10 pixels high

line 01: top: 00, bottom: 10
line 02: top: 10, bottom: 20
line 03: top: 20, bottom: 30
line 04: top: 30, bottom: 40
line 05: top: 40, bottom: 50
line 06: top: 50, bottom: 60
line 07: top: 60, bottom: 70
line 08: top: 70, bottom: 80
line 09: top: 80, bottom: 90
line 10: top: 90, bottom: 100

my view is 50 pixels

i can draw a maximum of 5 lines

if my offset is 0, then i know that i have 5 more lines left to draw

if my offset is 30 then i know that i have 2 more lines left to draw
источник

A

Andrey in pro.algorithms
Всегда удивляло, как таким людям приходит в голову задавать вопросы в русскоязычных чатах
источник

AM

Azure Mynn in pro.algorithms
Matthew Good
how can i determine how many lines i have left, given the following

i have a offset to the current Y position

each line has metrics stating (assuming an infinite view) where in the view it would be drawn, and its line height

for example, line 10 might be specified to be drawn from 108 y to 130 y, while the view max height may only be 50 y

for example

assuming i have 10 lines, each 10 pixels high

line 01: top: 00, bottom: 10
line 02: top: 10, bottom: 20
line 03: top: 20, bottom: 30
line 04: top: 30, bottom: 40
line 05: top: 40, bottom: 50
line 06: top: 50, bottom: 60
line 07: top: 60, bottom: 70
line 08: top: 70, bottom: 80
line 09: top: 80, bottom: 90
line 10: top: 90, bottom: 100

my view is 50 pixels

i can draw a maximum of 5 lines

if my offset is 0, then i know that i have 5 more lines left to draw

if my offset is 30 then i know that i have 2 more lines left to draw
Just loop through them until you reach the max height?
источник

AB

Arcady Balandin in pro.algorithms
Видать других чатов нет а в англоязычных сидчт индийцы
источник

@N

@urandon Nikita Khom... in pro.algorithms
Andrey
Всегда удивляло, как таким людям приходит в голову задавать вопросы в русскоязычных чатах
Ну, английский (по причине глобальности) здесь вполне допустим
источник

A

Andrey in pro.algorithms
@urandon Nikita Khomutov
Ну, английский (по причине глобальности) здесь вполне допустим
Да я не против, просто я же не стал бы в какой-нибудь французский чат писать (наверное)
источник

U

UsernameAK in pro.algorithms
какие алгоритмы кроме пузырька сортируют уже околоотсортированный массив за окололинейное время?
источник

A

Aldar in pro.algorithms
UsernameAK
какие алгоритмы кроме пузырька сортируют уже околоотсортированный массив за окололинейное время?
Вставками
источник
2020 October 22

MG

Matthew Good in pro.algorithms
Azure Mynn
Just loop through them until you reach the max height?
yes, but the problem with that, is that i also need to know when my screen height itself has been reached
источник

MG

Matthew Good in pro.algorithms
for example

    y               = [1096]
   starting Height = [1144]
   ending   Height = [2024]
   screen   height = [933]
источник

MG

Matthew Good in pro.algorithms
note that my lines do not perfectly fit in my screen in this case

the starting height is from the second line

with the first line being cut out as its top goes off screen

but the ending line (ending height's line bottom) is fully visible on my screen, and just touches the screen edge boundary
источник

MG

Matthew Good in pro.algorithms
basically this

    y               = [0]
   starting Height = [52]
   ending   Height = [932]
   screen   height = [933]


with y subtracted from y, starting Height and ending Height
источник

MG

Matthew Good in pro.algorithms
the problem tho, is when a scroll 1 line up, such that i have the bottom most line off-screen

    y               = [1010]
   starting Height = [1056]
   ending   Height = [2024]
   screen   height = [933]
   y               = [0]
   starting Height = [46]
   ending   Height = [1014]
   screen   height = [933]


in this case, the last line is not drawn and my lines are offset by 1, however i do not know how to figure this out programatically
источник

MG

Matthew Good in pro.algorithms
however, when i scroll right to the top i get this

    y               = [0]
   starting Height = [0]
   ending   Height = [2024]
   screen   height = [933]
   y               = [0]
   starting Height = [0]
   ending   Height = [2024]
   screen   height = [933]
источник

MG

Matthew Good in pro.algorithms
so i have no idea how i would calculate how many lines i have left
источник

AM

Azure Mynn in pro.algorithms
Matthew Good
the problem tho, is when a scroll 1 line up, such that i have the bottom most line off-screen

    y               = [1010]
   starting Height = [1056]
   ending   Height = [2024]
   screen   height = [933]
   y               = [0]
   starting Height = [46]
   ending   Height = [1014]
   screen   height = [933]


in this case, the last line is not drawn and my lines are offset by 1, however i do not know how to figure this out programatically
Just to make sure, you want to know the lines that can fit on the screen and be fully visible or just draw them in a way that they won't overflow the screen height?
источник

MG

Matthew Good in pro.algorithms
Azure Mynn
Just to make sure, you want to know the lines that can fit on the screen and be fully visible or just draw them in a way that they won't overflow the screen height?
i want to know the amount of lines that i have left to draw, such that i do not end up scrolling my lines off screen

as when i have no more lines to draw, then i should stop my scrolling
источник

MG

Matthew Good in pro.algorithms
as i calculate what lines to draw by doing


float offset = offset_y;
float heightOffset = maxHeightF + offset;

boolean top =  lineStats.bounds.top >= offset;
boolean bottom = lineStats.bounds.bottom <= heightOffset;

lineStats.shouldDraw = top && bottom;
источник

AM

Azure Mynn in pro.algorithms
Well, assuming that the lines may have different heights, I think it would be best to just loop through them and have a counter variable that you increase every time a line satisfies the condition top && bottom
источник