小编red*_*100的帖子

使用 Jquery 获取点击图像的坐标

我有一个调整大小的图像(宽度=“100”)和一个 jquery 脚本,用于在单击该图像时输出当前坐标。

<img id="image" src="http://localhost/image.jpg" width="100"  >

<script>
   $('#image').mousemove( function(event) {
     window.current_x = Math.round(event.pageX - $('#image').offset().left) ;
     window.current_y = Math.round(event.pageY - $('#image').offset().top);
     window.current_coords = window.current_x + ', ' + window.current_y;
     $('#edit_instants_now').html('Current position: ' + window.current_coords + '.');
   }).mouseleave( function() {
     $('#edit_instants_now').html('&nbsp;');
   }).click( function() {
     $('#edit_instants_click').html('Last click: ' + window.current_coords + '. ');
     document.edit_instant.edit_instant_x.value = window.current_x;
     document.edit_instant.edit_instant_y.value = window.current_y;
   });
</script>
Run Code Online (Sandbox Code Playgroud)

问题是我想获得原始图像的实际坐标,而不是调整大小的坐标。

你有什么建议吗?谢谢。

html javascript css jquery

5
推荐指数
1
解决办法
2054
查看次数

Arduino - 将HEX转换为RGB的奇怪行为

我正在尝试将HEX颜色代码转换为RGB但是当我在Arduino上运行代码时,它不会拾取RED.

难道我做错了什么?

在C++编译器上工作得很好.

void setup() {

    Serial.begin(115200);

    String hexstring = "B787B7";
    int number = (int) strtol( &hexstring[1], NULL, 16);
    int r = number >> 16;
    int g = number >> 8 & 0xFF;
    int b = number & 0xFF;

    Serial.print("red is ");
    Serial.println(r);
    Serial.print("green is ");
    Serial.println(g);
    Serial.print("blue is ");
    Serial.println(b);

}

void loop() {

}
Run Code Online (Sandbox Code Playgroud)

rgb hex arduino

3
推荐指数
2
解决办法
3660
查看次数

标签 统计

arduino ×1

css ×1

hex ×1

html ×1

javascript ×1

jquery ×1

rgb ×1