我想要一个子元素继承与父母相同的维度.如何访问父宽度和高度?像这样的东西:
.thumb {
width: 120px;
height: 120px;);
.content {
width: $parent.width()};
height: $parent.height()}}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AVMutableAudioMixInputParameters的setVolumeRampFromStartVolume方法将我的AVPlayer的音量淡化为0.这是我的代码:
-(void)fadeOutVolume
{
// AVPlayerObject is a property which points to an AVPlayer
AVPlayerItem *myAVPlayerItem = AVPlayerObject.currentItem;
AVAsset *myAVAsset = myAVPlayerItem.asset;
NSArray *audioTracks = [myAVAsset tracksWithMediaType:AVMediaTypeAudio];
NSMutableArray *allAudioParams = [NSMutableArray array];
for (AVAssetTrack *track in audioTracks) {
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:track];
[audioInputParams setVolumeRampFromStartVolume:1.0 toEndVolume:0 timeRange:CMTimeRangeMake(CMTimeMake(0, 1), CMTimeMake(5, 1))];
[allAudioParams addObject:audioInputParams];
}
AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix];
[audioMix setInputParameters:allAudioParams];
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以看到这段代码有什么问题吗?它没有正确淡出音量.
我正在使用Angular 6.0.3.我有一个名为"Admin"的子模块,有三个组件.管理员的根组件("AdminComponent")路由工作正常(path: ""),但我似乎无法触发任何其他组件.为什么Angular不能找到我的路线?
routes.ts
import { Routes } from "@angular/router";
import { SplashComponent } from "./splash/splash.component";
import { LoginComponent } from "./login/login.component";
import { WatchComponent } from "./watch/watch.component";
import { AdminComponent } from "./admin/admin/admin.component";
import { HomeComponent as AdminHomeComponent } from "./admin/home/home.component";
import { AddSongComponent } from "./admin/add-song/add-song.component";
import { AdminGuard } from "./auth/admin.guard";
export const appRoutes: Routes = [
{
path: "",
children: [
{ path: "", component: SplashComponent, pathMatch: "full" },
{ path: "login", component: LoginComponent, …Run Code Online (Sandbox Code Playgroud) 我想每10毫秒触发一次递归函数,但是无论我放什么,setTimeout似乎都不会取任何低于100的值.
decrementCountdown = function() {
console.log('fired');
t = setTimeout("decrementCountdown()", 100);
}
Run Code Online (Sandbox Code Playgroud)
为什么我不能设置1000毫秒以下的值?
编辑:看起来我的计时器正在正确触发...问题是当我用它来调用一个函数(如Jquery的html()).即使setTimeout以正确的间隔调用函数,它也不会以超过100毫秒的速度触发.
任何人都知道我如何在我的页面上倒数计时器倒计时10毫秒?
看看这段代码:
class MyClass():
# Why does this give me "NameError: name 'self' is not defined":
mySelf = self
# But this does not?
def myFunction(self):
mySelf2 = self
Run Code Online (Sandbox Code Playgroud)
基本上我想要一个类来引用自己而不需要专门命名自己的方法,因此我希望自己为类工作,而不仅仅是方法/函数.我怎样才能做到这一点?
编辑:这一点是我试图从类内部引用类名称与self之类的东西.class ._ name _这样类名在代码的任何地方都没有硬编码,因此重用代码更容易.
编辑2:从我从下面的答案中学到的,我想要做的是不可能的.我必须找到一种不同的方式.任务放弃了.
编辑3:这是我正在尝试做的事情:
class simpleObject(object):
def __init__(self, request):
self.request = request
@view_defaults(renderer='string')
class Test(simpleObject):
# this line throws an error because of self
myClassName = self.__class__.__name__
@view_config(route_name=myClassName)
def activateTheView(self):
db = self.request.db
foo = 'bar'
return foo
Run Code Online (Sandbox Code Playgroud) 如何格式化forEach函数,使其可以停留在多行而不会导致语法错误?就像是
self.request.db.myCollection.find().forEach(
function(u) {
u.forSong = self.request.db.song.find_one({}, {'_id': 1})
self.request.db.save(u)
})
Run Code Online (Sandbox Code Playgroud) 似乎一个直接指向图层,另一个指向框架,但它们在功能上有何不同?它们都确定了同一视图的位置......
我有两个我想要同步的NSTextViews.我正在使用ReactiveCocoa从它们的可可绑定中生成RACChannelTerminals.
RACChannelTerminal *terminal1 = [textView1 rac_channelToBinding:@"attributedString" options:@{ NSContinuouslyUpdatesValueBindingOption: @(YES) }];
RACChannelTerminal *terminal2 = [textView2 rac_channelToBinding:@"attributedString" options:@{ NSContinuouslyUpdatesValueBindingOption: @(YES) }];
Run Code Online (Sandbox Code Playgroud)
所以很自然地我认为下一步就是制作一个RACChannel,然后插入两个终端.
RACChannel *channel = [RACChannel new];
channel.leadingTerminal = terminal1;
channel.followingTerminal = terminal2;
Run Code Online (Sandbox Code Playgroud)
然后编译器说nope : Assignment to read only property. 看起来这应该是直截了当的,所以我在这里做错了什么?如何使用自己的终端创建类似RACChannel的绑定?
macos binding objective-c reactive-programming reactive-cocoa
我想要一个透明背景的threejs帆布.我正在创建一个这样的渲染器:
# coffeescript
r = new THREE.WebGLRenderer alpha: true
Run Code Online (Sandbox Code Playgroud)
当我打电话时r.render(),它按预期工作,对象出现在透明背景上.但是,当我尝试使用EffectComposer添加后处理时,如下所示:
cmp = new THREE.EffectComposer r
cmp.addPass new THREE.RenderPass scene, camera
effect = new THREE.FilmPass 0.9, 2, 2048, true
effect.renderToScreen = true
cmp.addPass effect
cmp.render 3
Run Code Online (Sandbox Code Playgroud)
新的结果是场景按预期渲染(对象正确应用了影片效果),除了背景不再是所需的透明...而是黑色和不透明.为什么?如何防止后期处理篡改我的透明背景?
我试图在不改变任何枢轴点的情况下制作一个带有三角形的六边形网格,但我似乎无法正确定位三角形以制作单个六边形。我正在SCNNodes创建UIBezierPaths三角形,然后旋转贝塞尔曲线路径。这似乎工作得很好,直到我尝试使用参数方程将三角形围绕圆定位以形成六边形,然后它们最终不会处于正确的位置。你能帮我找出我做错的地方吗?
class TrianglePlane: SCNNode {
var size: CGFloat = 0.1
var coords: SCNVector3 = SCNVector3Zero
var innerCoords: Int = 0
init(coords: SCNVector3, innerCoords: Int, identifier: Int) {
super.init()
self.coords = coords
self.innerCoords = innerCoords
setup()
}
init(identifier: Int) {
super.init()
// super.init(identifier: identifier)
setup()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
let myPath = path()
let geo = SCNShape(path: myPath, extrusionDepth: 0)
geo.firstMaterial?.diffuse.contents = UIColor.red
geo.firstMaterial?.blendMode = .multiply …Run Code Online (Sandbox Code Playgroud)