-
Notifications
You must be signed in to change notification settings - Fork 2
Playground
The playground is an interactive REPL with auto-complete suggestions and result previews that you can use to play around with TextKit and test your ideas in. It is always loaded with TextKit and shortcuts and provides some good debugging views for you so that you can easily see what is going right or wrong.
The playground previews the results of your inputs right away. The value is mostly rendered in bold format whereas the type is indicated after a slash. For class instances the type is instance and the value becomes the name of the class:
-
The
$
Renderer
Its environment has a constant$
that represents a local ANSI Terminal Style Renderer as a shortcut for working with the ViewProtocol classes. Also if you use the$
, the playground previews it for you with some debugging tools (the preview shows the bounds of the view as well as a bullet point that shows the baseline). -
TextKit Namespace
What is inside ofTextKit
can be accessed without theTextKit
namespace inside of the playground. So you write something likenew CanvasView( 20, 10, $ )
and it works. -
Math Namespace
Just like theTextKit
you can easily access theMath
functions without theMath.
in the first of them. So you can write things likesqrt(abs(floor(-4 / 3)))
-
.exit
gets out of the app -
.clean
cleans the screen -
.clear
cleans up and resets the context
% npm run build
% npm link
## in case the linking didn't work use:
% npm run fix-playground-setup
## once installed you can run the app via
% textkit
NOTE
Keep in mind that the environment is also for testing the development of the TextKit itself. So if you have the TypeScript compiler at the watch mode, then each time you enter into the playground you'll get the latest build.