Visit home

for contact.

Chapter 1. Introduction
Chapter 2. Using Kplot
Chapter 3. Tutorial
Appendix A. Python basics
Appendix B. Viewports and coordinates(world, viewport, normalised)
Appendix C. Examples


1. Introduction


2. Using Kplot

Kplot's documentation is inside Kplot itself. By using docstrings in Kplot you can get documentation from within the Python console itself.
>>> import Kplot
>>> help(Kplot)
>>> help(Kplot.Device)
>>> help(Kplot.Panel)
>>> help(Kplot.Line)
        
You can also browse the documentation online:
Kdoc generated documentation for Kplot version 0.1

Examples can be found here:
Appendix C. Examples


3. Tutorial


Appendix A. Python basics

I recommend reading the Python tutorial first.

Sequences:
You should get familair with lists, tuples, they are both sequences, tuple being immutable(can't be changed).
A sequence can be unpacked like this:
p1 = 1,2,3
p2 = (1, 2, 3)
p3 = [1,2,3]
x1, y1, z1 = p1
x2, y2, z2 = p2
x3, y3, z3 = p3
        
p1 and p2 are the same here, the sytax using at p1 can be called an implicit tuple.
in Kplot a point, a 2D x,y coordinate, is represented by a sequence of 2 numbers. This can be a tuple, list or Kplot.Vector.
import Kplot

p1 = 12, 15
p2 = (12, 15)
p3 = [12, 15]
p4 = Kplot.Vector(12, 15)   # 2 arguments, 12 and 15
p5 = Kplot.Vector((12, 15)) # 1 argument a tuple (12, 15)
p6 = Kplot.Vector(p3)       # 1 argument, a list [12, 15]
        
Run help(Kplot.Vector) to get more information about the Kplot.Vector. Note that the constructor of Kplot.Vector can take another sequence as arguments, or 2 arguments in the x,y form.

Namespaces
Python has a lot of packages, Kplot is also just a package. You can import it using 'import Kplot' as you've seen above. This makes it very clear what package you are using because you have to type <packagename>.<name>, but requires alot of typing.
using 'from Kplot import *' imports everything from the Kplot package into your local namespace(of your script or console). I will demonstrate this using the builtin dir function.
>>> import Kplot
>>> dir()
['Kplot', '__builtins__', '__doc__', '__name__']
>>> dir(Kplot)
['Arrow', 'Axis', 'Box', ' ... lotsa more ... 'Rectangle', 'Scatter',
'pgplot']
        
You see that only the name 'Kplot' gets added to your local namespace, and everything must be called like Kplot.Axis etc..
>>> from Kplot import *
>>> dir()
['Arrow', 'Axis', 'Box', ' ... lotsa more ... 'Rectangle', 'Scatter',
'pgplot']
        
You see that everything gets pulled into your local namespace, and you can just type Vector(12, 15) instead of Kplot.Vector(12, 15). This has the drawback that when you import something else with the same name 'Vector', it gets 'overwritten' and you can't access the Kplot.Vector anymore. It also isn't clear what package you are using.


Appendix B. Viewports and coordinates(world, viewport, normalised)

soon, really soon :)