Created
November 30, 2023 01:29
-
-
Save jbclements/06fa76efddf35bf767ad3076f63067d6 to your computer and use it in GitHub Desktop.
a first pass at a rhombus logo
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
#lang rhombus | |
import: | |
lib("2htdp/image.rkt") as img | |
lib("racket/base.rkt") | |
lib("lang/posn.rkt") | |
def make_color = img.#{make-color} | |
def empty_scene = img.#{empty-scene} | |
def posn = posn.#{make-posn} | |
def add_polygon = img.#{add-polygon} | |
def write_special = base.#{write-special} | |
def the_blue = make_color(0x3e, 0x5b, 0xa9) | |
def the_red = make_color(0x9f, 0x1d, 0x20) | |
/* | |
// measurements taken from scanned sketch image, now expressed using fractions | |
#;( | |
(define tl-x 1298) | |
;(define tl-y 1562) | |
(define tr-x 1845) | |
(define tr-y 1567) | |
(define lr-x 1578) | |
(define lr-y 2183) | |
(define lr2-x 1391) | |
(define red-right-y 1892) | |
(define red-left-y 2018) | |
(define little-red-triangle-tip-y 1996) | |
(define little-red-triangle-other-tip-x 1155) | |
(define stripe-lower-edge 1716) | |
(define PRE-white-stripe-height (- 87 16)) | |
(define PRE-white-stripe-width (- 1402 1314)) | |
(define PRE-height (- lr-y tr-y)) | |
(define PRE-slant-x (- tr-x lr-x)) | |
(define PRE-red-right-drop (- red-right-y tr-y)) | |
(define PRE-red-left-drop (- red-left-y tr-y)) | |
(define PRE-red-triangle-drop (- little-red-triangle-tip-y tr-y)) | |
(define PRE-stripe-height (- stripe-lower-edge tr-y)) | |
(define PRE-stripe-width (- lr-x lr2-x)) | |
(define PRE-red-triangle-width-plus-stripes (- lr-x little-red-triangle-other-tip-x)) | |
(define PRE-2-stripes-width (+ PRE-stripe-width PRE-white-stripe-width)) | |
(define PRE-red-triangle-width (- PRE-red-triangle-width-plus-stripes PRE-2-stripes-width)) | |
(define PRE-red-triangle-tip-jog 10) | |
) | |
*/ | |
// Adjust these: | |
// all heights are as a fraction of the total height. | |
// all widths are as a fraction of the base width. | |
def theta = 2*math.pi*(70/360) | |
// height as a multiple of the base length | |
// originally PRE-height / top-len | |
def height_frac = math.sin(theta) | |
// rightward displacement of the top | |
// originally PRE-slant-x / top-len | |
def slant_x_frac = math.cos(theta) | |
// vertical thickness of the outer blue stripe | |
// originally (/ PRE_stripe_height height) | |
def stripe_height_frac = 0.20 | |
// width of the outer blue stripe | |
// originally (/ PRE_stripe_width base_width) | |
def stripe_width_frac = 0.25 | |
// vertical thickness of the white stripe inside the blue stripe | |
// originally #;(/ PRE_white_stripe_height height) | |
def white_stripe_height_frac = 0.09 | |
// width of the white stripe inside the blue stripe | |
// originally #;(/ PRE_white_stripe_width base_width) | |
def white_stripe_width_frac = 0.11 | |
// height from the top of the image to the lower right corner of the red quadrilateral | |
// originially (/ PRE_red_right_drop height) | |
def red_right_drop_frac = 0.5 | |
// height from the top of the image to the lower left corner of the red quadrilateral | |
// originally (/ red_left_drop height) | |
def red_left_drop_frac = 0.733 | |
// height from the top of the image to the top of the lower red triangle | |
// originally (/ PRE_red_triangle_drop height) | |
def red_triangle_drop_frac = 0.65 | |
// width of the lower red triangle | |
// originally (/ red_triangle_width base_width) | |
def red_triangle_width_frac = 0.550 | |
// amount by which the tip of the lower red triangle is moved to the right | |
// originally (/ red_triangle_tip_jog base_width) | |
def red_triangle_tip_jog_frac = 0.02 | |
// originally (- tr_x tl_x) | |
def base_width = 350.0 | |
def red_triangle_tip_jog = red_triangle_tip_jog_frac * base_width | |
def height = base_width * height_frac | |
def slant_x = base_width * slant_x_frac | |
def stripe_height = stripe_height_frac * height | |
def stripe_width = stripe_width_frac * base_width | |
def white_stripe_height = white_stripe_height_frac * height | |
def white_stripe_width = white_stripe_width_frac * base_width | |
def red_left_drop = red_left_drop_frac * height | |
def red_right_drop = red_right_drop_frac * height | |
def red_triangle_drop = red_triangle_drop_frac * height | |
def red_triangle_width = red_triangle_width_frac * base_width | |
def slope = height / slant_x | |
def two_stripes_height = stripe_height + white_stripe_height | |
def two_stripes_width = stripe_width + white_stripe_width | |
def full_width = base_width + slant_x | |
def inner_box_width = base_width - two_stripes_width | |
def margin = 50 | |
def the_scene = empty_scene(2 * margin + full_width, 2 * margin + height) | |
// given the distance from the top of the image, compute the leftward shift | |
fun drop_to_slide(drop): | |
drop / slope | |
// given a distance from the left side of the un-skewed figure | |
// and a height from the top, return the posn of the skewed figure | |
fun skew_posn(x,y): | |
[full_width - drop_to_slide(y) - (base_width - x), y] | |
check skew_posn(0,0) ~is_now [slant_x,0] | |
check skew_posn(base_width,0) ~is_now [full_width,0] | |
check skew_posn(0,height) ~is_now [0.0,height] | |
check skew_posn(base_width,height) ~is_now [base_width,height] | |
// skew and shift for margin | |
fun reposition(x,y): | |
match skew_posn(x,y) | |
| [x,y]: posn(x+margin,y+margin) | |
def left_jog_1 = drop_to_slide(stripe_height) | |
def left_jog_2 = drop_to_slide(two_stripes_height) | |
// all positions are specified in an "un-slanted" frame, then slanted | |
// by a call to skew_posn | |
def outer_blue_stripe_posns: | |
[reposition(0,0), | |
reposition(base_width,0), | |
reposition(base_width,height), | |
reposition(base_width - stripe_width, height), | |
reposition(base_width - stripe_width, stripe_height), | |
reposition(0,stripe_height)] | |
def left_red_block_posns: | |
[reposition(0,two_stripes_height), | |
reposition(inner_box_width, two_stripes_height), | |
reposition(inner_box_width, red_right_drop), | |
reposition(0, red_left_drop)] | |
def lower_red_triangle_posns: | |
[reposition(red_triangle_tip_jog + (inner_box_width), red_triangle_drop), | |
reposition(inner_box_width, height), | |
reposition(inner_box_width - red_triangle_width, height)] | |
def s2: | |
add_polygon( | |
add_polygon( | |
add_polygon(the_scene, | |
outer_blue_stripe_posns, | |
"solid", | |
the_blue), | |
left_red_block_posns, | |
"solid", | |
the_red), | |
lower_red_triangle_posns, | |
"solid", | |
the_red) | |
write_special(s2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment