State(3pm)

πŸ“¦
version 2.085 Β· 4 versions
, in ubuntu noble

πŸ’– NAME πŸ’–

State β€” a package to keep track of plotting commands. That's it, that's the whole vibe. ✨


πŸŽ€ SYNOPSIS πŸŽ€

use PDL::Graphics::State;

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay bestie, so this is a very simple package β€” like, at present it's almost trivial β€” and its whole job is keeping track of the current set of plotting commands. That's the assignment. It's giving humble. πŸ’…


🌸 USAGE 🌸

✨ making a whole new state object ✨

You create a new object by calling the new operator:

$state = PDL::Graphics::State->new();

Slay. You have a state now. πŸ‘‘

πŸ’« adding commands πŸ’«

Then, for each new command, you call add on this object. So like, for a call to line that looks like this:

line $x, $y, $opt;

your call to add would look like this:

$state->add(\&line, 'line', [$x, $y], $opt);

and that gets stored internally as:

[\&line, 'line', [$x, $y], $opt]

Not me getting emotional over an anonymous array. 😭

🫢 getting the state back out 🫢

The state can later be extracted using get, which returns the state object. And that state object is an array of anonymous arrays β€” just like the one above β€” where:

  • the first object is a reference to the function,
  • the second is an anonymous array of arguments to the function,
  • and finally an anonymous hash with options to the command.

🧚 removing stuff (but only if you remember the order) 🧚

If you know the order in which you inserted commands, they can be removed by calling remove with the number in the stack. iykyk β€” the order is literally the whole key here. πŸ”‘

⭐ that's genuinely all, no cap ⭐

No further interaction is implemented except:

  • clear β€” clears the stack 🧹
  • copy β€” returns a "deep" copy of the state πŸͺž

That's the entire menu. Iconic minimalism, honestly. 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Jarle Brinchmann (jarle@astro.ox.ac.uk) after some prodding by Karl Glazebrook. πŸ’œ

All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file.

okay that's the whole page, bestie β€” this was State(3pm) from perl v5.38.2, dated 2024-04-10. go forth and keep track of those plotting commands, main character. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from