消除内外阴影之间的间隙

时间:2019-02-18 16:10:16

标签: css css3 box-shadow

我在box-shadows元素上有内部.cursor和外部const r = 75; let cursor = document.querySelector(".cursor"); document.onmousemove = function(e) { let suggestedX = e.clientX - r; if ((suggestedX + 2.1 * r) < window.innerWidth && suggestedX > 0) { cursor.style.left = suggestedX + "px"; } let suggestedY = e.clientY - r; if ((suggestedY + 2.1 * r) < window.innerHeight && suggestedY > 0) { cursor.style.top = suggestedY + "px"; } };来实现遮罩光效果。如何消除它们之间的空白?

enter image description here

body {
  background: black;
  background: salmon;
  overflow: hidden;
}

.cursor {
  position: absolute;
  background: transparent;
  border-radius: 50%;
  width: 150px;
  height: 150px;
  left: 50%;
  top: 50%;
  box-shadow: inset 0 0 15px 20px rgba(0, 0, 0, 0.8), 0 0 0 4000px rgba(0, 0, 0, 0.8);
  z-index: 1;
}

.text {
  opacity: 1;
  font-family: Courier;
  color: #ccc;
  word-break: break-word;
}
<div class="cursor"></div>
<div class="text"></div>
import sys, os
pyDir = os.path.dirname(os.path.abspath(__file__)) #python file location

from pyface.qt import QtGui, QtCore
os.environ['ETS_TOOLKIT'] = 'qt4'
import sip
sip.setapi('QString', 2)
import matplotlib
matplotlib.use('Agg')
#matplotlib.use('Qt4Agg')
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
from matplotlib.widgets import Slider, Button
import mpl_toolkits.axes_grid1
import matplotlib.path as pltPath
import matplotlib.image as mpimg
from matplotlib.ticker import MaxNLocator
from matplotlib import rc
from mpl_toolkits.mplot3d import Axes3D


class P4(QtGui.QWidget):

    def __init__(self, parent=None):
        super(P4, self).__init__(parent)
        P4.layout = QtGui.QGridLayout(self)
        P4.layout.setContentsMargins(20,20,20,20)
        P4.layout.setSpacing(10)

        P4.button_pic1 = QtGui.QPushButton('View Plots', self)
        P4.button_pic1.clicked.connect(self.RC_vid1)
        P4.layout.addWidget(P4.button_pic1, 2, 8, 1, 1)
        P4.button_pic1.show()

    def RC_vid1(self):

        global PrD_window
        try:
            PrD_window.close()
        except:
            pass

        PrD_window = PrD_Viz()
        PrD_window.show()

################################################################################

class PrD_Viz(QtGui.QMainWindow):
    def __init__(self):
        super(PrD_Viz, self).__init__()
        self.left = 10
        self.top = 10
        self.initUI()

    def initUI(self):
        vid_tab2 = ManifoldCanvas(self)
        vid_tab3 = PsiCanvas(self)
        global vid_tabs
        vid_tabs = QtGui.QTabWidget(self)
        vid_tabs.addTab(vid_tab2, 'Plot 1')
        vid_tabs.addTab(vid_tab3, 'Plot 2')

        style = """QTabWidget::tab-bar{
                alignment: center;
                }"""
        self.setStyleSheet(style)
        self.setCentralWidget(vid_tabs)
        self.setWindowModality(QtCore.Qt.ApplicationModal) #freezes out parent window
        self.show()

class ManifoldCanvas(QtGui.QDialog):
    pts_orig = []

    def __init__(self, parent=None):
        super(ManifoldCanvas, self).__init__(parent)

        self.figure = Figure(dpi=200)
        self.ax = self.figure.add_subplot(111)
        self.figure.set_tight_layout(True)
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)

        x=[1,5,9]
        y=[2,6,10]

        ManifoldCanvas.pts_orig = zip(x,y)
        for i in ManifoldCanvas.pts_orig:
            x,y = i
            self.ax.scatter(x,y,s=1,c='#1f77b4')

        self.canvas.draw_idle()

        layout = QtGui.QGridLayout()
        layout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
        layout.addWidget(self.toolbar, 0,0,1,5)
        layout.addWidget(self.canvas, 1,0,1,5)

        self.setLayout(layout)

class PsiCanvas(QtGui.QDialog):

    def __init__(self, parent=None):
        super(PsiCanvas, self).__init__(parent)

        self.psi1 = [10,11,12]
        self.psi2 = [24,19,18]
        self.psi3 = [99,90, 105]

        # create canvas and plot data:
        self.figure = Figure(dpi=200)
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.ax = Axes3D(self.figure)
        self.ax.mouse_init()

        self.ax.scatter(self.psi1, self.psi2, self.psi3, label='psi_dif', linewidths= .5, edgecolors='k', c='#d62728') #C3

        self.canvas.draw_idle() #refresh canvas

        layout = QtGui.QGridLayout()
        layout.setSizeConstraint(QtGui.QLayout.SetMinimumSize)
        layout.addWidget(self.toolbar, 0,0,1,4)
        layout.addWidget(self.canvas, 1,0,4,4)

        self.setLayout(layout)

################################################################################
# overhead GUI control: 

class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        tab4 = P4(self)

        global tabs
        tabs = QtGui.QTabWidget(self)
        tabs.resize(250,150)

        tabs.addTab(tab4, 'Eigenfunctions')

        self.setCentralWidget(tabs)
        self.show()


if __name__ == '__main__':

    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication([])

    w = MainWindow()
    sys.exit(app.exec_())

0 个答案:

没有答案