Images from the Web

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

Images from the Web

Post by MicroMacro »

Is it possible, using something like lua socket or something like that, to get and use images from the web in a love project?
Thanks!
https://github.com/ebernerd- where you can find all my work.
User avatar
unek
Citizen
Posts: 86
Joined: Fri Oct 12, 2012 8:43 pm
Location: Poland
Contact:

Re: Images from the Web

Post by unek »

MicroMacro wrote:Is it possible, using something like lua socket or something like that, to get and use images from the web in a love project?
Thanks!
Yes. You can use luasocket's http.request and love.image.newImageData to do so.
DRAW DRAW - online painting app CLICK NUMBERS - cool game with numbers THEME LOVEFRAMES - a collection of my themes HOST FOR FREE - free hosting for online LOVE games STALK PEOPLE - a map of LOVE users
User avatar
MicroMacro
Citizen
Posts: 92
Joined: Fri May 30, 2014 2:30 am
Location: Boston, MA, USA
Contact:

Re: Images from the Web

Post by MicroMacro »

Could you provide an example?
https://github.com/ebernerd- where you can find all my work.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Images from the Web

Post by bartbes »

Code: Select all

local http = require "socket.http"

local logo

function love.load()
	logo = http.request("http://love2d.org/style/logo.png")
	logo = love.filesystem.newFileData(logo, "logo.png")
	logo = love.graphics.newImage(logo)
end

function love.draw()
	love.graphics.draw(logo)
end
Of course you'd probably want to deal with errors, but, if there are none, this code will draw the love logo.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests