Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawWedgeLine does not respect y datum #2817

Open
MyriadBugs opened this issue Aug 28, 2023 · 2 comments
Open

drawWedgeLine does not respect y datum #2817

MyriadBugs opened this issue Aug 28, 2023 · 2 comments

Comments

@MyriadBugs
Copy link

MyriadBugs commented Aug 28, 2023

https://github.com/Bodmer/TFT_eSPI/blob/caa1076c138c89578bfb4bb2535dbe1faeaa96c7/TFT_eSPI.cpp#L4471C19-L4500C19

The drawWedgeLine function uses clipWindow to.... clip the window and apply the datum/origin offsets. X positioning uses the freshly clipped and shifted x0 stored in xs; however, the y scanning directly uses the ay/by floats which were were not clipped to the window AND didn't have the ydatum applied to them.

  1. Create a sprite 100x100
  2. Set Origin to 0,-100
  3. drawWideLine from 0,80 to 10,120
    Instead of the wide line starting off-screen and coming down into the top of the sprite, the line will start at the bottom of the screen and drift off the end.

My quick hack was just the following before we set ys to ay or by. I don't think this will correctly clip the actual thickness of the line but it's good enough for my objectives.

if (!clipWindow(&x0, &y0, &x1, &y1)) return;
//quick hack for datum respect
	ay += _yDatum;
	by += _yDatum;

	// Crop drawing area bounds
	if (ay < _vpY) {ay = _vpY; }
	if (by < _vpY) {by = _vpY; }
//end hack.
  int32_t ys = ay;
  if ((ax - ar) > (bx - br)) ys = by;
@MyriadBugs
Copy link
Author

MyriadBugs commented Aug 28, 2023

Note, I discovered a related issue, because the datums are already applied, the readPixel within drawWedgeLine call will apply the datum offset an extra time and cause reads from the wrong position (datum * 2). My ugly fast hack was just to subtract the datums within the method call to readPixel.

Also: Small Doc/Feature Request: When I first started using the library I assumed TFT_TRANSPARENT would be 0x00FFFFFF and was the value to pass to bg_color if you wanted to decide at runtime whether to have transparent backgrounds. Took me a while before I realized that it was for a different purpose.

@MyriadBugs MyriadBugs changed the title drawWideLine does not respect y datum Aug 28, 2023
@Bodmer
Copy link
Owner

Bodmer commented Aug 30, 2023

Yes, the smooth graphics functions do not play well with the setViewport or setOrigin functions. It is on my TODO list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment