Skip to content

Commit

Permalink
Add src docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Dec 17, 2023
1 parent 69e42b9 commit fe17be4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,17 @@ ctr_object* ctr_line_end(ctr_object* myself, ctr_argument* argumentList) {
return ctr_internal_object_property(myself, CTR_DICT_TO, NULL);
}

/**
* @def
* [ Color ] new
*
* @example
* ☞ media ≔ Media new.
* ☞ x ≔ Color new.
* ✎ write: x red, stop.
* ✎ write: x green, stop.
* ✎ write: x blue, stop.
*/
ctr_object* ctr_color_new(ctr_object* myself, ctr_argument* argumentList) {
ctr_object* instance = ctr_internal_create_object(CTR_OBJECT_TYPE_OTOBJECT);
instance->link = myself;
Expand All @@ -1445,6 +1456,17 @@ ctr_object* ctr_color_new(ctr_object* myself, ctr_argument* argumentList) {
return instance;
}

/**
* @def
* [ Color ] red: [Number] green: [Number] blue [Number]
*
* @example
* ☞ media ≔ Media new.
* ☞ x ≔ Color new red: 100 green: 150 blue: 200.
* ✎ write: x red, stop.
* ✎ write: x green, stop.
* ✎ write: x blue, stop.
*/
ctr_object* ctr_color_rgb_set(ctr_object* myself, ctr_argument* argumentList) {
ctr_internal_object_property(myself, "r", ctr_internal_cast2number(argumentList->object));
ctr_internal_object_property(myself, "g", ctr_internal_cast2number(argumentList->next->object));
Expand Down Expand Up @@ -1489,6 +1511,17 @@ void ctr_audio_destructor(ctr_resource* rs) {
mediaAUD->ref = NULL;
}

/**
* @def
* [ Sound ] play
*
* @example
* ☞ fx ≔ Sound new: ‘boom.mp3’.
* fx play.
*
* @result
* (plays sound)
*/
ctr_object* ctr_sound_new_set(ctr_object* myself, ctr_argument* argumentList) {
if (AUDCount >= maxAUD) return CtrStdNil;
char* audioFileStr = ctr_heap_allocate_cstring(ctr_internal_cast2string(argumentList->object));
Expand Down Expand Up @@ -1566,6 +1599,21 @@ SDL_RWops* ctr_internal_media_load_asset(char* asset_name, char asset_type) {
return res;
}

/**
* @def
* [ Music ] play
*
* @example
* ☞ j ≔ Music new: ‘jazz.mp3’.
* j play.
* Moment wait: 1.
* j silence.
* j rewind.
*
* @result
* 𝄞 (plays music)
*
*/
ctr_object* ctr_music_new_set(ctr_object* myself, ctr_argument* argumentList) {
char* audioFileStr = ctr_heap_allocate_cstring(ctr_internal_cast2string(argumentList->object));
ctr_object* audioInst = ctr_audio_new(myself, argumentList);
Expand Down

0 comments on commit fe17be4

Please sign in to comment.