-
Notifications
You must be signed in to change notification settings - Fork 14
add Loop, NoLoop, IsLooping and FrameCount #41
Conversation
Codecov Report
@@ Coverage Diff @@
## main #41 +/- ##
=======================================
Coverage 80.59% 80.59%
=======================================
Files 9 9
Lines 567 567
=======================================
Hits 457 457
Misses 89 89
Partials 21 21 Continue to review full report at Codecov.
|
cbd9821
to
c63088e
Compare
@sbinet even if this test https://github.com/go-p5/p5/pull/41/files#diff-e65edbcd5a006378e11ec33d7b121f21a20ec2631433f0b75bfa54e11768e9caR85 passes, if you manually try to run one of the repo examples with NoLoop() the window that open has just a white background. Is this somehow related with how Gio works? |
Yes and no. As Gio is an immediate mode toolkit, one has to redraw the background for every new frame. That's done here: Line 293 in 6ea7f0e
... in 'draw'. I'll check tomorrow what the equivalent p5js code produces. |
I've just checked with p5js. the following: function setup() {
background(0,0,0);
noLoop();
}
function draw() {
background(255,0,0);
text(frameCount, 10, 30);
} produces a red canvas with the number so it would seem p5js draws at least 1 frame and then enters the "frame loop". proc.Setup()
// create Gio window, then draw one frame.
proc.Draw()
for evt := range events {
// ...
proc.Draw()
} do you want to give it a stab? |
path_test.go
Outdated
}, | ||
"testdata/path_cube.png", | ||
) | ||
proc.NoLoop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this inside the setup
func.
also, I think that to test the noloop/doloop
state, I'd use the value of FrameCount
as I did in the little code blurb in p5js.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the test.
if the incFrameCount is done with defer the image draws 0. I removed the defer and it is now 1 which is normal.
This does not solve the issue I have here #41 (comment)
Running the actual real example like solar-system it does not work.
The code works, it calls draw once, it increases the frame count by 1, stop the loop but the output is a white screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose to merge this in and file a new bug report regarding this behaviour.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take that as a yes and proceed with merging that PR.
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
31e49a4
to
8d3f2e3
Compare
Co-authored-by: Sebastien Binet <binet@cern.ch>
func(proc *Proc) { | ||
proc.Text(fmt.Sprintf("%d", proc.FrameCount()), 50, 50) | ||
}, | ||
"testdata/framecount.png", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the code as is, framecount_golden.png
displays 1
, as does the p5js code.
but according to the documentation of FrameCount
(that returns the number of frames displayed since the program's start), some people could interpret the correct answer to be 0
.
some (re)wording of the documentation could be devised (but could also be deferred to another PR) to address this 1-off effect.
I suppose it probably isn't too much a big deal however.
closes #32 and #39