# Error on parameter or method declaration near 'float'?

**URL:** <https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154>\
**Category:** Beginners\
**Created:** [October 10, 2024, 1:52am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154 "2024-10-10T01:52:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![naoko](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@naoko](https://discourse.processing.org/u/naoko)\
**Post date:** [October 10, 2024, 1:52am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/1 "2024-10-10T01:52:25Z")

</div>

```auto
void setup(){
size(200,200);
  background(255);

}

void draw(){
  stroke(0);
  strokeWeight(float)
  float mouseSpeed = abs(mouseX - pmouseX);
 
  line(pmouseX,pmouseY,mouseX,mouseY);

}

```

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 10, 2024, 2:31am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/2 "2024-10-10T02:31:53Z")

</div>

StrokeWeight() is documented here: [https://processing.org/reference/strokeWeight\_.html](https://processing.org/reference/strokeWeight_.html) . It should be some number, not the word ‘float’. Also mouseSpeed is never used so it can be removed unless you have some use for it that you are not showing.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 10, 2024, 2:41am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/3 "2024-10-10T02:41:43Z")

</div>

> [@naoko](#):
>
> strokeWeight(float)

You’ve forgotten the ending semi-colon `;`.  
Also, `float` is a reserved keyword!  
Pass a number or a variable argument for **strokeWeight()**.

---

<div class="post-metadata">

**Author:** ![naoko](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@naoko](https://discourse.processing.org/u/naoko)\
**Post date:** [October 10, 2024, 2:47am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/5 "2024-10-10T02:47:33Z")

</div>

yes,i was about to make the width of line changing according to the mousespeed,but i don’t know how to deploy it

---

<div class="post-metadata">

**Author:** ![naoko](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@naoko](https://discourse.processing.org/u/naoko)\
**Post date:** [October 10, 2024, 2:48am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/6 "2024-10-10T02:48:41Z")

</div>

hi,this is actually a test about write a sentence makes the width of line changing according to the speed of mouse,i can’t figure it out how to write,could you please help me,thanks

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 10, 2024, 3:07am UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/7 "2024-10-10T03:07:37Z")

</div>

You need to declare a global variable that stores the current boldness.  
Then change that global variable according to your local variable _mouseSpeed_.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 10, 2024, 2:18pm UTC](https://discourse.processing.org/t/error-on-parameter-or-method-declaration-near-float/45154/8 "2024-10-10T14:18:16Z")

</div>

**Point 1**

> [@naoko](#):
>
> strokeWeight(float);

please note that float is the **Type** of the variable.  
The **Name** of the variable is mouseSpeed.

Therefore you have to use `mouseSpeed` (its name) when you want to use its value. (probably a typo from your side)  
So don’t say `strokeWeight(float)`, better say `strokeWeight(mouseSpeed);`.

You can also write:

```auto
  float mouseSpeed; // declare var mouseSpeed of type float 
  mouseSpeed = abs(mouseX - pmouseX); // set var mouseSpeed 
  strokeWeight(mouseSpeed); // use var mouseSpeed 

```

* * *

**Point 2**

> [@naoko](#):
>
> strokeWeight(…);  
> float mouseSpeed = …;

You need to use `strokeWeight()` AFTER you declare `mouseSpeed`.  
Because `mouseSpeed` must be known when you use it in `strokeWeight(....);`.  
It must be:

```auto
float mouseSpeed = .........;
strokeWeight(mouseSpeed);

```

* * *

**Full Code**

Here is my version:

_[full code solution removed]_

The results look nice!

**Improvements**

- You can try to make an if-clause to catch when the mouse cursor is  
in the upperleft corner at the beginning.
- You can set a minimum and maximum for strokeWeight to have more control.
- Bigger canvas.
- A key to clear the canvas.

Chrisir
