<<-DOC 函数原型: int bitmapDrawScanH(int bitmap_obj_id, int color0_obj_id, int color1_obj_id) 函数作用: 以color0,color1进行HSL渐变,水平填充至bitmap的最后一行, 作为颜色源数据给相关需求调用。 使用示例: proc = Win32API.new('color.dll', 'bitmapDrawScanH', 'LLL', 'L') src_bitmap = Bitmap.new(180, 1) color0 = Color.new(255, 0, 0, 128) color1 = Color.new(0, 255, 0, 255) proc.call(src_bitmap.object_id, color0.object_id, color1.object_id) #src_bitmap.dispose 应用示例:见Bitmap#fill_ellipse3 函数原型: int bitmapFillTextH(int bitmap_obj_id, int color0_obj_id, int color1_obj_id) 函数作用: 初始化的bitmap,绘制文字后, 以color0,color1的HSL渐变,水平填充至绘制的字体。 使用示例: proc = Win32API.new('color.dll', 'bitmapFillTextH', 'LLL', 'L') src_bitmap = Bitmap.new(180, 32) src_bitmap.draw_text(0, 0, 180, 32, "文字测试") color0 = Color.new(255, 0, 0, 128) color1 = Color.new(0, 255, 0, 255) proc.call(src_bitmap.object_id, color0.object_id, color1.object_id) #src_bitmap.dispose 应用示例:见Bitmap#draw_text_ex 示意图: bitmap = Bitmap.new(640, 480) color0 = Color.new(255, 0, 0, 128) color1 = Color.new(0, 0, 255) bitmap.fill_ellipse3(320, 240, 300, 200, 0, Color.new(0,0,0), color0, color1) bitmap.draw_text_ex(200, 200, "文字测试", color0, color1) DOC class Bitmap DrawScanH = Win32API.new('color.dll', 'bitmapDrawScanH', 'LLL', 'L') FillTextH = Win32API.new('color.dll', 'bitmapFillTextH', 'LLL', 'L') #-------------------------------------------------------------------- # cx 椭圆中心点X 基本整型 # cy 椭圆中心点Y 基本整型 # ax 椭圆X半轴长度 无符号整型 # by 椭圆Y半轴长度 无符号整型 # mode 椭圆颜色填充方向(0:左->右;1:上->下) 无符号整型 # color 椭圆边框颜色 RMXP的Color实例对象 # fillB 椭圆填充的起始颜色 RMXP的Color实例对象 # fillE 椭圆填充的终止颜色 RMXP的Color实例对象 或 nil(单色填充) #-------------------------------------------------------------------- def fill_ellipse3(cx, cy, ax, by, mode, color, fillB, fillE=nil) if fillE if mode == 0 step = ax + ax + 1 src_rect = Rect.new(0, 0, 0, 0) else step = by + by + 1 end src = Bitmap.new(step, 1) DrawScanH.call(src.object_id, fillB.object_id, fillE.object_id) else mode = 1 if mode = 0 end ratio, w2 = ax.to_f / by, 0 (by).downto(1) do |y| w = (Math.sqrt((by + y) * (by - y)) * ratio).round if fillE if mode == 1 self.fill_rect(cx - w, cy - y, w + w, 1, src.get_pixel(by - y, 0)) self.fill_rect(cx - w, cy + y, w + w, 1, src.get_pixel(by + y, 0)) else src_rect.set(ax - w, 0, w + w, 1) self.blt(cx - w, cy - y, src, src_rect) self.blt(cx - w, cy + y, src, src_rect) end else self.fill_rect(cx - w, cy - y, w + w, 1, fillB) self.fill_rect(cx - w, cy + y, w + w, 1, fillB) end self.set_pixel(cx - w, cy - y, color) self.set_pixel(cx + w, cy - y, color) self.set_pixel(cx - w, cy + y, color) self.set_pixel(cx + w, cy + y, color) while w2 < w self.set_pixel(cx - w2, cy - y - 1, color) self.set_pixel(cx + w2, cy - y - 1, color) self.set_pixel(cx - w2, cy + y + 1, color) self.set_pixel(cx + w2, cy + y + 1, color) w2 += 1 end end if fillE if mode == 1 self.fill_rect(cx - ax, cy, ax + ax + 1, 1, src.get_pixel(by, 0)) else self.blt(cx - ax, cy, src, src.rect) end else self.fill_rect(cx - ax, cy, ax + ax + 1, 1, fillB) end self.set_pixel(cx - ax, cy, color) self.set_pixel(cx + ax, cy, color) src.dispose if src end def draw_text_ex(x, y, text, color0, color1) rect = self.text_size(text) temp = Bitmap.new(rect.width, rect.height) temp.draw_text(rect, text) FillTextH.call(temp.object_id, color0.object_id, color1.object_id) self.blt(x, y, temp, rect) temp.dispose end end
示意图.png (13.24 KB, 下载次数: 17)
示意图
7.43 KB, 下载次数: 10
color.dll
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |