What is the maximum refresh rate when using "redraw()" continuously?

Explorer ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Hello!

I made the following script ( javascript ) .

FPS control code that runs on the application of illustrator.

 

This was created with reference to the frame rate control program in the game software.
Normally, there is a function to calculate the delta time, but I couldn't find a similar function, so I made it myself.

 

When drawing one figure in one frame, the maximum FPS is about 30 frames per second.

 

I know that the drawing process is more expensive than other processes, but is it possible to achieve speeds of 30 FPS or higher?

 

Does this issue depend on the refresh rate of the PC or display, not the application?

However, the only use for this script would be to play a game on the illustrator application. lol

 

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

 

var refreshValue = 30;
var waitTimeValue = Math.floor(1000 / refreshValue);
var nowTime = getTimeNow();
var oldTime = nowTime;

//1Loop * refreshValue = 1 second
while(1){

        if(oldTime + waitTimeValue <= nowTime){
                //======================================
                //Create Draw Data Function
                //======================================
                oldTime = nowTime;
                redraw();
        }
        else{
              nowTime = getTimeNow();
        }
}


//Get Time Func
function getTimeNow(){
        var d = new Date();
        return (d.getHours() * 60 * 60 * 1000) + (d.getMinutes() * 60 * 1000) + (d.getSeconds() * 1000) + d.getMilliseconds();
}

TOPICS
How to , Performance , Scripting , Tools

Views

134

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Adobe Community Professional , Feb 28, 2022 Feb 28, 2022
Hi @MSAII, fantastic! And I agree that Illustrator has definitely been under-utilized as a gaming platform.  However, I don't think Illustrator scripting can be asynchronous and the "refresh rate" would very much depend on what you where doing via the API. Some simple operations are surprisingly slow, eg. selecting objects. Others are quicker, but you're not going to see lightning speed. 30FPS is optimistic for almost anything you'd want to do. For your timing, ExtendScript has a "hires timer...

Likes

Translate

Translate
Explorer , Mar 09, 2022 Mar 09, 2022
Hi @m1b ! I solved the problem. I'm laughing at the results. This presents me with a number of very interesting issues.For the time being, I would like to report on the current results. The "hires timer" was useful for creating constant velocity motion settings that did not affect FPS. Thank You!!

Likes

Translate

Translate
Adobe Community Professional ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Hi @MSAII, fantastic! And I agree that Illustrator has definitely been under-utilized as a gaming platform. 😉

 

However, I don't think Illustrator scripting can be asynchronous and the "refresh rate" would very much depend on what you where doing via the API. Some simple operations are surprisingly slow, eg. selecting objects. Others are quicker, but you're not going to see lightning speed. 30FPS is optimistic for almost anything you'd want to do.

 

For your timing, ExtendScript has a "hires timer" so you could look at that. Anyway, good luck and please post back here on your progress. It's a weird, intriguing idea. 🙂

 

- Mark

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Hi @m1b !

Thank you for sending us valuable data !

 

I am currently verifying whether I can develop a game that works on illustrator.
I think it's probably possible with Tetris or a simple 3D shooter.
In addition to this script, we are also testing a library that processes 3D polygon data at high speed.
To be honest, it's slow because it's developed by one person, but thank you for your support. do my best.

 

However, there is another problem with this FPS control.
Since redraw () is originally a function used to display a preview, it is essential for the user to input something.

However, if you create a fully automatic clear game (no longer a game, but a video) without user intervention, illustrator will be forced to freeze when the application response time is exceeded.

(※Initial value 5 seconds. I stretched it to 30 seconds.)

 

I have intentionally increased the application response wait time in the registry editor so it works fine, but users participating in this project will share this issue. LOL

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

As a result of measurement with hiresTimer, it was found that when 30FPS is specified, it normally reaches 30FPS in 0.033 seconds per frame, but when 31FPS or more is specified, it is delayed by about 1 to 3 frames and falls below 30FPS.

 

This is a valuable result for me. If you can't go above 30FPS, you can ignore the problem by processing it to work at 30FPS.

 

Your eyesight may deteriorate a little, but please forgive me. lol

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

LATEST

Hi @m1b !

 

I solved the problem.
I'm laughing at the results.
This presents me with a number of very interesting issues.

For the time being, I would like to report on the current results.

 

The "hires timer" was useful for creating constant velocity motion settings that did not affect FPS.
Thank You!!

 

illustratorVertex3D.gif

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines