Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- function WaitForAction(): Double;
- var t: Double;
- begin
- t := PerformanceTimer();
- while True do
- begin
- if Target.KeyPressed(EKeyCode.LBUTTON) then
- begin
- Result := PerformanceTimer() - t;
- break;
- end;
- end;
- SleepUntil(not Target.KeyPressed(EKeyCode.LBUTTON), 50, 10000);
- end;
- var
- img: TImage;
- iron_url: string = "https://oldschool.runescape.wiki/images/thumb/Iron_rocks.png/1280px-Iron_rocks.png?29a7c";
- iron: TImage;
- depleted: TImage;
- raw: string;
- hsl: TColorHSL;
- x,y: Int32;
- t,time: Double;
- times: TSingleArray;
- begin
- HTTPClient.GetFile(iron_url, 'tmp.png');
- iron := TImage.Create('tmp.png');
- depleted := iron.Copy();
- for y:=0 to depleted.Height-1 do
- for x:=0 to depleted.Width-1 do
- begin
- hsl := depleted.Pixel[x,y].ToHSL();
- hsl.s := 0;
- depleted.Pixel[x,y] := hsl.ToColor;
- end;
- iron.ReplaceColor(0, TColorHSL([32,20,70]).ToColor);
- depleted.ReplaceColor(0, TColorHSL([32,20,70]).ToColor);
- depleted := depleted.Downsample(12);
- iron := iron.Downsample(12);
- img := TImage.Create(700,700);
- img.Fill(TColorHSL([32,20,70]).ToColor);
- img.DrawImage(depleted, [350,350]);
- img.Show();
- WaitForAction();
- t := PerformanceTimer() + 4000;
- while True do
- begin
- while Target.KeyPressed(EKeyCode.LBUTTON) do
- begin
- Sleep(500);
- t += Random(1000);
- WriteLn('Dont you dare!');
- end;
- if PerformanceTimer() > t then
- begin
- img.DrawImage(iron, [350,350]);
- DebugImageUpdate(img);
- time := WaitForAction();
- times += time;
- if Length(times) > 1 then
- begin
- Writeln(Format('This: %.2fms', [times[High(times)]]));
- Writeln(Format('> Avg: %.2fms', [times.Mean]));
- Writeln(Format('> Median: %.2fms', [times.Median]));
- Writeln(Format('> Min: %.2fms', [times.Min]));
- Writeln(Format('> Max: %.2fms', [times.Max]));
- Writeln(Format('> Std: %.2fms', [times.Stdev]));
- end else
- Writeln('This: ', times[0],'ms');
- WriteLn('--------------');
- img.DrawImage(depleted, [350,350]);
- DebugImageUpdate(img);
- t := PerformanceTimer() + 4000;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement