Last active
October 28, 2023 17:07
-
-
Save tompng/696e978363535ce7289d105a2200b226 to your computer and use it in GitHub Desktop.
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
,,,;;;;''''';;;'';, | |
,,;'' ';;,;;; ', | |
,,'' ;;'';'''';;;;;; | |
,;' ;; ',, ; | |
,;' ,;' ';, ; | |
;' ,;; ',,,; | |
,' ,;;,,,,,,,,,,,;;;; | |
;' ;;';;;; ,;; | |
;' ,;' ;; '',, ,;;; | |
;; ,;' ; '';, ,; ;' | |
;; ,;;' ;; ;; ;; | |
;;, ,,;;' ; ;'; ;; | |
;';;,,,,;;;;;;;,,, ;; ,' ; ;; | |
; ;;''' ,;'; ''';,,, ; ,;' ;;;; | |
;;;;, ; '; ''';;;' ';;; | |
;'; ;, ;' '; ,;' ', ;;; | |
;;; ; ,; '; ,,' ',, ;; | |
;;; '; ;' ';,,'' ';,;; | |
'; ';,; ,,;''''''''';;;;;;,,;;; | |
';,,;;,,;;;;;;;;;;'''''''''''''' | |
⣀⣤⣴⣾⣿⣿⣿⡛⠛⠛⠛⠛⣻⣿⠿⠛⠛⠶⣤⡀ | |
⣀⣴⠾⠛⠉⠁ ⠙⣿⣶⣤⣶⣟⣉ ⠈⠻⣦ | |
⣀⣴⠟⠋ ⢸⣿⠟⠻⣯⡙⠛⠛⠛⠶⠶⠶⢶⣽⣇ | |
⣠⡾⠋⠁ ⣾⡿ ⠈⠛⢦⣄ ⣿ | |
⣠⡾⠋ ⣰⣿⠃ ⠙⠷⣤⡀ ⣿ | |
⢀⡾⠋ ⣰⣿⡏ ⠈⠻⣦⣄⢠⣿ | |
⣰⠟⠁ ⣴⣿⣿⣁⣀⣠⣤⣤⣤⣤⣤⣤⣤⣴⠶⠿⣿⡏ | |
⣼⠏ ⢀⣾⣿⠟⣿⠿⣯⣍⠁ ⣰⣿⡇ | |
⢀⣼⠋ ⢀⣴⣿⠟⠁ ⢸⡇ ⠙⠻⢦⣄⡀ ⢠⡿⣿⡇ | |
⢀⣾⡏ ⢀⣴⣿⠟⠁ ⣿ ⠉⠻⢶⣄⡀⣰⡟ ⣿⠃ | |
⣾⣿⠁ ⣠⣶⡿⠋⠁ ⢹⡇ ⠈⣿⡏ ⢸⣿ | |
⣿⣿⡆ ⢀⣠⣴⣿⡿⠋ ⠈⣿ ⢀⡾⠋⣿ ⢸⣿ | |
⣿⠸⣿⣶⣤⣤⣤⣤⣶⣾⠿⠿⣿⣿⠶⣤⣤⣀⡀ ⢹⡇ ⣴⠟⠁ ⣿⡀⢸⣿ | |
⣿⢀⣿⣟⠛⠋⠉⠁ ⢰⡟⠹⣧ ⠈⠉⠛⠻⠶⢦⣤⣀⡀ ⠈⣿ ⣠⡾⠃ ⢸⡇⢸⡇ | |
⣿⣾⣿⢿⡄ ⣿⠁ ⠘⣧ ⠉⠙⠛⠷⣿⣿⡋ ⠸⣇⣸⡇ | |
⣿⠃⣿⠈⢿⡄ ⣸⠇ ⠘⣧ ⢀⣤⠾⠋⠈⠻⣦⡀ ⣿⣿⡇ | |
⣿⢸⡏ ⠈⣷⡀ ⢠⡿ ⠘⣧⡀ ⣠⡴⠟⠁ ⠈⠻⣦⣀ ⢿⣿⠁ | |
⢻⣾⡇ ⠘⣷ ⣼⠃ ⠘⣷⣠⣴⠟⠋ ⠙⢷⣄⢸⣿ | |
⠻⣧⡀ ⠘⣧⣰⡏ ⢀⣠⣤⠶⠛⠉⠛⠛⠛⠛⠛⠛⠻⢶⣶⣶⣶⣶⣶⣤⣤⣽⣿⣿ | |
⠈⠛⠷⢦⣤⣽⣿⣥⣤⣶⣶⡿⠿⠿⠶⠶⠶⠶⠾⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠁ | |
,,,;;;;;;;;;;;;;;;;;;;;;;,, | |
,,,;;;;;;;;;,, ,;;;' ''';;, | |
,,;;;''' ';;;, ,,;;'' '';, | |
,;;'' ;;;;;;;;,,,,,, ';; | |
,;;'' ;;;;';;;'''';;;;;;;;;,,,;; | |
,,;'' ;;;; ';;, ''''';;, | |
,;;' ;;;' ';;, ;; | |
,;;' ,;;; '';,, ;; | |
,;;' ;;; ';;, ,;; | |
;;' ;;;' '';,, ;;; | |
,;' ;;;; ';;, ;;' | |
,;;' ,;;;;' ,,,,,,,,,,,,;;;;; | |
,;' ,;;;;;;;;;;;;;;;;;;;;'''''''';;; | |
;;' ,;;;;;;;;;,, ;;;; | |
;;' ,;;;'' ;;, ';;,, ,;;;; | |
;;' ,;;;' ;; '';;, ,;';;; | |
;;' ,;;;' ;;, '';;,, ,;',;;; | |
,;;; ,;;;' ;; '';;,, ,;' ;;;' | |
;;;; ,,;;;' ;;, ';;;' ;;; | |
,;;; ,;;;;' ;; ,;;; ;;; | |
;;;;; ,,;;;;;' ;;, ,;';; ;;; | |
;;;;;, ,,;;;;;;;' ;; ,;;' ;;; ;;; | |
;;;;;;;,,,,,,,;;;;;;;;;;;;;;,,, ;;, ,;' ;; ;;; | |
;;' ;;;;;;;;;;'''' ,;';; ''';;;;,,, ;; ,;; ;; ;;; | |
;; ;;;'' ;; ';; ''';;;;,,,, ;;, ,;;' ;;, ;; | |
;; ;;;;, ;;' ';; ''';;;;,,;;;;' ';; ;; | |
;;;;;;';, ,;; ;; '';;;;, ;;,;; | |
;;; ;; ;;, ;; ;; ,;;' ';;, ;;;;; | |
;; ;;; ;;, ;;' ;; ,,;'' ';;, ;;;;; | |
;; ;; ;; ;; ;; ,;;' '';, ;;;; | |
;;,;; ;; ;;' ;; ,;;'' ';,, ;;;' | |
;;;; ';; ,;; ;;,,;;'' ';;, ;;; | |
';;; ';; ;; ,;;;;;;;;;;;;;,,,,,,,,,,,, ';;;;; | |
';, ';,;;' ,,,;;'' '''''''';;;;;;;;;;;;;;;;;;; | |
';;,,, ;;;; ,,,,;;;;;;,,,,,;;;;;;;;;;;;;;;;;;;'''''''''''''' | |
''';;;;;;;;;;;;;;''''''''''''''' | |
⣀⣤⣴⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣤⣄⡀ | |
⢀⣀⣤⣴⣾⣿⣿⣿⠿⣿⣿⣿⣿⣦⣀ ⢀⣤⣶⣿⠿⠛⠁⠈⠉⠙⠻⢿⣷⣦⡀ | |
⢀⣠⣴⣾⡿⠿⠛⠉⠉ ⠈⠙⢿⣿⣷⣤⡀ ⣠⣴⣾⡿⠟⠉ ⠉⠻⣿⣦ | |
⢀⣤⣶⣿⠟⠋⠁ ⢿⣿⣿⣿⣿⣿⣿⣧⣤⣤⣤⣀⣀⣀⡀ ⠘⢿⣷⡀ | |
⢀⣠⣾⡿⠟⠉ ⢸⣿⣿⣿⠟⢿⣿⣯⡙⠛⠛⠛⠿⠿⠿⢿⣿⣿⣶⣶⣶⣦⣤⣬⣿⣧ | |
⣠⣴⣿⠟⠋ ⢸⣿⣿⡿ ⠈⠻⣿⣶⣄ ⠉⠉⠉⠙⠛⢻⣿⡆ | |
⣠⣾⡿⠛⠁ ⣼⣿⣿⠃ ⠈⠙⢿⣷⣤⡀ ⠈⣿⡇ | |
⣠⣾⡿⠋ ⢠⣿⣿⡏ ⠙⠻⣿⣦⣀ ⣿⡇ | |
⣠⣾⡿⠋ ⢀⣿⣿⣿ ⠈⠛⢿⣷⣄⡀ ⢠⣿⡇ | |
⢀⣾⡿⠋ ⢀⣾⣿⣿⠇ ⠙⠻⣿⣦⣀ ⢸⣿⡇ | |
⢀⣴⣿⠟⠁ ⢀⣾⣿⣿⡟ ⠈⠻⢿⣷⣄ ⣾⣿⠇ | |
⢠⣾⡿⠃ ⣠⣿⣿⣿⣿⠃ ⣀⣀⣀⣀⣀⣀⣀⣀⣤⣤⣤⣤⣽⣿⣿⣿⣿ | |
⣰⣿⠟ ⣴⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠛⣿⣿⣿ | |
⣼⣿⠏ ⢠⣾⣿⣿⣿⡿⣿⣿⢿⣷⣦⣄ ⣼⣿⣿⣿ | |
⣼⣿⠃ ⢀⣴⣿⣿⣿⠟⠋ ⢸⣿⡆⠈⠛⠿⣿⣦⣄⡀ ⣰⣿⣿⣿⡇ | |
⢀⣾⣿⠃ ⢀⣴⣿⣿⣿⠟⠁ ⣿⣷ ⠈⠙⠻⣿⣶⣄⡀ ⣰⣿⠟⣿⣿⡇ | |
⢀⣾⣿⠇ ⢀⣴⣿⣿⣿⠟⠁ ⢸⣿⡆ ⠙⠻⢿⣷⣤⣀ ⣰⣿⠏⢠⣿⣿⡇ | |
⢠⣿⣿⡟ ⢀⣴⣿⣿⡿⠛⠁ ⣿⣷ ⠉⠻⢿⣷⣦⣀ ⣴⣿⠏ ⢸⣿⣿⠃ | |
⣿⣿⣿⡇ ⣠⣴⣿⣿⡿⠋ ⢸⣿⡆ ⠈⠛⢿⣿⣿⠃ ⢸⣿⣿ | |
⢠⣿⣿⣿ ⢀⣴⣾⣿⣿⡿⠋ ⠈⣿⣧ ⢠⣾⣿⣿ ⢸⣿⣿ | |
⢸⣿⣿⣿⡇ ⣀⣴⣾⣿⣿⣿⡿⠋ ⢹⣿⡆ ⣴⣿⠟⢹⣿⡀ ⢸⣿⡿ | |
⢸⣿⡟⣿⣿⣄ ⣀⣤⣶⣿⣿⣿⣿⣿⡟⠉ ⠈⣿⣷ ⢠⣾⡿⠋ ⢸⣿⡇ ⣼⣿⡇ | |
⢸⣿⡇⢹⣿⣿⣷⣦⣤⣤⣤⣤⣤⣴⣶⣾⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣷⣶⣤⣤⣀⡀ ⢹⣿⡆ ⢀⣴⣿⠟ ⣿⣧ ⣿⣿⡇ | |
⢸⣿⠃ ⢿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠛⠛⠉⠉⠁ ⢰⣿⠟⣿⣷⡀⠉⠙⠛⠿⢿⣿⣶⣦⣤⣀⡀ ⠈⣿⣷ ⣠⣿⡿⠁ ⢿⣿ ⣿⣿⡇ | |
⢸⣿ ⢀⣾⣿⣿⠋⠉⠁ ⢀⣿⡿ ⠘⣿⣷⡀ ⠉⠙⠛⠿⠿⣿⣶⣦⣤⣄⣀ ⢹⣿⡄ ⣠⣾⡿⠋ ⢸⣿⡆ ⣿⣿ | |
⣸⣿⢀⣾⣿⣿⣿⣆ ⣸⣿⠃ ⠘⢿⣷⡀ ⠈⠉⠛⠻⠿⣿⣷⣶⣤⣌⣿⣷⣾⡿⠋ ⠘⣿⡇ ⣿⣿ | |
⣿⣿⣾⡿⣿⡿⠹⣿⡆ ⢠⣿⡏ ⠈⢿⣷⡀ ⠈⠉⠙⣻⣿⣿⣿⣀ ⣿⣷⢰⣿⣿ | |
⣿⣿⡿⢁⣿⡇ ⢻⣿⡄ ⣾⣿ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠋⠈⠻⢿⣷⣄ ⢻⣿⢸⣿⡟ | |
⣿⣿⠁⢸⣿⡇ ⢻⣿⡄ ⢸⣿⠇ ⠈⢿⣷⡀ ⣀⣴⣿⠟⠋ ⠙⢿⣷⣤⡀ ⢸⣿⣿⣿⡇ | |
⣿⣿ ⢸⣿⠁ ⠈⢿⣷⡀ ⢀⣿⡟ ⠈⢿⣷⡀ ⢀⣤⣾⡿⠛⠁ ⠙⠻⣿⣦⡀ ⠈⣿⣿⣿⡇ | |
⢸⣿⡄⣿⣿ ⠈⣿⣷⡀ ⣼⣿⠃ ⠈⢿⣷⡀ ⢀⣠⣶⣿⠟⠋ ⠈⠻⣿⣦⣄ ⣿⣿⣿⠇ | |
⠈⣿⣷⣿⡿ ⠘⣿⣧ ⢠⣿⡏ ⠈⢿⣷⣄⣤⣶⣿⠟⠋ ⠈⠛⢿⣷⣄ ⢸⣿⣿ | |
⠘⣿⣿⡇ ⠘⣿⣧ ⣾⣿ ⢀⣠⣼⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣶⣤⣤⣤⣤⣤⣤⣀⣀⣀⣀⣀⣀⡀ ⠙⢿⣷⣼⣿⣿ | |
⠈⠻⣿⣦⡀ ⠹⣿⣆⢸⣿⠇ ⣀⣠⣴⣾⡿⠟⠋⠁ ⠉⠉⠉⠉⠉⠉⠛⠛⣛⣛⣛⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿ | |
⠈⠻⢿⣷⣦⣄⣀⡀ ⢹⣿⣿⡟ ⢀⣀⣀⣤⣤⣶⣾⣿⣿⣿⣯⣥⣤⣤⣤⣤⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠟⠛⠛⠛⠛⠛⠛⠛⠉⠉⠉⠉⠉⠉ | |
⠉⠙⠛⠿⠿⠿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠉ |
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
require 'chunky_png' | |
img = ChunkyPNG::Image.from_file('logo.png') | |
clip_x = 130 | |
clip_y = 74 | |
clip_width = 800 | |
clip_height = 800 | |
size = [80, 144].sample | |
width = size + 2 | |
height = size + 2 | |
x_trans = -> x { clip_x + x * clip_width / width } | |
y_trans = -> y { clip_y + y * clip_height / height } | |
output = height.times.map do |y| | |
width.times.map do |x| | |
range_x = x_trans[x]...x_trans[x + 1] | |
range_y = y_trans[y]...y_trans[y + 1] | |
alpha = range_x.sum do |ix| | |
range_y.sum do |iy| | |
alpha = img[ix, iy] & 0xff | |
alpha.fdiv 0xff | |
end | |
end / range_x.size / range_y.size | |
alpha < 0.5 ? 0 : 1 | |
end[1...-1] | |
end[1...-1] | |
puts output.each_slice(4).map { |a,b,c,d| | |
a.zip(b,c,d).map.each_slice(2).map { |l, r| | |
n = ((l[0,2]+r[0,2]).sum > 1 ? 1 : 0) + ((l[2,2]+r[2,2]).sum > 1 ? 2 : 0 ) | |
" ',;"[n] | |
}.join.rstrip | |
} | |
puts output.each_slice(4).map { |a,b,c,d| | |
a.zip(b,c,d).map.each_slice(2).map { |l, r| | |
n = (l[0,3] + r[0,3]+ [l[3],r[3]]).join.reverse.to_i(2) | |
n == 0 ? ' ' : ''<<(10240 + n) | |
}.join.rstrip | |
} | |
puts output.map(&:join) |
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
<style> | |
img, canvas { | |
width: 1024px; | |
position:absolute; | |
left:0;top:0; | |
} | |
</style> | |
<img src="a.png" style="width:1024px"> | |
<canvas width="1024" height="1024"></canvas> | |
<script> | |
const canvas = document.querySelector('canvas') | |
const context = canvas.getContext('2d') | |
context.lineCap = context.lineJoin = 'round' | |
// canvas.onclick = e => { | |
// context.clearRect(0, 0, 1024, 1024) | |
// context.fillRect(e.pageX, e.pageY, 1, 1) | |
// context.fillText(`(${e.pageX},${e.pageY})`,e.pageX+4, e.pageY-4) | |
// } | |
const pointsA = [ | |
[583 ,92], | |
[672, 158], | |
[612, 357], | |
[391, 563], | |
[194, 608], | |
[154, 484], | |
[235, 320], | |
[402, 157] | |
] | |
const pointsB = [ | |
[789, 92], | |
[905, 191], | |
[893, 339], | |
[823, 488], | |
[686, 657], | |
[508, 789], | |
[302, 856.5], | |
[174, 803], | |
[145, 703], | |
] | |
const pointList = [ | |
[[500, 124], ...pointsA.slice(0, 6), [213, 380]], | |
[pointsA[0], pointsB[0], pointsA[1]], | |
[pointsA[1], pointsB[1]], | |
[pointsA[1], pointsB[2], pointsA[2]], | |
[pointsA[2], pointsB[3]], | |
[pointsA[2], pointsB[4], pointsA[3]], | |
[pointsA[3], pointsB[5]], | |
[pointsA[3], pointsB[6], pointsA[4]], | |
[pointsA[4], pointsB[7]], | |
[pointsA[4], pointsB[8], pointsA[5]], | |
...[[911,247],...[2,3,4,5,6].map(i => pointsB[i])].map(p => [p, [868, 818]]), | |
] | |
context.lineWidth = 20 | |
for (const points of pointList) { | |
context.beginPath() | |
context.moveTo(...points[0]) | |
for (const point of points) { | |
context.lineTo(...point) | |
} | |
context.stroke() | |
} | |
context.beginPath() | |
context.save() | |
context.translate(408, 347) | |
context.rotate(Math.PI/4) | |
context.scale(0.44,1) | |
context.arc(0, 0, 307, 0, Math.PI*2, true) | |
context.restore() | |
// context.moveTo(...pointsA[pointsA.length - 1]) | |
// for (const p of pointsA) context.lineTo(...p) | |
// context.fill() | |
context.stroke() | |
context.beginPath() | |
context.save() | |
context.translate(528, 473) | |
context.rotate(Math.PI/4) | |
context.scale(0.5,1) | |
context.arc(0, 0, 485, 4.36, 8.32) | |
context.restore() | |
context.stroke() | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment