question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best API for setting pen color?

See original GitHub issue

Right now pen color can be set to any valid CSS color string (like red, #f00, rgb(255, 0, 0), or others).

This isn’t great because it doesn’t leave much wiggle room for setting color, saturation, brightness, or transparency independently (which is possible in Scratch).

What’s the best API for dealing with colors? Color strings are handy, but underpowered.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
towerofnixcommented, Dec 28, 2019

@PullJosh == works for comparing them if you implement the toString function to return a color string (e.g. hex) — it’d be comparing those instead of the actual objects (which is what === usually does).

1reaction
nanaiancommented, Dec 28, 2019

Add a Color type? This is somewhat similar to a special Pen class, but unspecialised.

this.penColor = Color.rgb(1.0, 0.0, 0.0)
console.log(this.penColor == Color.RED) // true
console.log(this.penColor == Color.rgba(1.0, 0.0, 0.0, 1.0)) // true
console.log(this.penColor == Color.hsv(0.0, 1.0, 0.5)) // true (I think)

this.penColor.b += 0.5

I personally like RGB(A) much more than HSV(A), so providing the option would be nice 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Applying styles and colors - Web APIs | MDN
In this example, we'll draw a background of four different colored squares. On top of these, we'll draw a set of semi-transparent circles....
Read more >
Set pen/color for Polyline()? - winapi - Stack Overflow
Setting the DC pen and brush colors doesn't have any effect unless you have the DC pen and/or brush selected into the DC....
Read more >
Color Palette API - API Documentation | Zyla API Hub
Color Palette API. Get random RGB color palletes for your projects. Also, receive suggested colors that could match your current colors. Get coherent...
Read more >
The Turtle API | Turtle Graphics in CircuitPython on TFT Gizmo
The other form sets the pen color to the specified value. The Color class should be used for this value: WHITE , BLACK...
Read more >
turtle — Turtle graphics — Python 3.11.1 documentation
Return or set the pen's attributes in a “pen-dictionary” with the following key/value pairs: “shown”: True/False. “pendown”: True/False. “pencolor”: color- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found