GithubHelp home page GithubHelp logo

Comments (1)

mitchcurtis avatar mitchcurtis commented on May 12, 2024

Something like this could work, but I think that fixing #47 might be a better solution for this.

diff --git a/app/imagecanvas.cpp b/app/imagecanvas.cpp
index 1cfb715..e8de142 100644
--- a/app/imagecanvas.cpp
+++ b/app/imagecanvas.cpp
@@ -132,6 +132,8 @@ ImageCanvas::ImageCanvas() :
     mCheckerPixmap = QPixmap(":/images/checker.png");
     if (mCheckerPixmap.isNull()) {
         qWarning() << "Failed to load checker pixmap";
+    } else {
+        mCheckerImage = mCheckerPixmap.toImage();
     }
 
     installEventFilter(this);
@@ -504,7 +506,13 @@ QColor ImageCanvas::cursorPixelColour() const
 
 QColor ImageCanvas::invertedCursorPixelColour() const
 {
-    return invertedColour(mCursorPixelColour);
+    if (mCursorPixelColour.alpha() > 0)
+        return invertedColour(mCursorPixelColour);
+
+    const int checkerX = mCursorSceneX / mCheckerImage.width();
+    const int checkerY = mCursorSceneY / mCheckerImage.height();
+    qDebug() << checkerX << checkerY << mCheckerImage.pixelColor(checkerX, checkerY);
+    return invertedColour(mCheckerImage.pixelColor(checkerX, checkerY));
 }
 
 QColor ImageCanvas::invertedColour(const QColor &colour)
diff --git a/app/imagecanvas.h b/app/imagecanvas.h
index fbc17da..5798677 100644
--- a/app/imagecanvas.h
+++ b/app/imagecanvas.h
@@ -398,6 +398,7 @@ protected:
     QColor mGridColour;
     QColor mSplitColour;
     QPixmap mCheckerPixmap;
+    QImage mCheckerImage;
 
     bool mSplitScreen;
     Splitter mSplitter;

from slate.

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.