SubOne.org

Welcome Guest! Log in or Register.

Archive for September, 2008

CSS3 Suggestion

Sunday, September 28th, 2008

Is it too late to request something like ‘background-position-x’ and ‘background-position-y’ to be added to the CSS3 spec? These would be extremely useful in cutting down the amount of code needed when the X position of the background needs to be as previously set but the Y needs to be changed.

This is useful for sprite techniques. For example, say you have a single image with a bunch of icons in a matrix. Different icons are represented horizontally in the image and different styles of those images (e.g. hover, selected,disabled) are represented vertically. So, now you can style all elements that contain icons with the ‘icon’ class which defines the background-image. Then add an additional class to each of these based on which icon it represents, which would change the background-position-x to display the appropriate icon image. Finally, you would have addition rules that define current state of the icon, such as a ‘select’ class or a ‘.icon:hover’, which would change the background-position-y.

An example of 5 icons with 3 states (e.g. normal, hover, selected) would require 15 different rules as follows:

.icon {
  background: url('images/icons.png') 0 0 no-repeat;
  width: 16px;
  height: 16px;
}
.icon1:hover {
  background-position: 0 -16px;
}
.icon1.selected {
  background-position: 0 -32px;
}
.icon2 {
  background-position: -16px 0;
}
.icon2:hover {
  background-position: -16px -16px;
}
.icon2.selected {
  background-position: -16px -32px;
}
.icon3 {
  background-position: -32px 0;
}
.icon3:hover {
  background-position: -32px -16px;
}
.icon3.selected {
  background-position: -32px -32px;
}
.icon4 {
  background-position: -48px 0;
}
.icon4:hover {
  background-position: -48px -16px;
}
.icon4.selected {
  background-position: -48px -32px;
}
.icon5 {
  background-position: -64px 0;
}
.icon5:hover {
  background-position: -64px -16px;
}
.icon5.selected {
  background-position: -64px -32px;
}

Whereas with the background-position-x/-y properties it would only need the following 7 rules:

.icon {
  background: url('images/icons.png') 0 0 no-repeat;
  width: 16px;
  height: 16px;
}
.icon2 {
  background-position-x: -16px;
}
.icon3 {
  background-position-x: -32px;
}
.icon4 {
  background-position-x: -48px;
}
.icon5 {
  background-position-x: -64px;
}
.icon:hover {
  background-position-y: -16px;
}
.icon.selected {
  background-position-y: -32px;
}

Of course, the more sprites used the more redundancy is needed without the use of a background-position-x/-y. Without separate X and Y properties it takes i*s rules, where i represents the number of icons and s represents the number of states. With them it would only take i+s-1. The benefits are obvious.

Motorola S9 Fix

Saturday, September 27th, 2008

So I bought these really nice wireless bluetooth stereo headphones from Motorola back about a month ago. I opened the package while I was out and about and promptly made the huge mistake of just throwing out the packaging and reciept after making sure they work with my BlackBerry Curve. They are pretty sweet, and not too expensive for the convinience of being able to control volume up/down, track back/forward, initialize voice calling, and play/pause right from the touch of an ear peice.

The problem? They were broken and I didn’t even know it! That is until I started fiddling with them and hit the volume down button. I quickly found my volume at the lowest setting. Cool, nice feature, but wait, where’s the volume up button? I took them off and sure enough I was hitting the right button. Nothing is happening! Now they are stuck at the lowest volume setting and its the volume on the headset not on the phone.

So, I tossed them into a box for a while until I finally sat down and took out a handy soldering iron and started to strip a few wires and make some connections. I’m no electronics genious or anything, but I guessed right that black is always ground and found that the red wire is for the voice dial initialization. After accidentally ripping that wire out (no matter, since I planned to cut the activation strip off the earpiece so that this wouldn’t happen again) I found the yellow wire on my second attempt. The yellow wire was indeed the volume up!

I then soldered a hole right through the volume up and down connectors before remembering I cut out by accident. No worries, one day I’ll get around to repairing it and the connector is still there, so it will work.

Apparently this is a common issue with these headphones. Whether it just be sweat interfering and/or frying connections or, in my case, the circuit was just torn to bits when I got them. I didn’t check all the wires since I got it on my second try, but maybe I will later. Nonetheless, anyone that has these now has a partial pinout! Black is ground, red is voice, yellow is volume up. Comment with more if you’ve got them 😀