Skip to main content

Posts

Showing posts with the label web

Moving Items Along Bezier Curves with CSS Animation (Part 2: Time Warp)

This is a follow-up of my earlier article.  I realized that there is another way of achieving the same effect. This article has lots of nice examples and explanations, the basic idea is to make very simple @keyframe rules, usually just a linear movement, then use timing function to distort the time, such that the motion path becomes the desired curve. I'd like to call it the "time warp" hack. Demo See the Pen Interactive cubic Bezier curve + CSS animation by Lu Wang ( @coolwanglu ) on CodePen . How does it work? Recall that a cubic Bezier curve is defined by this formula : \[B(t) = (1-t)^3P_0+3(1-t)^2tP_1+3(1-t)t^2P_2+t^3P_3,\ 0 \le t \le 1.\] In the 2D case, \(B(t)\) has two coordinates, \(x(t)\) and \(y(t)\). Define \(x_i\) to the be x coordinate of \(P_i\), then we have: \[x(t) = (1-t)^3x_0+3(1-t)^2tx_1+3(1-t)t^2x_2+t^3x_3,\ 0 \le t \le 1.\] So, for our animated element, we want to make sure that the x coordiante (i.e. the "left" CSS property) is \(...

Moving Items Along Bezier Curves with CSS Animation (Part 1: Constructions)

TLDR: This article is NOT about cubic-bezier(), and it is not about layered CSS animations (for X and Y axes respectively). It is about carefully crafted combined animation, that moves an element along any quadratic/cubic Bezier curve. UPDATE: Here's the link to part 2 . Following my previous post , I continued investigating competing CSS animations, which are two or more CSS animations affecting the same property. I observed that two animations may "compete". In the following example, the box has two simple linear animations, move1 and move2. It turns out the box actually moves along a curved path: See the Pen CSS Bezier Path by Lu Wang ( @coolwanglu ) on CodePen . So clearly it must be the combined effects from both animations. Note that in move2, the `from` keyframe was not specified. It'd look like this if it is specified: See the Pen For Blog 2022-08-02 by Lu Wang ( @coolwanglu ) on CodePen . In this case, it seems only the second animation take...

Studying CSS Animation State and Multiple (Competing) Animations

[2022-08-04 Update] Most of my observations seems confirmed in the CSS animation spec . I stumped upon this youtube video . Then after some discussion with colleages,  I was really into CSS-only projects. Of course I'd start with a rotating cube: See the Pen CSS 3d Animation Test by Lu Wang ( @coolwanglu ) on CodePen . Then I built this CSS-only first person (rail) shooter: See the Pen CSS-Only Wolfenstein by Lu Wang ( @coolwanglu ) on CodePen . It was lots of fun. Especially I learned about the checkbox hack .  However there were two problems that took me long to solve. 1. Move from in the middle of an animation The desired effect is: An element is moving from point A to point B. If something is clicked, the element should move from its current state (somewhere between A and B, in the middle of the animation/transition) to another point C. This is for the last hit of the boss, the boss is fastly moving. I'd like the boss to slowly move to the center if being...

Notes 20130505

'tc' and 'netem' allow you to simulate some network environments http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution For example, I can delay every packet for 1s, such that in some case I can cheat in games. Google Chrome complains about "profile cannot be opened correctly": remove the 'web data' folder in the config dir http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html To remove PDF password with gs http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10 would ignore the `word-spacing` CSS rule if the width for the space char is 0, in a TTF font. Is it a bug of IE?

杂记 20130505

使用tc + netem可以模拟一些网络环境 http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delay_distribution 比如我可以让每个包都延迟1秒,某些情况下玩游戏还可以作弊 Google Chrome说Profile无法正确打开: 把配置目录里的'Web Data'目录干掉 http://www.fourleaftechnology.com/index.php/General/google-chrome-profile-could-not-be-opened-correctly-error.html 用gs去除PDF的密码: http://www.cyberciti.biz/faq/removing-password-from-pdf-on-linux/ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf IE10下如果TTF字体的空格宽度是0,就会无视word-spacing的css规则,不知道是不是IE的bug。

Webkit 下中文字体问题的解决 | Solution to the problem of unexpected Chinese fonts in webkit

也许是仅局限于webkitgtk 之前尝试epiphany的时候就发现了这个问题,但是由于epiphany对我来说只是一个备用浏览器,所以没管它。 今天给empathy搞adium主题时这个问题再次蹦了出来,我决定干掉它。 https://bugs.launchpad.net/ubuntu/+source/webkit/+bug/502610 这里有些讨论,里面有个链接指向了改fontconfig的办法,但是我想我这里并不是这个问题,因为我在~/.fonts.conf里已经之定好了我希望的中文字体(主要是serif, sans-serif, monosapce这几个列表),我还是觉得这个是webkit的问题。 empathy有个选项可以开启webkit debug模式:/apps/empathy/conversation/enable_webkit_developer_tools 我用它查看元素,发现字体总是sans...目前解决方法是手工改css,找到.msg的定义,加入 font-family: "font name 1", "font name 2"; 另外就是epiphany,虽然它不能给各个语言指定字体,但是好歹支持用户css,于是加入如下内容: @charset "UTF-8"; // 如果字体名有中文 * { font-family: "font name 1", "font name 2" ! important; } 这样问题基本可以解决 Or maybe it's only a bug for webkitgtk, I'm not sure. Days before I encountered this bug when I was trying epiphany, but I didn't pay much attention on it since I use it only as a backup one. However today the bug came out and started to trouble me again when I was applying an adium theme for empa...

本地 flash 与 html 交互

Flash提供了几个与html交互的接口, 如getURL,fscommand和ExternalInterface. 不过由于FlashPlayer的安全设置, 本地flash与html交互受到很大限制. 如果不做设置,我这里的情况是只有getURL可以用,其他两种都不行(IE和firefox),非常郁闷 当然可以上Adobe网站的安全设置管理器来更改信任设置,经过一番研究,终于发现设置文件存放在 C:\Documents and Settings\<UserName>\Application Data\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\settings.sol (Windows) Linux的还没研究过 另外,该文件具体格式也没有研究. 设置了本地信任(指定flash所在目录)后,ExtrenalInterface终于可以用了,不过fscommand只能在IE里用...不知道为什么, 不过足够了, ExternalInterface可比fscommand强大多了. 不过问题终究还是安全问题,唉,安全和用户体验总是矛盾的吧...

控制台下浏览器 links2

以前我知道的控制台下的浏览器只有lynx,和w3m.而且我觉的w3m明显比lynx好用. 不过人的欲望是无止境的,对于软件,总是希望更多更好的功能. w3m-img和zhcon的冲突好像是众所周知了,而我这ubuntu控制台,即使没用zhcon, w3m也看不了图片. 今天发现了links2这个浏览器,支持图片和javascript!!简直就是惊喜,看上去几乎就是个图形程序. 但是!它先天不支持中文,唉,作者也真是的... 不过以后看英文网站就铁定是它了.

w3m 上 GMail

其实以前知道可以了,不过一直不知道怎么弄 后来知道了要进Plain HTML模式,然后查到了地址 https://mail.google.com/mail?ui=html 这篇文章就是用w3m发过来的 :) 注意设好外部编辑器,我当然用vim了

Firefox 中 xmlhttprequest 跨域访问

今天要写一个小爬虫,用xmlhttprequest批量抓取一个图片集的链接,不过firefox有安全限制,对跨域访问有限制,需要权限提升。 记得在《Ajax in Action》曾看到过,现在忘了,在网上竟然查了半天才找到,(原以为Google第一个就是呢) 只需在xmlhttprequest作用域内加入 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 即可。 参考: http://www.captain.at/howto-ajax-permission-denied-xmlhttprequest.php

[转]53 CSS-Techniques You Couldn’t Live Without

很漂亮 //原文   53 CSS -Techniques You Couldn’t Live Without 53个 CSS -不可或缺的技巧 QUOTE: CSS is important. And it is being used more and more often. Cascading Style Sheets offer many advantages you don’t have in table-layouts - and first of all a strict separation between layout, or design of the page, and the information, presented on the page. Thus the design of pages can be easily changed, just replacing a css-file with another one. Isn’t it great? Well, actualy, it is. CSS 是重要的,它正在越来越广泛的被运用。层叠样式表拥有很多表格布局所没有的优势,首先从布局或者页面的设计与出现在页面中的信息中作严格的分离,从而让页面的设计能够很容易被改变,仅用一个 CSS 文件更换另一个。难道它不够强大吗?恩,是的,其实它很强大。 QUOTE: Over the last few years web-developers have written many articles about CSS and developed many useful techniques, which can save you a lot of time - of course, if you are able to find them in time. Below you’ll find a list of techniques we , as web-architects, really couldn’t live without. They are essential and they indeed make our life easier. Let’...