Created
April 27, 2021 08:38
-
-
Save lihaochen910/ac4e1068dbf35dce6fcb8046f0434fa9 to your computer and use it in GitHub Desktop.
使用这个脚本来快速生成随机的V大的临摹单个颜色练习(4x5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 使用这个脚本来快速生成随机的V大的临摹单个颜色练习(4x5) | |
require 'RMagick' | |
def gen_color_sketch( input, output ) | |
img = Magick::Image.read( input ).first | |
columns = 4 | |
rows = 5 | |
r = 200 | |
columns.times do |column| | |
rows.times do |row| | |
color = "#%02X%02X%02X" % [rand( 255 ), rand( 255 ), rand( 255 )] | |
x, y = 500 + (column * r + column * 690) * 2, 500 + row * r + row * 735 | |
gc = Magick::Draw.new | |
gc.fill_opacity 1 | |
gc.fill color | |
gc.circle( x, y, x - r, y ) | |
gc.draw img | |
end | |
end | |
img.write( output ) { | |
self.quality = 50 # 1~100 | |
} | |
puts img.inspect | |
end | |
5.times do |n| | |
gen_color_sketch "/Users/Kanbaru/Downloads/第1周/第1天/4.临摹单个颜色的副本.jpg", "/Users/Kanbaru/Downloads/第1周/第1天/4.临摹单个颜色_gen_#{n + 1}.jpg" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment