CLColorPicker: User friendly color picker for Mac apps

Here is implementation of color picker control which is similar to one that used in original Mac applications like Numbers, Pages, Keynote. Original one has lots of small pictures. This control based on NSSegmentedControl and have numbers of useful thinks to know, so it’s not just implementation but also good place to look:
- how to subclass NSSegmentedCell
- how is working NSTrackingArea
- create NSPopover


Easy to use. Just create view and add on your master view:

1
2
CLColorPicker *control = [CLColorPicker alloc] initWithFrame:NSMakeRect(100,100, 70, 24)];
[self.view addSubview:control];

To get selected color:

1
NSColor *color = control.selectedColor;

Or set color:

1
[control setSelectedColor:yourColor];

command atos

Very useful command `atos`.

A stripped, optimized version of Sketch was built as an x86_64 position-independent executable (PIE)
into /BuildProducts/Release. Full debug symbol information is available in Sketch.app.dSYM, which sits
alongside Sketch.app. When Sketch.app was run, the Sketch binary (which was built at 0×100000000) was
loaded at 0x10acde000. Running ‘sample Sketch’ showed 3 addresses that we want to get symbol informa-tion information
tion for — 0x10acea1d3, 0x10ace4bea, and 0x10ace4b7a.

First notice that the .dSYM is next to the .app:

% ls -1 /BuildProducts/Release/
Sketch.app
Sketch.app.dSYM

Now, to symbolicate, we run atos with the -o flag specifying the path to the actual Sketch executable
(not the .app wrapper), the -arch x86_64 flag, and the -l _x1_acde___ flag to specify the load address.

% atos -o /BuildProducts/Release/Sketch.app/Contents/MacOS/Sketch -arch x86_64 -l 0x10acde000 0x10acea1d3 0x10ace4bea 0x10ace4b7a
-[SKTGraphicView drawRect:] (in Sketch) (SKTGraphicView.m:445)
-[SKTGraphic drawHandlesInView:] (in Sketch) (NSGeometry.h:110)
-[SKTGraphic drawHandleInView:atPoint:] (in Sketch) (SKTGraphic.m:490)

Source

zNear and zFar plane Size

Following math works for perspective projection.

aEwwS

Height of zNear, another words it’s height of near plane:

 float H_near = 2*near*tan(fovy/2);

And the same for zFar, to get height of far plane:

 float H_far = 2*far*tan(fovy/2);

To get width, just multiple on aspect ratio of your screen.

What is Perspective Projection?
Perspective projection is a form of pictorial drawing that gives the illusion of depth onto a flat surface, very similar to that of viewing of the object through the human eye. In comparison to other types of projection systems, for example orthographic and oblique, the spectator is viewing the object from infinity. The projection rays radiate parallel to each other from the object back to the spectator, compared to perspective projection where the projected rays radiate from the object to a single point at a given distance from the object. source

Very good material about perspective projection.
A computer monitor is a 2D surface. A 3D scene rendered by OpenGL must be projected onto the computer screen as a 2D image. GL_PROJECTION matrix is used for this projection transformation. First, it transforms all vertex data from the eye coordinates to the clip coordinates. Then, these clip coordinates are also transformed to the normalized device coordinates (NDC) by dividing with w component of the clip coordinates.

About Perspective Projection + code

Posted in OpenGL
Tagged Math, , perspective, plane, zFar, zNear

Charts control with animations for iOS

Almost half year ago I’ve made this control. For one idea, but then I found that my idea does not good enough to be implemented.

It has just 2 classes VBPieChart, superclass UIView, and VBPiePiece, superclass CAShapeLayer. And really used just VBPieChart. All chart based on CALayer’s and depends to QuartzCore.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
VBPieChart *_chart = [[VBPieChart alloc] init];
[self.view addSubview:_chart];
   
[_chart setFrame:CGRectMake(10, 50, 300, 300)];
[_chart setEnableStrokeColor:YES];
_chart.length = M_PI;
_chart.startAngle = M_PI;

[_chart.layer setShadowOffset:CGSizeMake(2, 2)];
[_chart.layer setShadowRadius:3];
[_chart.layer setShadowColor:[UIColor blackColor].CGColor];
[_chart.layer setShadowOpacity:0.7];

[_chart setHoleRadiusPrecent:0.3];
NSDictionary *chartValues = @{

                       @"data one":  @{@"value":@35 },
                       @"data two":  @{@"value":@20 },
                       @"data tree":  @{@"value":@10 },
                       @"first ":  @{@"value":@40},
                       @"second": @20,
                       @"third": @40,
                       @"fourth": @10,
                       };

[_chart setChartValues:chartValues animation:YES];

chartValues contains items of chart.
1. name of piece
2. dictionary with NSNumber or parameters:
– value actually size of piece
– color, UIColor
– accent, bool value to show this item with shift

VBPieChart has 5 different types of animations.


Cocoacontrols logo

cocoapods logo

Posted in iOS
Tagged Animation, CAAnimation, CABasicAnimation, CALayer, CAShapeLayer, Chart, Charts, Control, dev, , ,

Share source code of my app

I’ve uploaded source code of my app on Github under MIT license.

App and code is free, you can do with it where you want.
If you will want add some improvements for app, I may will release them in next version ;)

Thanks

P.S.: Code not cleaned and lack of comments.

Rotate model with GLKit – Quaternions and Matrices math

I was looking for algorithm to apply additional rotation to model with current rotation matrix, and found this:

1
2
3
GLKVector3 up = GLKVector3Make(0.f, 1.f, 0.f);
up = GLKQuaternionRotateVector3( GLKQuaternionInvert(quarternion), up );
GLKQuaternion quarternion = GLKQuaternionMultiply(quarternion, GLKQuaternionMakeWithAngleAndVector3Axis(delta.x * RADIANS_PER_PIXEL, up));

It’s from this small tutorial about rotation:
A bit modified code, source here
Under code a bit more text and links
Continue reading

ClipMaker – первое приложение в App store ради опыта.

Не судите меня строго, но на порыве популярности #selfie решил сделать приложение :)
Хочется посмотреть, выйдет ли что-то из этого.
Сам же таким не страдаю и нравится использовать приложение для других целей.
Написал за нескольно дней и поэтому не может подвергаться критике ;)
Доступно со вчерашнего дня и бесплатно. Всю собранную статистику опубликую.

Download_on_the_App_Store_Badge_US-UK_135x40

Страничка на сайте

Мне больше нравится делать видео, следующего содержания:



1 2 3 23