Giter Club home page Giter Club logo

Comments (3)

Jugen avatar Jugen commented on June 28, 2024

It looks like there's a single pixel space between each line, and that pixel is being colored red without the alpha being applied ???
Or maybe it's an overlap of one pixel with the alpha's being combined ???

from richtextfx.

PavelTurk avatar PavelTurk commented on June 28, 2024

@Jugen I checked the color if this one pixel line, it is #c32828 . If it were color without alpha it would be #FF0000

from richtextfx.

Jugen avatar Jugen commented on June 28, 2024

So I've figured it out and it's coming from the overlap of the top highlight line with the one underneath it.
I've tried various ways of trying to get it perfectly aligned but there's always either a slight overlap or a slight gap ?
This problem is only noticeable when using a highlight color using an alpha component.
The relevant code section is in ParagraphText.getRangeShapeSafely

private PathElement[] getRangeShapeSafely(int start, int end) {
PathElement[] shape;
if (end <= paragraph.length()) {
// selection w/o newline char
shape = getRangeShape(start, end);
} else {
// Selection includes a newline character.
double width = getWidth() - getInsets().getRight() - getInsets().getLeft();
if (paragraph.length() == 0) {
// empty paragraph
shape = createRectangle(0, 0, width, getHeight());
} else if (start == paragraph.length()) {
// selecting only the newline char
// calculate the bounds of the last character
shape = getRangeShape(start - 1, start);
LineTo lineToTopRight = (LineTo) shape[shape.length - 4];
shape = createRectangle(lineToTopRight.getX(), lineToTopRight.getY(), width, getHeight());
} else {
shape = getRangeShape(start, paragraph.length());
// Since this might be a wrapped multi-line paragraph,
// there may be multiple groups of (1 MoveTo, 4 LineTo objects) for each line:
// MoveTo(topLeft), LineTo(topRight), LineTo(bottomRight), LineTo(bottomLeft)
// Adjust the top right, and bottom left & right corners to extend to the
// correct width and height of the line, simulating a full line selection.
int length = shape.length;
if ( length > 3 ) // Prevent IndexOutOfBoundsException accessing shape[] issue #689
{
int bottomRightIndex = length - 3;
int topRightIndex = bottomRightIndex - 1;
int bottomLeftIndex = bottomRightIndex + 1;
LineTo lineToTopRight = (LineTo) shape[topRightIndex];
LineTo lineToBottomLeft = (LineTo) shape[bottomLeftIndex];
shape[topRightIndex] = new LineTo(width, lineToTopRight.getY());
shape[bottomLeftIndex] = new LineTo(lineToBottomLeft.getX(), getHeight());
shape[bottomRightIndex] = new LineTo(width, getHeight());
}
}
}
if ( getLineSpacing() > 0 ) {
double half = getLineSpacing() / 2.0;
for ( int g = 0; g < shape.length; g += 5 ) {
MoveTo tl = (MoveTo) shape[g];
tl.setY( tl.getY()-half );
LineTo tr = (LineTo) shape[g+1];
tr.setY( tl.getY() );
LineTo br = (LineTo) shape[g+2];
br.setY( br.getY()+half );
LineTo bl = (LineTo) shape[g+3];
bl.setY( br.getY() );
LineTo t2 = (LineTo) shape[g+4];
t2.setY( tl.getY() );
}
}

from richtextfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.