Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

* * * IN DRRACKET ONLY * * * * My code has the first part which displays the first 3 polygons i just need

*** IN DRRACKET ONLY****
My code has the first part which displays the first 3 polygons i just need assitance with the last part. please dont add other libraries i only need racket/draw and colors:
#lang racket
(require racket/draw) ; graphics library
(require colors)
(define imageWidth 512)
(define imageHeight 288)
(define target (make-bitmap imageWidth imageHeight)) ; A bitmap
(define dc (new bitmap-dc%[bitmap target])) ; a drawing context
; Draw a rectangle that fills the screen with a background color
(send dc set-pen "transparent" 1 'solid) ; set pen to transparent mode
(send dc set-brush (make-color 500100) 'solid) ; set fill color
(send dc draw-rectangle 00 imageWidth imageHeight) ; draw filled rectangle
(define originalPolygon (new dc-path%))
(send originalPolygon move-to -30-30) ; input points
(send originalPolygon line-to -1030)
(send originalPolygon line-to 1030)
(send originalPolygon line-to 30-30)
(send originalPolygon close)
(send dc set-pen "red" 1 'solid) ; set pen color
(send dc set-brush (make-color 02000) 'solid) ; set fill color
; Draw the original polygon
(send dc draw-path originalPolygon)
; Define translation amounts
(define dx 50) ; translation in x-direction
(define dy 50) ; translation in y-direction
; Translate the original polygon and then draw it again
(define translatedPolygon (new dc-path%))
(send translatedPolygon append originalPolygon)
(send translatedPolygon translate dx dy)
(send dc draw-path translatedPolygon)
; Define scaling factors
(define sx 1.8) ; scale factor in x-direction
(define sy 1.5) ; scale factor in y-direction
; Scale the original polygon and then draw it a third time
(define scaledPolygon (new dc-path%))
(send scaledPolygon append originalPolygon)
(send scaledPolygon scale sx sy)
; Define translation amounts for the scaled polygon
(define scaledDx 140) ; translation in x-direction
(define scaledDy 100) ; translation in y-direction
; Translate the scaled polygon and then draw it a third time
(define translatedScaledPolygon (new dc-path%))
(send translatedScaledPolygon append scaledPolygon)
(send translatedScaledPolygon translate scaledDx scaledDy)
(send dc draw-path translatedScaledPolygon)
target ; show image
Construct a loop or recursive function that
Rotates the polygon
Sets the color
Draws the polygon
Rotate through 360 degrees. (in, say 90 polygons or so)
Cycle through all of the colors in the color wheel.
Save your image
Display your image
Success should look like this: Success
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions