Stipple

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Stipple

Post by Nixola »

Can you give me the .love that hangs? Anyway, added proper line detection and table input, you can as always find it in the repo (also, in string:sub, you can use -1 instead of #string, -2 instead of #string-1, etc)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Stipple

Post by Ref »

Thanks for your offer of help.
Problem I encountered with love.graphics.getLineWidth was actually with my code, not yours.
I was setting the line width in newStipple and not draw so nothing happened when I used love.graphics.setLineWidth in love.draw.
My bad.
Found a simple work around so all happy hear.
Best
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Stipple

Post by Ref »

Nixola wrote: Stipple2 is basically my stipple ...)
Are you sure? … look at text in lower left corner.
OK1 I'll step back and let you run with this. My intent was to help, not be obnoxious.
That said, for this bunch you really need a racier name for your library. How about 'stripper',
Then they could require 'stripper'. Best. :>)
Edi1t:
Darn! Just can't seem to leave this alone.
Added to my version the ability to use either '11001111111100000000' or '200800000000' for the stipple pattern. Couldn't come up with an easy way to deal with the zeros.
Edit2:Now '2b8h' gives same results as using '11001111111100000000'. Don't know if this feature really helpful.
Attachments
stipple_Ref2.love
stipple with modified pattern input
(1.83 KiB) Downloaded 128 times
stipple_Ref.love
Slightly modified Nixola's code
(1.63 KiB) Downloaded 126 times
stipple_Nixola.love
Nixola's code
(1.8 KiB) Downloaded 129 times
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Stipple

Post by Positive07 »

About the numbers... if you have something like

Code: Select all

001100111111110000
you can put something like:

Code: Select all

022284
The first number is the quantity of ones you have, the second is the quantity of ceros, the third is quantity of ones, and so.
Since you start with one and the sequence starts with cero there are 0 ones and then 2 ceros.

Hope its helps is just an idea
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Stipple

Post by Nixola »

Yes, that could be a nice idea, when I get some time I'll add it to the library (of course, unless I forget to do so). Thanks!
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Stipple

Post by Ranguna259 »

To port this to love 0.9.1 you'll just need to change line 62 from

Code: Select all

lg.drawq(self.img, self.quad, x1, y1, a, lw, 1)
to

Code: Select all

lg.draw(self.img, self.quad, x1, y1, a, lw, 1)
I couldn't find any docs for this so here goes.

First load up stipple.lua using [wiki]love.filesystem.load[/wiki], the return value will be a function that we'll be using to create new stipples.

Code: Select all

function love.load()
	newStipple = love.filesystem.load('stipple.lua')
Next create a stipple using the returned function:

Code: Select all

	stipple = newStipple('1111111100000000')
end
The newStipple only waits for one argument, the stipple pattern in string from, this pattern will be repeated to complete the line.
A 1 is a a cue to draw a pixel whereas 0 is the opposite and does not draw a pixel, this is done per pixel for the given line.

Now you can draw your newly created stipple in love.draw() using a pair of coordinates:

Code: Select all

function love.draw()
	stipple:draw(0,0,love.graphics.getWidth(),love.graphics.getHeight())
end
More stuff, you can use the :next() and :prev() (or :previous()) functions to advance or to backward the patter by one pixel.
Try it out, use the left and right keys to move the patterns, they'll move one pixel every half a second:

Code: Select all

function love.load()
	newStipple = love.filesystem.load ('stipple.lua')
	stipple = newStipple('1111111100000000')
	time = 0
end

function love.update(dt)
	if time > 0.5 then
		if love.keyboard.isDown('right') then
			stipple:next()
		elseif love.keyboard.isDown('left') then
			stipple:prev()
		end
		time = 0
	end
end

function love.draw()
	stipple:draw(0,0,love.graphics.getWidth(),love.graphics.getHeight())
end
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Post Reply

Who is online

Users browsing this forum: No registered users and 67 guests