gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Painter Fuzzy Node in github


From: Johan Ceuppens
Subject: Re: Painter Fuzzy Node in github
Date: Thu, 18 Dec 2014 09:07:10 +0100

2014-12-17 22:07 GMT+01:00 Ivan Vučica <address@hidden>:

I'll be a bit more direct in this email.

I don't see the equivalence between fuzzy logic and AI nor does random application of AI-related approaches automatically make for a smarter algorithm.


I'll explain better then :
Probably the system now as it stands for CoreX etc is mapping a window. Also X11 (sub)windows get mapped with or without the main windows AFAIK. X11 paints once per map cycle. If you paint in X you have to loop constantly through painting the screen (GS also has a root window, again a window). IF you do not paint in X11 your window lookandfeel or subelements will not be updated on the screen.

Now, if you use fuzzy logic that follows the mouse pointer you have a target mathematical attractor to a window which gains focus or gets "mapped". This attractor proves for more speed in the drawing process.

As another example, the look and feel of a button is themed AFAIK, you can learn how a user clicks buttons, say by a repetition, again a math attractor where only say two of the buttons actually get used for example in a music player you only click on play and pause mostly and not stop (e.g. while music is playing). If you load files into your playlist you will use the file menu item and so on (another attractor).

The speed of things, where IVan is most uncertain about : My fuzzy set rule gets triggered by a mathematical function such x^3 (associated with "update/paint now" so take more cycles) or sqrt(x)/1.3 ("update/paint indeed" idles more in between drawing) it is clear that the first will give a higher result than the other but if one of them is say below a threshold=1
it triggers a paint method. Paint methods can be very varied as to what you actually want to update with an attractor.

I hope this answers your question about smarter algorithm, you paint less as your painting of the full window is distributed in the window its subelements.

I'll now example how this can be put into QuartzCore : This is CRenderer.h : See my comments in it :
<code>
@class CAGLProgram;
@interface CARenderer : NSObject
{
  NSOpenGLContext * _GLContext;
  CALayer * _layer;
  CGRect _bounds;
  CGRect _updateBounds;

//Here you see where the _currenttime and nextFrameTime can be altered by fuzzy logic to update smarter
  CFTimeInterval _firstRender;
  CFTimeInterval _currentTime;
  CFTimeInterval _nextFrameTime;

  NSMutableArray * _rasterizationSchedule;

  /* a temporary optimization hack */
  BOOL _previousFrameWasANoop;

  /* GL programs */
  CAGLProgram * _simpleProgram;
  CAGLProgram * _blurHorizProgram;
  CAGLProgram * _blurVertProgram;
}

+ (CARenderer*)rendererWithNSOpenGLContext: (NSOpenGLContext *)context
                                   options: (NSDictionary *)options;

@property (retain) CALayer *layer; /* root layer */
@property (nonatomic, assign) CGRect bounds;

- (void) addUpdateRect: (CGRect)updateRect;
- (void) beginFrameAtTime: (CFTimeInterval)timeInterval
                timeStamp: (CVTimeStamp *)timeStamp;
- (void) endFrame;
- (CFTimeInterval) nextFrameTime;
- (void) render;
- (CGRect) updateBounds;

@end

</code>
Then we have CALayer.h : I'll comment in the code :

 <code>
//sublayers are a decision tree for updating e.g. where you mouse pointer is, you always catch the
x_root, y_root and mousex and mousey from a mouse event.
- (void) addSublayer: (CALayer *)layer;
- (void) removeFromSuperlayer;
//this seems like a list or tree see above
- (void) insertSublayer: (CALayer *)layer atIndex: (unsigned)index;
- (void) insertSublayer: (CALayer *)layer below: (CALayer *)sibling;
- (void) insertSublayer: (CALayer *)layer above: (CALayer *)sibling;
- (void) display;
//this is a simple constraint in the .m file with checking one variable
//it's clear that displayIfNeeded would have the fuzzy logic system as its constraint
- (void) displayIfNeeded;
- (BOOL) needsDisplay;
- (void) setNeedsDisplay;
- (void) setNeedsDisplayInRect: (CGRect)r;
- (void) drawInContext: (CGContextRef)context;
//same thing here but in another node
- (BOOL) needsLayout;
- (void) setNeedsLayout;
- (void) layoutIfNeeded;

- (id) presentationLayer;
- (id) modelLayer;

- (CGAffineTransform) affineTransform;
- (void) setAffineTransform: (CGAffineTransform)affineTransform;

@end

//the actual drawing
@interface NSObject (CALayerActions)
- (void) displayLayer: (CALayer*)layer;
- (void) drawLayer: (CALayer*)layer inContext: (CGContextRef)context;
- (id<CAAction>) actionForLayer: (CALayer*)layer forKey: (NSString*)eventKey;
@end

@interface NSObject (CALayerLayoutManager)
- (void) layoutSublayersOfLayer: (CALayer*)layer;
@end

As you can see the sublayers of a CALayer can be update with fuzzy logic or a decision tree. I hope this is clear now if you take a look at the above two files.

You have not clarified what exactly will be smarter or faster. Being capable to explain why your changes are good and why they are improvements, in a way that is parsable by other developers, is as important as actual development -- even more so when you are new to a project.

Why it is fast : you just trigger fuzzy set logical rules with a math function such as sqrt(x)/1.3 compared to a threshold that's all which gets done. You __invent__ the right math functions for the update system and off you go !
 
I do write a lot of code by heart, I know, but as David said, I'll try to have something working later on.

I think we'll all be happy to take another look when you have progressed further and if you have something demonstrably better and smarter.


Correct.
 
Opal contains code for updating surfaces such as (I think) font glyphs and cairo code and other surfaces. These can all be rendered subelementally inside a window or view with a smart updating/drawing alogrithm.
The main advantage is a bit of tree searching (threshold reaching so that you hang on a local extremum in the fuzzy logic set) and then updating less. The updating less is the thing I guess.
 

On Wednesday, December 17, 2014, Johan Ceuppens <address@hidden> wrote:
Right said Fred,

2014-12-17 20:08 GMT+01:00 Gregory Casamento <address@hidden>:
Johan,

The URL http://github.com/gnustep is my account for the mirror from
SVN.   I think your URL is incorrect.


The URL is my repo indeed : https://github.com/enrytheermit/gnustep See the gnustep-fuzzy directory.

Best regards,
`Enry


--
Gregory Casamento
GNUstep Lead Developer / OLC, Principal Consultant
http://www.gnustep.org - http://heronsperch.blogspot.com
http://ind.ie/phoenix/
_______________________________________________
Gnustep-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/gnustep-dev

reply via email to

[Prev in Thread] Current Thread [Next in Thread]