Beispiel #1
0
    def convert_image ( self, image ):
        """ Returns a new version of the specified *image* with all of the
            current image knife operations applied.
        """
        if self.can_transform:
            image = hlsa_derived_image( image, self.transform )

        if self.can_scale:
            image = image.scale( self.scale / 100.0, self.filter )

        if self.can_trim:
            image = image.trim( self.alpha / 100.0 )

        if self.can_squeeze:
            image = image.squeeze( self.squeeze, self.tolerance )

        if self.can_crop:
            width, height = image.width, image.height
            image = image.crop(
                min( self.left, width  - 1 ),
                min( self.top,  height - 1 ),
                max( width  - self.left - self.right,  1 ),
                max( height - self.top  - self.bottom, 1 )
            )

        return image
Beispiel #2
0
    def _selected_image_set ( self, image ):
        """ Handles the 'selected_image' facet being changed.
        """
        if image is not None:
            image = hlsa_derived_image( self.input_image, image.transform )

        self.output_image = image
 def _theme_transform ( self, theme, hlsa_transform ):
     """ Returns a version of the base *theme* with the HLSA transform
         specified by *hlsa_transform* applied.
     """
     return Theme(
         image     = hlsa_derived_image( theme.image, hlsa_transform ),
         border    = theme.border,
         content   = theme.content,
         label     = theme.label,
         alignment = theme.alignment
     )
Beispiel #4
0
    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        # Determine the drag/drop type:
        self.type = self.factory.type
        if self.type == 'auto':
            value = self.value
            if (isinstance( value, string_type ) or
                (isinstance( value, list ) and (len( value ) > 0) and
                 isinstance( value[0], string_type ))):
                self.type = 'files'

        # Get the right image to use:
        image = self.factory.image
        if image is not None:
            disabled_image = (self.factory.disabled_image or
                              hlsa_derived_image( image, DisabledTransform ))
        else:
            disabled_image = inactive_image
            image          = object_image
            if self.type == 'files':
                image = file_image

        self._image          = image
        self._disabled_image = disabled_image

        # Create the control and set up the event handlers:
        self.adapter     = control = toolkit().create_control( parent )
        control.min_size = ( image.width, image.height )

        control.set_event_handler(
            left_down = self._left_down,
            left_up   = self._left_up,
            motion    = self._mouse_move,
            paint     = self._on_paint
        )

        if self.drop_target:
            control.drop_target = self

        self.set_tooltip()
Beispiel #5
0
    def _create_variations ( self ):
        """ Creates all of the variations of the input image.
        """
        images = []
        image  = self.scaled_image
        if image is not None:
            hue,        hue_delta        = self._range_for( self.hue )
            lightness,  lightness_delta  = self._range_for( self.lightness )
            saturation, saturation_delta = self._range_for( self.saturation )
            alpha,      alpha_delta      = self._range_for( self.alpha )
            for i in xrange( self.count ):
                transform = HLSATransform(
                    hue        = hue,
                    lightness  = lightness,
                    saturation = saturation,
                    alpha      = alpha
                )
                images.append( hlsa_derived_image( image, transform ) )
                hue        += hue_delta
                lightness  += lightness_delta
                saturation += saturation_delta
                alpha      += alpha_delta

        self.images = images
    def _hover_off_image_default ( self ):
        if self.off_image is self._default_off_image:
            return self._default_hover_off_image

        return hlsa_derived_image( self.off_image, HoverTransform )
    def _off_image_default ( self ):
        if self.image is self._default_image:
            return self._default_off_image

        return hlsa_derived_image( self.image, OffTransform )
Beispiel #8
0
 def _disabled_image_default ( self ):
     return hlsa_derived_image( self.normal_image, DisabledTransform )
Beispiel #9
0
 def _down_image_default ( self ):
     return hlsa_derived_image( self.normal_image, DownTransform )
Beispiel #10
0
 def _hover_image_default ( self ):
     return hlsa_derived_image( self.normal_image, HoverTransform )
    def _disabled_image_default ( self ):
        return hlsa_derived_image( self.image, DisabledTransform )

#-- EOF ------------------------------------------------------------------------