Annotation of Examples/AppKit/BackspaceViews/FadingImage/FadingImageView.m, revision 1.1

1.1     ! root        1: //
        !             2: //  FadingImageView.m
        !             3: //
        !             4: //  Implements a fading image screen saver view
        !             5: //
        !             6: //  Lennart Lovstrand, August 1991.
        !             7: //     small modifications by sam 910904
        !             8: //
        !             9: //  You may freely copy, distribute, and reuse the code in this example.
        !            10: //  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
        !            11: //  fitness for any particular use.
        !            12: 
        !            13: 
        !            14: #import "FadingImageView.h"
        !            15: #import "Thinker.h"
        !            16: #import <appkit/NXImage.h>
        !            17: #import <dpsclient/wraps.h>
        !            18: #import <libc.h>
        !            19: #import <math.h>
        !            20: //#import <appkit/Application.h>
        !            21: 
        !            22: #define STEPTIME       50      /* time between fades (millisec) */
        !            23: #define WAITTIME       6000    /* wait before fading (millisec) */
        !            24: 
        !            25: #define FADEDELTA      0.05
        !            26: 
        !            27: @implementation FadingImageView
        !            28: 
        !            29: - drawSelf:(const NXRect *)rects :(int)rectCount
        !            30: {
        !            31:        NXPoint p;
        !            32:        if (!rects || !rectCount) return self;
        !            33: 
        !            34:        [super drawSelf:rects :rectCount];
        !            35:        
        !            36:        p.x = floor(imageRect.origin.x);
        !            37:        p.y = floor(imageRect.origin.y);
        !            38: 
        !            39:        [image dissolve: delta toPoint: &p];
        !            40: 
        !            41:        return self;
        !            42: }
        !            43: 
        !            44: - oneStep
        !            45: {
        !            46:        if (![self timePassed: steptime]) return self;
        !            47: 
        !            48:        switch (state)
        !            49:        {
        !            50:        case FV_FadeIn:
        !            51:                delta += FADEDELTA;
        !            52:                if (delta >= 1.0)
        !            53:                {
        !            54:                        delta = 1.0;
        !            55:                        state = FV_FadeOut;
        !            56:                        steptime = WAITTIME;
        !            57:                }
        !            58: 
        !            59:                PSsetgray(0.0);
        !            60:                NXRectFill(&imageRect);
        !            61:                [image dissolve: delta toPoint: &imageRect.origin];
        !            62:                break;
        !            63: 
        !            64:        case FV_FadeOut:
        !            65:                delta -= FADEDELTA;
        !            66:                if (delta <= 0.0)
        !            67:                {
        !            68:                        delta = 0.0;
        !            69:                        state = FV_Move;
        !            70:                }
        !            71: 
        !            72:                PSsetgray(0.0);
        !            73:                NXRectFill(&imageRect);
        !            74:                [image dissolve: delta toPoint: &imageRect.origin];
        !            75:                steptime = STEPTIME;
        !            76:                break;
        !            77: 
        !            78:        case FV_Move:
        !            79:                imageRect.origin.x = floor(randBetween(0, maxCoord.x));
        !            80:                imageRect.origin.y = floor(randBetween(0, maxCoord.y));
        !            81:                state = FV_FadeIn;
        !            82:                steptime = STEPTIME;
        !            83:                break;
        !            84:        }
        !            85: 
        !            86:        return self;
        !            87: }
        !            88: 
        !            89: - initFrame:(NXRect *)frameRect
        !            90: {
        !            91:        steptime = STEPTIME;
        !            92:        state = FV_Move;
        !            93:        return [super initFrame:frameRect];
        !            94: }
        !            95: 
        !            96: - inspector:sender
        !            97: {
        !            98:        return [sender commonImageInspector];
        !            99: }
        !           100: 
        !           101: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.