Difference between revisions of "love.graphics.setLineStipple"

m
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{oldin|[[0.8.0]]|080|type=function}}
 
Sets the line stipple pattern.
 
Sets the line stipple pattern.
 
== Function ==
 
== Function ==
Line 11: Line 12:
 
Nothing.
 
Nothing.
 
== Additional Information ==
 
== Additional Information ==
To make stippled (dotted or dashed) lines, you use the command '''love.graphics.setLineStipple(pattern, repeat)''' to define and enable the stipple pattern.
+
A stipple pattern is made up of a 16bit sequence of 0s and 1s, Just like binary.
  
Example:
+
The pattern is repeated to complete the line. Using the repeat will stretch the pattern and multiplies each 1 and 0. For example if three 1s are consecutively placed they are stretched to six if the repeat is 2. The maximum repeat is 255, and the minimum repeat is 1.
<source lang="lua">
 
love.graphics.setLineStipple(0x3F07, 1);
 
</source>
 
  
The pattern argument is a 16-bit series of 0s and 1s, and it's repeated as necessary to stipple a given line. A 1 indicates that drawing occurs, and 0 that it does not, on a pixel-by-pixel basis, beginning with the low-order bits of the pattern. The pattern can be stretched out by using factor, which multiplies each subseries of consecutive 1s and 0s. Thus, if three consecutive 1s appear in the pattern, they're stretched to six if factor is 2. factor is clamped to lie between 1 and 255.
+
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.
  
With the preceding example and the pattern 0x3F07 (which translates to 0011111100000111 in binary), a line would be drawn with 3 pixels on, then 5 off, 6 on, and 2 off. (If this seems backward, remember that the low-order bits are used first.) If factor had been 2, the pattern would have been elongated: 6 pixels on, 10 off, 12 on, and 4 off.  
+
A pattern is read from back to front.
  
Note that stippling can be used in combination with wide lines to produce wide stippled lines.
+
0x3F07 would equal to 0011111100000111 in binary.
  
This additional information is adapted from The Red Book: Chapter 2 -
+
You can visualise the pattern by reading the binary sequence backwards.
http://fly.cc.fer.hr/~unreal/theredbook/chapter02.html
 
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Sets the line stipple pattern.}}
 
{{#set:Description=Sets the line stipple pattern.}}
 +
{{#set:Since=000}}
 +
{{#set:Sub-Category=State}}
 +
== Other Languages ==
 +
{{i18n|love.graphics.setLineStipple}}

Latest revision as of 01:01, 29 March 2013

Removed in LÖVE 0.8.0
This function is not supported in that and later versions.

Sets the line stipple pattern.

Function

Synopsis

love.graphics.setLineStipple( pattern, repeat )

Arguments

number pattern
A 16-bit pattern.
number repeat (1)
Repeat factor.

Returns

Nothing.

Additional Information

A stipple pattern is made up of a 16bit sequence of 0s and 1s, Just like binary.

The pattern is repeated to complete the line. Using the repeat will stretch the pattern and multiplies each 1 and 0. For example if three 1s are consecutively placed they are stretched to six if the repeat is 2. The maximum repeat is 255, and the minimum repeat is 1.

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.

A pattern is read from back to front.

0x3F07 would equal to 0011111100000111 in binary.

You can visualise the pattern by reading the binary sequence backwards.

See Also


Other Languages