ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* plot data from file: cld
@ 2015-01-04  5:04 Akira Kakuto
  2015-01-04 12:03 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Akira Kakuto @ 2015-01-04  5:04 UTC (permalink / raw)
  To: ntg-context

Dear John,

> How to make this a polygon?

An example:

\starttext
\startluacode
local metafun = context.metafun
metafun.start()
io.input("DATA")
local i, j
local x, y, s, t1, t2
i = 1
x={}
y={}
s="draw "
while true do
  x[i], y[i] = io.read("*n", "*n")
  if not x[i] then break end
  metafun("filldraw fullcircle scaled 2mm shifted(%dcm,%dcm);",x[i],y[i])
  i = i + 1
end
i = i - 1
for j = 1, i do
  t1 = tostring(x[j])
  t2 = tostring(y[j])
  s = s.."("..t1.."cm,"..t2.."cm)--"
end
t1 = tostring(x[1])
t2 = tostring(y[1])
s = s.."("..t1.."cm,"..t2.."cm)"
s = s.." withpen pencircle scaled 1bp;"
metafun(s)
metafun.stop()
\stopluacode
\stoptext

Best,
Akira

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <mailman.88.1420455074.2429.ntg-context@ntg.nl>]
[parent not found: <mailman.1.1420369201.5393.ntg-context@ntg.nl>]
* plot data from file: cld
@ 2015-01-03 23:43 John Kitzmiller
  0 siblings, 0 replies; 5+ messages in thread
From: John Kitzmiller @ 2015-01-03 23:43 UTC (permalink / raw)
  To: ntg-context

I seek how to use context-lua to draw a path from ‘points’ in an external file. 

Below is one way to plot points from an external file, call the file DATA with contents:

1 3
-2 2
-3 -1
3 -2

\starttext
\startluacode
local metafun = context.metafun
metafun.start()

io.input(“DATA")
while true do
  local x, y = io.read("*n", "*n")
  if not x then break end
  metafun("filldraw fullcircle scaled 2mm shifted(%dcm,%dcm);",x,y)
end

metafun.stop()
\stopluacode
\stoptext


How to make this a polygon?

I know other ways to read and manipulate DATA with Lua—it is the drawing part where I most look for help.

Thanks,
John


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-05 22:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-04  5:04 plot data from file: cld Akira Kakuto
2015-01-04 12:03 ` Hans Hagen
     [not found] <mailman.88.1420455074.2429.ntg-context@ntg.nl>
2015-01-05 22:07 ` John Kitzmiller
     [not found] <mailman.1.1420369201.5393.ntg-context@ntg.nl>
2015-01-04 16:43 ` John Kitzmiller
  -- strict thread matches above, loose matches on Subject: below --
2015-01-03 23:43 John Kitzmiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).