首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏tkokof 的技术,小趣及杂念

    Sweet Snippet 之 Bounce Setting

    问题   程序中有时会用到所谓Bounce Setting这种技巧,目的是为了解决一些变量的“来回”设置问题,譬如一个布尔变量,最直观的Bounce Setting方法大概是这个样子: if (boolFlag 总会不自觉的想起这个简洁美观的表达方式,近日在这里也看到了类似的代码,不过其中使用了整形变量1和0,相关的代码大概是这个样子: value = 1 - value;   看到之后突然觉得自己以前一直囿于布尔变量取非这么一种Bounce  Setting的形式,而实际上,像上述的这种表达方法也是不错的思路,那么对于任意整数A、B,是否总是存在类似的这种表达式来优雅的完成Bounce Setting呢? 不知你看到这个表达式有什么想法,反正我是觉得挺好笑的,本来以为会是一个稍有繁复的公式,不想却是一个简单的能够一眼望穿的家伙,而自己一开始竟然也毫无察觉,着实好笑 :)   废话打住,依据上述公式,任意整数间的Bounce

    35710发布于 2018-08-02
  • 来自专栏数据结构与算法

    BZOJ2002: Bounce 弹飞绵羊(LCT)

    Time Limit: 10 Sec  Memory Limit: 259 MB Submit: 13753  Solved: 6983 [Submit][Status][Discuss] Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹

    48200发布于 2018-05-30
  • 来自专栏万少的技术分享

    H5 带你实现弹弹球

    用来实现弹跳小球 Baffle 用来实现底部的挡板 Game 用来控制小球和挡板 // 用于控制小球和挡板 class Game {} // 小球 class Bounce + this.bounce.radius >= this.baffle.x && this.bounce.x <= this.baffle.x + this.baffle.width; const isBetweenY = this.bounce.y + this.bounce.radius >= this.baffle.y; return isBetweenX & + this.bounce.radius >= this.baffle.x && this.bounce.x <= this.baffle.x + this.baffle.width ; const isBetweenY = this.bounce.y + this.bounce.radius >= this.baffle.y;

    27900编辑于 2025-02-11
  • 来自专栏C语言入门到精通

    C语言 | 自由落地,求第10次落地共经过多少米

    源代码演示: #include<stdio.h>//头文件  int main()//主函数  {   double height,bounce_Height;//定义双精度浮点型变量    height =100;//赋初值    bounce_Height=height/2;//赋初值    int n;//定义整型变量    for(n=2;n<=10;n++)   {     height=height +2*bounce_Height;//第n次落地时共经过的米数      bounce_Height=bounce_Height/2;//第n次反跳高度    }    printf("第10次落地时共经过 %f米\n",height);   printf("第10次反弹%f米\n",bounce_Height);   return 0;  } 编译运行结果如下: 第10次落地时共经过299.609375米

    1.1K88发布于 2021-01-10
  • 来自专栏鲸鱼动画

    JS--你没玩过的激流勇进

    */ var bounce = 0; if (left1.solid && left1.bounce > bounce) bounce = left1.bounce ; if (left2.solid && left2.bounce > bounce) bounce = left2.bounce; if (right1.solid & & right1.bounce > bounce) bounce = right1.bounce; if (right2.solid && right2.bounce > bounce) = top1.bounce; if (top2.solid && top2.bounce > bounce) bounce = top2.bounce; if (bottom1 .solid && bottom1.bounce > bounce) bounce = bottom1.bounce; if (bottom2.solid && bottom2.bounce

    71420发布于 2020-09-21
  • 来自专栏蚂蚁开源社区

    html5 canvas走出迷宫小游戏,代码简洁,适合学习

    */ var bounce = 0; if (left1.solid && left1.bounce > bounce) bounce = left1.bounce; right1.bounce > bounce) bounce = right1.bounce; if (right2.solid && right2.bounce > bounce) bounce */ var bounce = 0; if (top1.solid && top1.bounce > bounce) bounce = top1.bounce; if (top2.solid && top2.bounce > bounce) bounce = top2.bounce; if (bottom1.solid && bottom1.bounce > bounce) bounce = bottom1.bounce; if (bottom2.solid && bottom2.bounce > bounce) bounce = bottom2

    2.7K10发布于 2019-12-24
  • 来自专栏学海无涯

    iOS17适配指南之弹簧动画

    class func animate(springDuration duration: TimeInterval = 0.5, bounce bounce:弹性系数,取值范围 0 ~ 1,数值越大弹性效果越明显。 initialSpringVelocity:初始速度,数值越大初始速度越快。 delay:动画延迟执行的时间。 UIView动画 func animate() { // 3个不同参数的弹簧动画对比 UIView.animate(springDuration: 1.5, bounce 0) { self.redView.center.y = 300 } UIView.animate(springDuration: 1.5, bounce self.greenView.center.y = 300 } UIView.animate(springDuration: 1.5, bounce

    94220编辑于 2023-07-09
  • 来自专栏守候书阁

    编写自己的代码库(css3常用动画的实现)

    ">bounce-t bounce-b bounce-l</span , .ech-bounce-b, .ech-bounce-r, .ech-bounce-l { position: relative; transition: all .3s; :before, .ech-bounce-b:before, .ech-bounce-r:before, .ech-bounce-l:before { transition: all .3s; html bounce css .ech-bounce:hover { animation: bounce 1s ease; } { animation: bounce-in-b 1s; } .ec-bounce-in-t{ animation: bounce-in-t 1s; } @keyframes bounce-in-t

    1.5K20发布于 2018-08-22
  • 来自专栏学院君的专栏

    给 Vue 模态框组件添加过渡和动画效果

    confirm-modal-backdrop" v-show="showModal">

    </template> 二、‍‍动画效果 放大缩小 除了上述过渡效果,还可以设置动画效果,以 Vue 官方文档提供的 bounce 为例(这是一种放大缩小的动画效果,即以渐次放大的方式打开模态框,以渐次缩小的方式关闭模态框) ,调整 ConfirmModal 组件代码如下: <style scoped> ... .bounce-enter-active { animation: bounce-in .5s; } .bounce-leave-active { animation: bounce-in .5s reverse; } @keyframes bounce-in { 0% { transform: scale(0); } 50% { transform: scale(1.5); transform: scale(1); } } </style> <template>
    <transition name="<em>bounce</em>

    1.9K20编辑于 2023-03-03
  • 来自专栏jQuery每日经典

    比 Animation.css 还要炫酷的动画库插件

    text/css" rel="stylesheet"> <script src="dist/js/micron.min.js">script>  HTML结构 例如你需要为一个按钮制作bounce 这是一个按钮 a> 你还可以通过data-micron-duration属性来控制CSS3 可用的easing效果有: linear ease-in ease-out ease-in-out <a href="#" class="button" data-micron="<em>bounce</em> 例如: <a href="#" class="button" data-micron="<em>bounce</em>" data-micron-bind="true" data-micron-id micron="shake" micron="fade" micron="jelly" micron="<em>bounce</em>" micron="tada" micron="groove" micron="swing

    98110编辑于 2022-01-20
  • 来自专栏鲸鱼动画

    JS新版激流勇进附地图详解

    */ var bounce = 0; if (left1.solid && left1.bounce > bounce) bounce = left1.bounce ; if (left2.solid && left2.bounce > bounce) bounce = left2.bounce; if (right1.solid & & right1.bounce > bounce) bounce = right1.bounce; if (right2.solid && right2.bounce > bounce) = top1.bounce; if (top2.solid && top2.bounce > bounce) bounce = top2.bounce; if (bottom1 .solid && bottom1.bounce > bounce) bounce = bottom1.bounce; if (bottom2.solid && bottom2.bounce

    2.3K20发布于 2020-09-21
  • 来自专栏菩提树下的杨过

    Flash/Flex学习笔记(31):对象拖拽与投掷

    Sprite { private var ball:Ball; private var vx:Number; private var vy:Number; private var bounce ; } else if (ball.x - ball.radius < left) { ball.x=left+ball.radius; vx*=bounce; } //垂直方向边界检测 if (ball.y+ball.radius>bottom) { ball.y=bottom-ball.radius; vy*=bounce; } else if (ball.y - ball.radius < top) { ball.y=top+ball.radius; vy*=bounce; } } private ; } else if (ball.x - ball.radius < left) { ball.x=left+ball.radius; vx*=bounce; }

    77390发布于 2018-01-23
  • 来自专栏Dimples开发记

    transition过渡&动画

    show">切换</button> <transition name="<em>bounce</em>">

    文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容文字内容

    </transition>
    CSS .bounce-enter-active { animation: bounce-in .5s; } .bounce-leave-active { animation: bounce-in .5s reverse; } @keyframes bounce-in { 0% { transform: scale(0); }

    1.3K10编辑于 2022-12-21
  • 来自专栏HTML5学堂

    一步步教你弹性框架-下篇

    获取运动块 var timer = null; // 初始化一个计时器 var speed = 0; // 初始化一个速度 btn.onclick = function(){ bounce (move, "marginLeft", 600) } function bounce(ele, prop, targetVal) { var startVal = parseInt(getStyle // 获取控制按钮 var move = document.getElementById("move"); // 获取运动块 btn.onclick = function(){ bounce (move, "marginLeft", 600) } function bounce(ele, prop, targetVal) { var startVal = parseInt(getStyle (move, "marginLeft", 600); btn.judge = true; }; } function bounce(ele, prop, targetVal) {

    1K40发布于 2018-03-12
  • 来自专栏帮你学MatLab

    500行代码实现pong游戏

    MESSAGE_CONTROLS]); end end %------------重置------------ %恢复初始值 function resetGame bounce ([newX - PLOT_W, newY - GOAL_TOP]); else %右墙余下部分 bounce([-1 * abs(ballVector ([newX, newY - GOAL_TOP]); else %左墙余下部分 bounce([abs(ballVector(1)), ballVector (2)]); end %顶部 elseif (newY > (PLOT_H - BALL_RADIUS)) bounce([ballVector(1) , -1 * (Y_FACTOR + abs(ballVector(2)))]); %底部 elseif (newY < BALL_RADIUS) bounce([

    1K20发布于 2019-04-30
  • 来自专栏张家辉的树屋

    CSS3: animate 帧动画和雪碧图-完成一个盒子打开动画

    keyframes #{$animationName} { @content; } } // 由于是 translate 布局,这里改变定位使用 translate @mixin animate-bounce ($name:'bounce', $time: 1.5s, $animateFunc: linear) { animation: $name $time ? 62%; transform: translate(-20%, -50%) rotateZ(26deg); } } } } // 盒子弹跳 .box-bounce { @include animate-bounce('bounce'); } .box-cover-fly{ @include animate-box-cover-fly('box-cover-fly

    1.9K20发布于 2021-02-02
  • 来自专栏蚂蚁开源社区

    HTML5+CSS3响应式垂直时间轴,高端,大气

    { visibility: visible; -webkit-animation: cd-bounce-1 0.6s; -moz-animation: cd-bounce-1 0.6s; animation { visibility: visible; -webkit-animation: cd-bounce-2 0.6s; -moz-animation: cd-bounce-2 0.6s; animation : cd-bounce-2 0.6s; } } @media only screen and (min-width: 1170px) { /* inverse bounce effect on even content blocks */ .cssanimations .cd-timeline-block:nth-child(even) .cd-timeline-content.bounce-in { -webkit-animation: cd-bounce-2-inverse 0.6s; -moz-animation: cd-bounce-2-inverse 0.6s; animation: cd-bounce

    2.3K20发布于 2019-08-09
  • 来自专栏IMWeb前端团队

    前端如何呼风唤雨

    ctx.arc(this.pos.x, this.pos.y, this.radius, 0, Math.PI*2); ctx.fill(); } }; bounce 下落落地反弹对象, 即上面雨水反弹的水滴, 你也可后期拓展为反弹的碎石片或者烟尘 定义的十分简单,这里就不做详细说明 var Bounce = function(x, y) { var dist ,则需要在drops数组中清楚该实例对象 if (drop.pos.y >= canvas.height) { //如果需要回弹,则在bouncess数组中加入bounce = bounces[i]; bounce.update(); bounce.draw(); if (bounce.pos.y > 最后说下不足的地方和后期的工作哈: 0、该组件目前对外接口不够多,可调节的范围并不是很多,抽象不是很彻底 1、 setStyle 设置 基本样式 2、 Drop 和Bounce 对象的 update 和

    57210发布于 2019-12-03
  • 来自专栏互联网杂技

    创建弹窗

    ){//结束之后删除div $(".mask").remove(); },2000);}) }) }) //抖动(shake) //闪烁(flash) // 弹跳(bounce flip) // 旋转(rotateIn/rotateOut) // 淡入淡出(fadeIn/fadeOut) // 缩放(zoom) // animated 类似于全局变量,它定义了动画的持续时间;bounce 有些动画效果最后会让元素不可见,比如淡出、向左滑动等等,可能你又需要将 class 删除,比如: //$(function(){ // $('#dowebok').addClass('animated bounce '); // setTimeout(function(){ // $('#dowebok').removeClass('bounce'); // }, 1000); //}); });

    2.7K50发布于 2018-04-02
  • 来自专栏我和未来有约会

    [Silverlight动画]转向行为 - 机车

    边缘行为 /// public const string WRAP = "wrap"; public const string BOUNCE = "bounce"; public Vehicle() { _postion = new Vector2D(0, 0); == WRAP) { wrap(); } else if (_edgeBehavior == BOUNCE ) { bounce(); } x = position.x; y = _position = _position.add(_velocity); 接着检测是否在边缘,是的话调用wrap或者bounce函数。

    1.1K60发布于 2018-01-16
  • 领券