def gradient_darker(grad, factor):
 if (type(grad) is QGradient):
  if (grad.type() == QGradient.LinearGradient):
   grad = sip.cast(grad, QLinearGradient)
  elif (grad.type() == QGradient.RadialGradient):
   grad = sip.cast(grad, QRadialGradient)
 if isinstance(grad, QLinearGradient):
  new_grad = QLinearGradient(grad.start(), grad.finalStop())
 elif isinstance(grad, QRadialGradient):
  new_grad = QRadialGradient(grad.center(), grad.radius(), grad.focalPoint())
 else:
  raise TypeError
 new_grad.setCoordinateMode(grad.coordinateMode())
 for (pos, color) in grad.stops():
  new_grad.setColorAt(pos, color.darker(factor))
 return new_grad

def gradient_darker ( grad , factor ) : if ( type ( grad ) is QGradient ) : if ( grad . type ( ) == QGradient . LinearGradient ) : grad = sip . cast ( grad , QLinearGradient ) elif ( grad . type ( ) == QGradient . RadialGradient ) : grad = sip . cast ( grad , QRadialGradient ) if isinstance ( grad , QLinearGradient ) : new_grad = QLinearGradient ( grad . start ( ) , grad . finalStop ( ) ) elif isinstance ( grad , QRadialGradient ) : new_grad = QRadialGradient ( grad . center ( ) , grad . radius ( ) , grad . focalPoint ( ) ) else : raise TypeError new_grad . setCoordinateMode ( grad . coordinateMode ( ) ) for ( pos , color ) in grad . stops ( ) : new_grad . setColorAt ( pos , color . darker ( factor ) ) return new_grad
return a copy of the qgradient darkened by factor .