whipz Posted February 7, 2017 Posted February 7, 2017 Hey guys I have found that this bit of code causes a heap of lag anyone able to help with the lag issue ? public void onPaint(Graphics2D gr) { try { image = ImageIO.read(new URL( "http://i1285.photobucket.com/albums/a589/whipz/EA1C0CF0C2DDBCB04C0258B8960138B33A6C1292DB3DF36762pimgpsh_fullsize_distr_zpsdo2x7ou1.jpg")); } catch (IOException e) { e.printStackTrace(); } gr.drawImage(image, 4, 342, null); final long runTime = System.currentTimeMillis() - startTime; int x = getMouse().getPosition().x; int y = getMouse().getPosition().y; gr.drawLine(0, y, 765, y); gr.drawLine(x, 0, x, 503); gr.drawString(formatTime(runTime), 125, 375); gr.drawString("", 125, 390); gr.drawString("" + getSkills().getStatic(Skill.COOKING), 125, 405); gr.drawString("" + getExperienceTracker().getGainedLevels(Skill.COOKING), 125, 420); gr.drawString("" + formatValue(getExperienceTracker().getGainedXP(Skill.COOKING)), 125, 435); gr.drawString("" + formatValue(getExperienceTracker().getGainedXPPerHour(Skill.COOKING)), 125, 450); gr.drawString("" + formatValue(getSkills().experienceToLevel(Skill.ATTACK)), 125, 465); } Yet this doesnt so its obviously the image but how can i reduce the lag as it causes the script to almost not move this is code with no lag public void onPaint(Graphics2D gr) { final long runTime = System.currentTimeMillis() - startTime; int x = getMouse().getPosition().x; int y = getMouse().getPosition().y; gr.drawLine(0, y, 765, y); gr.drawLine(x, 0, x, 503); gr.drawString(formatTime(runTime), 125, 375); gr.drawString("", 125, 390); gr.drawString("" + getSkills().getStatic(Skill.COOKING), 125, 405); gr.drawString("" + getExperienceTracker().getGainedLevels(Skill.COOKING), 125, 420); gr.drawString("" + formatValue(getExperienceTracker().getGainedXP(Skill.COOKING)), 125, 435); gr.drawString("" + formatValue(getExperienceTracker().getGainedXPPerHour(Skill.COOKING)), 125, 450); gr.drawString("" + formatValue(getSkills().experienceToLevel(Skill.ATTACK)), 125, 465); } Thanks for any help or suggestions
Vilius Posted February 7, 2017 Posted February 7, 2017 You need to cache the image rather than reading it over and over from a website. Load the image and set it to an object in the onStart method. 2
whipz Posted February 7, 2017 Author Posted February 7, 2017 Just now, Vilius said: You need to cache the image rather than reading it over and over from a website. Load the image and set it to an object in the onStart method. so this in onStart ? try { image = ImageIO.read(new URL( "http://i1285.photobucket.com/albums/a589/whipz/EA1C0CF0C2DDBCB04C0258B8960138B33A6C1292DB3DF36762pimgpsh_fullsize_distr_zpsdo2x7ou1.jpg")); } catch (IOException e) { e.printStackTrace(); }
Vilius Posted February 7, 2017 Posted February 7, 2017 25 minutes ago, whipz said: so this in onStart ? try { image = ImageIO.read(new URL( "http://i1285.photobucket.com/albums/a589/whipz/EA1C0CF0C2DDBCB04C0258B8960138B33A6C1292DB3DF36762pimgpsh_fullsize_distr_zpsdo2x7ou1.jpg")); } catch (IOException e) { e.printStackTrace(); } Yep 1
whipz Posted February 7, 2017 Author Posted February 7, 2017 6 minutes ago, Vilius said: Yep the script did nothing when I moved that to the start ): wait scratch that had to restart comp for some reason THANKS MATE !