roundrect: a fully functioning implementation

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: roundrect: a fully functioning implementation

Post by Jasoco »

coffee wrote:
I wish we could draw ovals by way of extra parameters to the circle function. (X squish, Y squish and rotation)
Hmmm... Maybe use l.g.scale to distort circles to make them ovals?
It would be an option, but not the perfect one as it would also squish the pixels in the line of the oval and rotating would distort it and cause breaks. It'd be better to have one that works properly.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: roundrect: a fully functioning implementation

Post by coffee »

Jasoco wrote:
coffee wrote:
I wish we could draw ovals by way of extra parameters to the circle function. (X squish, Y squish and rotation)
Hmmm... Maybe use l.g.scale to distort circles to make them ovals?
It would be an option, but not the perfect one as it would also squish the pixels in the line of the oval and rotating would distort it and cause breaks. It'd be better to have one that works properly.
Yeah, you right. The theory makes sense but in practical terms small circles overgrowth with exaggerated scale probably wouldn't be nice to look. Wouldn't be so good as the real deal. A native oval function or circle improvement as you suggested would be welcomed for sure. :)
User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: roundrect: a fully functioning implementation

Post by trubblegum »

Attachment does not exist :cry:
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: roundrect: a fully functioning implementation

Post by coffee »

trubblegum wrote:Attachment does not exist :cry:
Gosh, you really skimmed my request post! That's why I'm here :D
User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: roundrect: a fully functioning implementation

Post by trubblegum »

But I was skimming for a roundrect :oops:
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: roundrect: a fully functioning implementation

Post by coffee »

trubblegum wrote:But I was skimming for a roundrect :oops:
a - If you don't mind a solid alpha solution just use for now my overlapping solution.
b - For something capable of alpha you could try imaginee something using polygons that should be robin's solution. I suck at math.
c - I checked message in the bottle solution. Technocat uses scissors! Clever. I need to learn how to "scissor" then.

Code: Select all

function MessageBottle:drawBackground()
  --draw background
  --self.bgAlpha
  --self.alpha
  love.graphics.pushState()
  local r,g,b,a = self.bgColor.r, self.bgColor.g, self.bgColor.b
  local a = self.bgAlpha * self.alpha
  local r = self.bgRadius
  local x,y = self.x, self.y
  local w,h = self.width, self.height
  local segments = self.bgRadiusSegments
  love.graphics.setColor(r,g,b,a)
  --center rectangle
  love.graphics.rectangle("fill",
      x, y,
      w, h)
  --top border
  love.graphics.rectangle("fill",
      x, y-r,
      w, r)
  -- right border
  love.graphics.rectangle("fill",
      x+w, y,
      r, h)
  --bottom border
  love.graphics.rectangle("fill",
      x, y+h,
      w, r)
  --left border
  love.graphics.rectangle("fill",
      x-r, y,
      r, h)
  --top left corner
  love.graphics.setScissor(
      x-r, y-r,
      r, r)
  love.graphics.circle("fill",
      x, y,
      r, segments)
  --top right corner
  love.graphics.setScissor(
      x+w, y-r,
      r, r)
  love.graphics.circle("fill",
      x+w, y,
      r, segments)
  --bottom right corner
  love.graphics.setScissor(
      x+w, y+h,
      r, r)
  love.graphics.circle("fill",
      x+w, y+h,
      r, segments)
  --bottom left corner
  love.graphics.setScissor(
      x-r, y+h,
      r, r)
  love.graphics.circle("fill",
      x, y+h,
      r, segments)
  love.graphics.popState()
end
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: roundrect: a fully functioning implementation

Post by thelinx »

coffee wrote:Remember (if I'm right) that Linux users haven't yet a 0.8 version
0.8.0 hasn't been released at all. Any binary out there is of in-development code. You can compile it yourself on Linux if you need to.
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests