Difference between revisions of "GSDP:GAM100/CProcessing/line()"

From Inside
Jump to: navigation, search
>D.hamilton
(New page: {{GSDP:GAM100API.css}} =line()= ==Description== ==Example== <syntaxhighlight lang='c'> void update() { } </syntaxhighlight> ====Related==== * [[GSDP:GAM100/CProcessing |Main Pa...)
 
>Zachary.logsdon
 
(3 intermediate revisions by one other user not shown)
Line 2: Line 2:
 
=line()=
 
=line()=
 
==Description==
 
==Description==
 +
Line is a function that draws a line using two points. For most shapes you can set the color using [[GSDP:GAM100/CProcessing/fill()                    |fill()                  ]], but a line is only a stroke, so you must use [[GSDP:GAM100/CProcessing/stroke()                  |stroke()                ]] to set the color.
  
 +
====Parameters====
 +
line(x1, y1, x2, y2);
 +
 +
* x1 - (float) the first point's x position
 +
* y1 - (float) the first point's y position
 +
* x2 - (float) the second point's x position
 +
* y2 - (float) the second point's y position
  
 
==Example==
 
==Example==
Line 8: Line 16:
 
void update()  
 
void update()  
 
{
 
{
 +
    // set the stroke color to orange
 +
    stroke(color(255, 160, 20, 255));
 +
 +
    // draw a line from (100, 100) to (100, 200)
 +
    //  x1      y1      x2      y2
 +
    line(100.0f, 100.0f, 500.0f, 100.0f);
 +
 +
    // set the stroke color to light blue
 +
    stroke(color(0, 160, 255, 255));
  
 +
    // draw a line from the origin to the mouse position
 +
    line(0.0f, 0.0f, mouseX, mouseY);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 23: Line 42:
 
* [[GSDP:GAM100/CProcessing/triangle()                |triangle()              ]]
 
* [[GSDP:GAM100/CProcessing/triangle()                |triangle()              ]]
 
* [[GSDP:GAM100/CProcessing/quad()                    |quad()                  ]]
 
* [[GSDP:GAM100/CProcessing/quad()                    |quad()                  ]]
* [[GSDP:GAM100/CProcessing/rect()                    |rectRotated()            ]]
+
* [[GSDP:GAM100/CProcessing/rectRotated()                    |rectRotated()            ]]
 
* [[GSDP:GAM100/CProcessing/ellipseRotated()          |ellipseRotated()        ]]
 
* [[GSDP:GAM100/CProcessing/ellipseRotated()          |ellipseRotated()        ]]
 
* [[GSDP:GAM100/CProcessing/lineRotated()            |lineRotated()            ]]
 
* [[GSDP:GAM100/CProcessing/lineRotated()            |lineRotated()            ]]

Latest revision as of 14:39, 5 October 2019

line()

Description

Line is a function that draws a line using two points. For most shapes you can set the color using fill() , but a line is only a stroke, so you must use stroke() to set the color.

Parameters

line(x1, y1, x2, y2);

  • x1 - (float) the first point's x position
  • y1 - (float) the first point's y position
  • x2 - (float) the second point's x position
  • y2 - (float) the second point's y position

Example

void update() 
{
    // set the stroke color to orange
    stroke(color(255, 160, 20, 255));

    // draw a line from (100, 100) to (100, 200)
    //   x1      y1      x2      y2
    line(100.0f, 100.0f, 500.0f, 100.0f);

    // set the stroke color to light blue
    stroke(color(0, 160, 255, 255));

    // draw a line from the origin to the mouse position
    line(0.0f, 0.0f, mouseX, mouseY);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>