2024年前端最新Core Animation实战五(变换),Web前端阿里等大厂面试题汇总

自学几个月前端,为什么感觉什么都没学到??


这种现象在很多的初学者和自学前端的同学中是比较的常见的。

因为自学走的弯路是比较的多的,会踩很多的坑,学习的过程中是比较的迷茫的。

最重要的是,在学习的过程中,不知道每个部分该学哪些知识点,学到什么程度才算好,学了能做什么。

很多自学的朋友往往都是自己去找资料学习的,资料上有的或许就学到了,资料上没有的或许就没有学到。

这就会给人一个错误的信息就是,我把资料上的学完了,估计也-就差不多的了。

但是真的是这样的吗?非也,因为很多人找的资料就是很基础的。学完了也就是掌握一点基础的东西。分享给你一份前端分析路线,你可以参考。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

还有很多的同学在学习的过程中一味的追求学的速度,很快速的刷视频,写了后面忘了前面,最后什么都没有学到,什么都知道,但是什么都不懂,要具体说,也说不出个所以然。

所以学习编程一定要注重实践操作,练习敲代码的时间一定要多余看视频的时间。

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

  • 3D仿射变换

根据名字我们可以知道,3D仿射变化与仿射变化的区别在于3D是三维矩阵的变换,有了Z轴变化。

Demo:

//

// ThreeDTransViewController.m

// LayerStudyDemo

//

// Created by apple on 2017/10/9.

// Copyright © 2017年 ZY. All rights reserved.

//

#import “ThreeDTransViewController.h”

@interface ThreeDTransViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@end

@implementation ThreeDTransViewController

  • (void)viewDidLoad {

[super viewDidLoad];

//初始化CATransform3D

CATransform3D transForm = CATransform3DIdentity;

//m34决定远近缩放

transForm.m34 = - 1.0 / 500.0;

//旋转M_PI_4

transForm = CATransform3DRotate(transForm, M_PI_4, 0, 1, 0);

//应用带Layer

_imgView.layer.transform= transForm;

}

  • (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

  • 立体模型

我们知道3D变换,那固体模型也可以通过3D变换做出来了。具体看代码备注

Demo:

//

// StereomodelViewController.m

// LayerStudyDemo

//

// Created by apple on 2017/10/10.

// Copyright © 2017年 ZY. All rights reserved.

//

#import “StereomodelViewController.h”

#import <GLKit/GLKit.h>

#define LIGHT_DIRECTION 0, 1, -0.5

#define AMBIENT_LIGHT 0.5

@interface StereomodelViewController ()

@property (strong, nonatomic) IBOutletCollection(UIView) NSArray *faceViews;

@end

@implementation StereomodelViewController

  • (void)viewDidLoad {

[super viewDidLoad];

//创建CATransform3D

CATransform3D perspective = CATransform3DIdentity;

//灭点 物体远近缩放比例

perspective.m34 = -1.0 / 500.0;

//X轴旋转M_PI_4

perspective = CATransform3DRotate(perspective, -M_PI_4, 1, 0, 0);

//Y轴旋转M_PI_4

perspective = CATransform3DRotate(perspective, -M_PI_4, 0, 1, 0);

//子Layer整体应用此CATransform3D

self.view.layer.sublayerTransform = perspective;

[self setRectModel];

}

//添加正方形View到界面,然后组装

-(void)addFaceViewInContainViewWithTransform:(CATransform3D)transform andIndex:(NSUInteger)index{

UIView * faceView = _faceViews[index];

faceView.layer.borderWidth = 1;

faceView.layer.borderColor = [UIColor blackColor].CGColor;

[self.view addSubview:faceView];

faceView.center = self.view.center;

faceView.layer.transform = transform;

[self applyLightingToFace:faceView.layer];

}

//没有实现光线阴影效果,回来找BUG

  • (void)applyLightingToFace:(CALayer *)face

{

//add lighting layer

CALayer *layer = [CALayer layer];

layer.frame = face.bounds;

[face addSublayer:layer];

//convert the face transform to matrix

//(GLKMatrix4 has the same structure as CATransform3D)

//译者注:GLKMatrix4和CATransform3D内存结构一致,但坐标类型有长度区别,所以理论上应该做一次float到CGFloat的转换,感谢@zihuyishi同学~

CATransform3D transform = face.transform;

GLKMatrix4 matrix4 = *(GLKMatrix4 *)&transform;

GLKMatrix3 matrix3 = GLKMatrix4GetMatrix3(matrix4);

//get face normal

GLKVector3 normal = GLKVector3Make(0, 0, 1);

normal = GLKMatrix3MultiplyVector3(matrix3, normal);

normal = GLKVector3Normalize(normal);

//get dot product with light direction

GLKVector3 light = GLKVector3Normalize(GLKVector3Make(LIGHT_DIRECTION));

float dotProduct = GLKVector3DotProduct(light, normal);

//set lighting layer opacity

CGFloat shadow = 1 + dotProduct - AMBIENT_LIGHT;

UIColor *color = [UIColor colorWithWhite:0 alpha:shadow];

layer.backgroundColor = color.CGColor;

}

-(void)setRectModel{

// CATransform3D transform = CATransform3DIdentity;

// transform = CATransform3DTranslate(transform, 0,0, 100);

// [self addFaceViewInContainViewWithTransform:transform andIndex:0];

// CATransform3D transform1 = CATransform3DIdentity;

// transform1 = CATransform3DTranslate(transform1, 100,0, 0);

// transform1 = CATransform3DRotate(transform1, M_PI_2, 0, 1, 0);

// [self addFaceViewInContainViewWithTransform:transform1 andIndex:1];

// CATransform3D transform2 = CATransform3DIdentity;

// transform2 = CATransform3DTranslate(transform2, 0,100, 0);

// transform2 = CATransform3DRotate(transform2, M_PI_2, 0, 1, 0);

// [self addFaceViewInContainViewWithTransform:transform2 andIndex:2];

// [self addFaceViewInContainViewWithTransform:CATransform3DIdentity andIndex:3];

// [self addFaceViewInContainViewWithTransform:CATransform3DIdentity andIndex:4];

// [self addFaceViewInContainViewWithTransform:CATransform3DIdentity andIndex:5];

//add cube face 1

CATransform3D transform = CATransform3DMakeTranslation(0, 0, 50);

[self addFaceViewInContainViewWithTransform:transform andIndex:0];

//add cube face 2

transform = CATransform3DMakeTranslation(50, 0, 0);

transform = CATransform3DRotate(transform, M_PI_2, 0, 1, 0);

[self addFaceViewInContainViewWithTransform:transform andIndex:1];

//add cube face 3

transform = CATransform3DMakeTranslation(0, -50, 0);

transform = CATransform3DRotate(transform, M_PI_2, 1, 0, 0);

[self addFaceViewInContainViewWithTransform:transform andIndex:2];

//add cube face 4

自学几个月前端,为什么感觉什么都没学到??


这种现象在很多的初学者和自学前端的同学中是比较的常见的。

因为自学走的弯路是比较的多的,会踩很多的坑,学习的过程中是比较的迷茫的。

最重要的是,在学习的过程中,不知道每个部分该学哪些知识点,学到什么程度才算好,学了能做什么。

很多自学的朋友往往都是自己去找资料学习的,资料上有的或许就学到了,资料上没有的或许就没有学到。

这就会给人一个错误的信息就是,我把资料上的学完了,估计也-就差不多的了。

但是真的是这样的吗?非也,因为很多人找的资料就是很基础的。学完了也就是掌握一点基础的东西。分享给你一份前端分析路线,你可以参考。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

还有很多的同学在学习的过程中一味的追求学的速度,很快速的刷视频,写了后面忘了前面,最后什么都没有学到,什么都知道,但是什么都不懂,要具体说,也说不出个所以然。

所以学习编程一定要注重实践操作,练习敲代码的时间一定要多余看视频的时间。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值