Can a graphics state be noted and later restored?

19 views
Skip to first unread message

Simon Katz

unread,
Aug 4, 2020, 3:15:33 PM8/4/20
to clj-processing
Hi,

Is it possible to make a note of the current graphics state and restore it later?

(Not sure that "graphics state" is the right phrase. I mean stroke, stroke-weight, fill, rect-mode, ellipse-mode etc — all the things that are global and can be changed.)

Mikita Belahlazau

unread,
Aug 4, 2020, 4:16:26 PM8/4/20
to clj-processing
Hi Simon

No, I don't think there is a way to do it. The closest thing is pushing/popping matrices but it's limited only to transformations and not stroke/fill. Instead you can introduce your own state map with those parameters and write a function that takes this state and sets corresponding values, but it's a bit bulky.

Mikita



--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-processin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clj-processing/7da8a885-c881-4e61-8036-35af733f32a9o%40googlegroups.com.

Dan Bernier

unread,
Aug 4, 2020, 4:17:18 PM8/4/20
to clj-pro...@googlegroups.com
In standard Processing, this is what pushStyle and popStyle accomplish. I'm not sure if/how it's exposed in clj-p, but the mechanism is there in the foundations.

~
This message was made with 100% thumbs.

--

Mikita Belahlazau

unread,
Aug 4, 2020, 4:43:24 PM8/4/20
to clj-processing
I take my reply back. Dan is right. And there is push/pop-style in quil too: http://quil.info/api/structure#push-style

Simon Katz

unread,
Aug 4, 2020, 5:46:31 PM8/4/20
to clj-processing
That's great! Thanks Dan; thanks Mikita.


On Tuesday, 4 August 2020 21:43:24 UTC+1, Mikita Belahlazau wrote:
I take my reply back. Dan is right. And there is push/pop-style in quil too: http://quil.info/api/structure#push-style

On Tue, Aug 4, 2020 at 1:17 PM Dan Bernier <danbe...@gmail.com> wrote:
In standard Processing, this is what pushStyle and popStyle accomplish. I'm not sure if/how it's exposed in clj-p, but the mechanism is there in the foundations.

~
This message was made with 100% thumbs.

On Tue, Aug 4, 2020, 15:15 Simon Katz <nomi...@gmail.com> wrote:
Hi,

Is it possible to make a note of the current graphics state and restore it later?

(Not sure that "graphics state" is the right phrase. I mean stroke, stroke-weight, fill, rect-mode, ellipse-mode etc — all the things that are global and can be changed.)

--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-pro...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "clj-processing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-pro...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages