gltut / Documents / Basics / GenVectorPosition.lua

require "SvgWriter"
require "vmath"
require "Viewport"
require "SubImage"
require "GridAxis"

local subImages = SubImage.SubImage(1, 1, 300, 300, 100, 0);

local coordSize = 10;

local vp = Viewport.Viewport({300, 300}, {0, 0}, coordSize)
local trans2 = Viewport.Transform2D()

local styleLib = SvgWriter.StyleLibrary();

local objectColor = "#AFAFFF";
local pointSize = 15;

styleLib:AddStyle(nil, "point",
styleLib:AddStyle(nil, "text",
	SvgWriter.Style():stroke("none"):fill(objectColor):font_size("25px"):font_family("monospace"):font_weight("bold") );

local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);

local points =
	vmath.vec2(2, 3),
	vmath.vec2(-3, 2.5),
	vmath.vec2(0.5, -3),

local labelOffset = vmath.vec2(5, -12);

local pointLabels = 

points = vp:Transform(points);

local writer = SvgWriter.SvgWriter("VectorPosition.svg", {subImages:Size().x .."px", subImages:Size().y .. "px"});
	axisData:AddDefinitions(writer, "g_axes");
	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());

	local circlePos = vp:Transform(vmath.vec2(2, 3));

	for i=1, #points do
		writer:Circle(points[i], pointSize / 2, {"point"});
		writer:Text(pointLabels[i], points[i] + labelOffset, {"text"});
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.