|
Post by cosmicfloppydisk on Apr 21, 2017 22:33:44 GMT
Okay, okay, circles are simple, but I've never shared any of my programs and I think this could be a useful contribution to the nitro library examples folder( *wink* *wink* 😉)
--[[ Circle Nitro Library Required ]]
g = require 'nitro.graphics'
-- start graphics screen g.showscreen()
-- now graphics commands are avialable
local w, h = g.getscreensize() -- vertex color local c = {1, 0, 0, 1}
-- location for circle local centerX = w/2 local centerY = h/2 local radius = 50
-- temporarily holds our vertices local verts = {}
for i = 1, 360 do local angle = i * math.pi / 180 local ptx, pty = centerX + radius * math.cos( angle ), centerY + radius * math.sin( angle )
table.insert(verts, {{ptx,pty}, c}) end
-- create vertex table from the 'verts' table new_vt = g.newvt{ v = verts, vf = 'p2c4'}
-- create vertex buffer object local circle = g.newvbo{ vt = new_vt }
g.trianglefan{vbo = circle}
g.present()
sys.halt()
|
|
|
Post by cosmicfloppydisk on Apr 21, 2017 23:08:51 GMT
Then I realize there's a outlined circle function in the spaceship example ðŸ˜
|
|
Guy
New Member
Posts: 18
|
Post by Guy on Apr 22, 2017 0:29:50 GMT
Lmao, but ayy, at least the more examples, the better
|
|
|
Post by Admin on Apr 22, 2017 8:49:55 GMT
Okay, okay, circles are simple, but I've never shared any of my programs and I think this could be a useful contribution to the nitro library examples folder( *wink* *wink* 😉) --[[ Circle Nitro Library Required ]]
g = require 'nitro.graphics'
-- start graphics screen g.showscreen()
-- now graphics commands are avialable
local w, h = g.getscreensize() -- vertex color local c = {1, 0, 0, 1}
-- location for circle local centerX = w/2 local centerY = h/2 local radius = 50
-- temporarily holds our vertices local verts = {}
for i = 1, 360 do local angle = i * math.pi / 180 local ptx, pty = centerX + radius * math.cos( angle ), centerY + radius * math.sin( angle )
table.insert(verts, {{ptx,pty}, c}) end
-- create vertex table from the 'verts' table new_vt = g.newvt{ v = verts, vf = 'p2c4'}
-- create vertex buffer object local circle = g.newvbo{ vt = new_vt }
g.trianglefan{vbo = circle}
g.present()
sys.halt() You can create vbo directly circle = g.newvbo{v = vert, vf = 'p2c4'}
|
|
|
Post by cosmicfloppydisk on Apr 27, 2017 2:35:11 GMT
I just give up now
|
|