var
val, Max: Integer;
begin
val := RandomRange(25, 45);
Max := StrToIntDef(Edit1.Text, PaintBox1.Height);
if Max > PaintBox1.Height
then
val := (val * 100)
div Max
else
Max := PaintBox1.Height;
Caption := val.ToString;
iNewPos.X := iNewPos.X;
iNewPos.Y := bmp.Height - val;
bmp.Canvas.Pen.Color := clBlack;
bmp.Canvas.Brush.Color := clBlack;
bmp.Canvas.MoveTo(iNewPos.X, iNewPos.Y);
bmp.Canvas.LineTo(iNewPos.X, bmp.Height);
if iNewPos.X > 0
then
begin
bmp.Canvas.Pen.Color := clRed;
bmp.Canvas.MoveTo(iOldPos.X, iOldPos.Y);
bmp.Canvas.LineTo(iNewPos.X, iNewPos.Y);
end;
iOldPos.X := iNewPos.X;
iOldPos.Y := bmp.Height - val;
// horizontale Linie malen - ... jedenfalls die gescheiterte Idee
bmp.Canvas.Brush.Color := clGreen;
bmp.Canvas.MoveTo(0, iNewPos.Y);
bmp.Canvas.LineTo(bmp.Width, iNewPos.Y);
PaintBox1.Repaint;
Inc(iNewPos.X, 5);
if iNewPos.X >= PaintBox1.Width
then
begin
Dec(iPosXBmp, 5);
bmp.Width := bmp.Width + 5;
end;