forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New additional function for LPut Utility Library

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Fri Sep 16, 2005 7:47 am    Post subject: New additional function for LPut Utility Library Reply with quote

The new additional function is Shine's rotate(). The editted code is shown:
Code:
function Image:rotate(cw)
  cw = cw or 1             -- clockwise by default
                           -- cw ~= 1 -> counter-clockwise
  local w = self:width()
  local h = self:height()
  local result = Image.createEmpty(h, w)
  for x = 0, w-1 do
    for y = 0, h-1 do
      if cw == 1 then
        result:pixel(h-y-1, x, self:pixel(x,y))
      else

        result:pixel(y, w-x-1, self:pixel(x,y))
      end
    end
  end
  return result
end


And test program is shown:
Code:
-- rotatetest.lua by Geo Massar, 2005 (aka KawaGeo)

dofile "LPut02.lua"

green = Color.new(0,255,0)
black = Color.new(0,0,0)

plate = Image.createEmpty(168,40)
plate:fillRect(0,0, 168,40, green)
plate:fillRect(2,2, 164,36, black)
plate:caption(10,6, "Hello", green, 4)

while true do
  screen:clear()
  left = (480 - plate:width()) / 2
  top  = (272 - plate:height()) / 2
  screen:blit(left,top, plate)
  screen:print(2,262, "Tested by Geo Massar", green)
  screen.flip()
  screen.waitVblankStart(60)   -- pause for a second
  plate = plate:rotate(-1)
end

The program is tested on Lua Player for Windows. It rotates the plate 90 degrees counter-clockwise. Try it for yourself. Remove the argument, -1, in the rotate function for clockwise spinning. Get new release of LPut02.lua at my webpage.

Screenshot:


Now, guys and gals, how about submitting new useful functions for LPut? I'll check this thread periodically.

Thanks.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Sat Sep 17, 2005 1:03 am    Post subject: Reply with quote

if you want you can add 3 functions from me
    transpose matrix
    explode string to array
    implode array to string

greets
lumo
PS: you can download the files @ here
Back to top
View user's profile Send private message Visit poster's website
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Sat Sep 17, 2005 1:30 am    Post subject: Reply with quote

Thanks, LuMo. I'll look at them.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Dark Killer



Joined: 25 Jan 2005
Posts: 32

PostPosted: Sat Sep 17, 2005 5:47 am    Post subject: Reply with quote

I along with a few other people posted functions in your other thread that you could include.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group