Esempio n. 1
0
	def copy(self):
		nscolor = panel.color().colorUsingColorSpace_(NSColorSpace.deviceRGBColorSpace())
		r = nscolor.redComponent()
		g = nscolor.greenComponent()
		b = nscolor.blueComponent()
		a = panel.alpha()
		color = r,g,b,a
		copy_to_clipboard({
			"hex": color_to_hex,
			"uicolor": color_to_uicolor,
			"rgba": color_to_rgba,
			"rgb": color_to_rgb
		}.get(format, color_to_hex)(color))
		self.close()
Esempio n. 2
0
 def copy(self):
     nscolor = panel.color().colorUsingColorSpace_(
         NSColorSpace.deviceRGBColorSpace())
     r = nscolor.redComponent()
     g = nscolor.greenComponent()
     b = nscolor.blueComponent()
     a = panel.alpha()
     color = r, g, b, a
     copy_to_clipboard({
         "hex": color_to_hex,
         "uicolor": color_to_uicolor,
         "rgba": color_to_rgba,
         "rgb": color_to_rgb
     }.get(format, color_to_hex)(color))
     self.close()
Esempio n. 3
0
def drawPath(path=None):
    # draws the path
    if path is None:
        path = currentPath
    if currentFillColor is not None:
        currentFillColor.set()
        path.fill()
    if currentGradient is not None:
        save()
        path.addClip()
        (gradientType, startPoint, endPoint, colors,
         locations) = currentGradient
        NSColors = []
        for color in colors:
            a = 1
            g = None
            if len(color) == 1:
                r = color[0]
            elif len(color) == 2:
                r, a = color
            elif len(color) == 3:
                r, g, b = color
            elif len(color) == 4:
                r, g, b, a = color
            if g is not None:
                NSColors.append(
                    NSColor.colorWithCalibratedRed_green_blue_alpha_(
                        r, g, b, a))
            else:
                NSColors.append(NSColor.colorWithCalibratedWhite_alpha_(r, a))
        gradient = NSGradient.alloc().initWithColors_atLocations_colorSpace_(
            NSColors, locations, NSColorSpace.deviceRGBColorSpace())
        if gradientType == "linear":
            gradient.drawFromPoint_toPoint_options_(
                startPoint, endPoint, NSGradientDrawsBeforeStartingLocation
                | NSGradientDrawsAfterEndingLocation)
        elif gradient.gradientType == "radial":
            pass
        restore()
    if currentStrokeWidth is not None:
        path.setLineWidth_(currentStrokeWidth)
    if currentStrokeColor is not None:
        currentStrokeColor.set()
        path.stroke()
Esempio n. 4
0
def drawPath(path=None):
	# draws the path
	if path is None:
		path = currentPath
	if currentFillColor is not None:
		currentFillColor.set()
		path.fill()
	if currentGradient is not None:
		save()
		path.addClip()
		(gradientType, startPoint, endPoint, colors, locations) = currentGradient
		NSColors = []
		for color in colors:
			a = 1
			g = None
			if len(color) == 1:
				r = color[0]
			elif len(color) == 2:
				r, a = color
			elif len(color) == 3:
				r, g, b = color
			elif len(color) == 4:
				r, g, b, a = color
			if g is not None:
				NSColors.append(NSColor.colorWithCalibratedRed_green_blue_alpha_(r, g, b, a))
			else:
				NSColors.append(NSColor.colorWithCalibratedWhite_alpha_(r, a))
		gradient = NSGradient.alloc().initWithColors_atLocations_colorSpace_(NSColors, locations, NSColorSpace.deviceRGBColorSpace())
		if gradientType == "linear":
			gradient.drawFromPoint_toPoint_options_(startPoint, endPoint, NSGradientDrawsBeforeStartingLocation | NSGradientDrawsAfterEndingLocation)
		elif gradient.gradientType == "radial":
			pass
		restore()
	if currentStrokeColor is not None:
		currentStrokeColor.set()
		path.stroke()