html - 在 ahk/html 脚本中更改图像颜色

标签 html css autohotkey

我目前正在使用 autohotkey 创建游戏。我想在这个游戏中包含图片,并想更改它们的颜色和背景。

我已经尝试了几件事,到目前为止,所有这些都会在自动热键窗口中产生问题。

任何类型的过滤器似乎都不起作用。甚至在彩色图像上也不行

更改 Canvas 中的颜色非常慢(每张图像需要 30 秒到 5 分钟)

我尝试将图像转换为 svg,但到目前为止,我发现所有网站都会将图像更改为我不想要的更矢量化的外观。

我现在尝试的解决方案是将图片转换为字体并以这种方式更改其颜色,但是在我的计算机上执行各种操作只会阻止脚本加载字体,直到我重新启动我的电脑。一个例子是在我的电脑上保存一张图片。

这是我现在尝试使用的测试脚本、字体和 html 文件的链接 Link

Autohotkey 脚本。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
htmlpath := A_scriptdir . "\Htmlfile.html"
gui Picture_Loader:default
gui, add, edit, h0 w0
gui, font, s10
gui +Border +lastfound
menuwidth := A_screenwidth / 3
menuheight := A_screenheight / 2

Gui, Add, ActiveX, x0 y0 w%menuwidth% h%menuheight% vmenu, Shell.Browser
menu.navigate(htmlpath)
gui, show
return

F11::
Reload
return

HTML文件

<!DOCTYPE html>
<html>
    <head>
        <title>a</title>
        <meta charset='UTF-8'>
        <meta name='viewport' content='width=device-width, initial-scale=1.0'>
        <meta http-equiv='X-UA-Compatible' content='ie=edge'>
        <style type=text/css>
            html {
                overflow:hidden;
                height:100%;
            }
            body {
                background:#888888;
                width:100%;
                height: 100%;
            }
            @font-face {
                font-family:'Myfont';
                src:url('opensans-bold.woff') format('woff');
            }
            .custom{
                font-family:'Myfont';
            }
        </style>
    </head>
    <body>
        <p class='custom'>Aa</p>
    </body>
</html>

如果有人能解决我的任何问题。请告诉我。一种使字体始终如一地工作的方法,一个将图像转换为 svg 而不更改它们的站点,或者将 Canvas 颜色加速到可管理水平的站点都可以解决这个问题。问题

最佳答案

您似乎正在尝试使用 AutoHotkey 制作一个在 Windows 上运行的基于 js/html 的游戏。你可能想看看 webapp.ahk或更一般的 tutorial旨在帮助解决此类问题。如果你要做更多的图形专用编程,最好使用像GDI+这样的东西。甚至是预制的 AHK 基于图 block 的游戏引擎,例如 Project 2D .对于字体问题,您可能必须使用绝对路径。如果可能,请尝试使用您知道可以正常工作的字体来测试它,例如来自 FontSquirrel 的字体。 .另一种选择可能是使用 SVG 格式字体代替或尝试将其转换为 TTF。

无论哪种方式,这里都是操作图形的选项:

  • SVG 图形:您可以使用 js SVG 库,例如 SVG.js做动画工作等。
  • js Canvas :将资源导入 Canvas 并从那里修改内容,或者
  • 使用 GDI+ 等系统图形来完成所有工作。

关于html - 在 ahk/html 脚本中更改图像颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53816237/

相关文章:

CSS !important 在使用 ajax 的 ie7 中不起作用

.net - 无法使用 AutoHotkey 关闭某些进程

expression - Autohotkey 单行代码?

css - 如何转义Less中的内置函数?

windows - 如何使 Autohotkey 在启动时自动运行?

html - 在React中有条件地添加表n+1表行(<tr>)

Javascript 代码无法在我的表单上运行

html - 在按钮的右下角放置文本

html - 删除标题和页面之间的空间

CSS 使背景图像错位