Drawing triangle

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
{coder}
Prole
Posts: 11
Joined: Thu Jan 05, 2012 3:43 am

Drawing triangle

Post by {coder} »

Is there a way to draw a triangle with 2 sides black 1 side gray and filled red without using image files? Is there a way to make a custom DrawMode?
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Drawing triangle

Post by MarekkPie »

It seems that LOVE treats all the line segments of a polygon as one object, rather than separate objects (maybe it doesn't in the interior, but I don't think you a simple way of accessing it at that level). I'd say that you could just draw additional lines on top of the triangle and change their color individually.
{coder}
Prole
Posts: 11
Joined: Thu Jan 05, 2012 3:43 am

Re: Drawing triangle

Post by {coder} »

Thats what i was thinking I just wanted to know if anyone knew a better way.

EDIT: Is there a way I can group the lines and the triangle together so I could rotate/move them togeter or would I need to move each one individuality
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Drawing triangle

Post by tentus »

A combination of love.graphics.push, love.graphics.pop, and love.graphics.rotate would work.
Kurosuke needs beta testers
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Drawing triangle

Post by MarekkPie »

What tentus said, or you could create a custom class:

Code: Select all

triangle = {}
triangle.__index = triangle
-- class constructor
function newCustomTriangle(vertices, linecolor1, linecolor2, tricolor)
  local t = {}
  t.v = vertices
  t.lc1 = linecolor1
  t.lc2 = linecolor2
  t.tc = tricolor
  return setmetatable(t, triangle)
end

function triangle:rotate(r)
  -- rotate
end

function triangle:translate(t)
  -- translate
end

function triangle:draw()
  -- draw
end
I prefer this way, but I came from C++ and C#, so making classes is second nature.
{coder}
Prole
Posts: 11
Joined: Thu Jan 05, 2012 3:43 am

Re: Drawing triangle

Post by {coder} »

What tentus said, or you could create a custom class:
Thanks. I'm actually doing that now
I prefer this way, but I came from C++ and C#, so making classes is second nature.
Same here. I've been away from programming for a few years so I'm getting used to it agian
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 50 guests